Module: Slackr

Extended by:
Slackr
Included in:
Slackr
Defined in:
lib/slackr.rb,
lib/slackr/errors.rb,
lib/slackr/channel.rb,
lib/slackr/version.rb,
lib/slackr/connection.rb,
lib/slackr/file_uploader.rb,
lib/slackr/webhooks/incoming.rb

Overview

slack_options { "channel" => "#myroom", "username" => "my_bot_name", "icon_url" => "https://slack.com/img/icons/app-57.png", "icon_emoji" => ":ghost:" }

Defined Under Namespace

Modules: Channel, IncomingWebhook Classes: ArgumentError, Connection, FileUploader, ServiceError, Webhook

Constant Summary collapse

VERSION =
"0.0.6"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



16
17
18
# File 'lib/slackr.rb', line 16

def connection
  @connection
end

Instance Method Details

#channelsObject



34
35
36
# File 'lib/slackr.rb', line 34

def channels
  Slackr::Channel.init(connection)
end

#connect(team, token, options = {}) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/slackr.rb', line 18

def connect(team, token, options = {})
  raise Slackr::ArgumentError, "Team required"  if team.nil?
  raise Slackr::ArgumentError, "Token required" if token.nil?
  #TODO: raise error if options doesn't contain channel and username values
  @connection = Slackr::Connection.new(team, token, options).init
  return self
end

#say(text, options = {}) ⇒ Object



26
27
28
# File 'lib/slackr.rb', line 26

def say(text, options = {})
  Slackr::IncomingWebhook.say(connection, text, options)
end

#upload(filepath, options = {}) ⇒ Object



30
31
32
# File 'lib/slackr.rb', line 30

def upload(filepath, options = {})
  Slackr::FileUploader.new(connection, filepath, options).upload
end