module Slackr

slack = Slackr.connect(“teamX”, “token124”, {“channel” => “#myroom”, “username” => “systems_bot”}) slack.say “hello world” => posts 'hello world' to the myroom channel as the systems_bot user slack.say “hello”, {“channel” => “#room2”, “username” => “joke_bot”} => posts 'hello' to the room2 channel as the joke_but user slack.upload “/path/to/a/file.txt”, {“channels” => “X026VKGP7”} => uploads a file to the channel specified by ID slack.channels.list => returns a hash of channel objects

slack_options {

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

}

Constants

VERSION

Attributes

connection[RW]

Public Instance Methods

channels() click to toggle source
# File lib/slackr.rb, line 34
def channels
  Slackr::Channel.init(connection)
end
connect(team, token, options = {}) click to toggle source
# 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 = {}) click to toggle source
# File lib/slackr.rb, line 26
def say(text, options = {})
  Slackr::IncomingWebhook.say(connection, text, options)
end
upload(filepath, options = {}) click to toggle source
# File lib/slackr.rb, line 30
def upload(filepath, options = {})
  Slackr::FileUploader.new(connection, filepath, options).upload
end