Class: Pairity::Slackbot

Inherits:
Object
  • Object
show all
Defined in:
lib/pairity/slackbot.rb

Instance Method Summary collapse

Constructor Details

#initializeSlackbot



6
7
8
9
10
11
12
13
14
15
# File 'lib/pairity/slackbot.rb', line 6

def initialize
  Config.load
  hook = Config.get(:url)
  options = {
    icon_url: 'https://static1.squarespace.com/static/54e22d6be4b00617871820ca/54e567bbe4b022f3194c63b5/55ddd86ae4b0f0c3127f8483/1440605037480/?format=1000w',
    username: 'Pairity',
    channel: slack_channel
  }
  @poster = Slack::Poster.new(hook, options)
end

Instance Method Details

#post(message) ⇒ Object



17
18
19
# File 'lib/pairity/slackbot.rb', line 17

def post(message)
  @poster.send_message(message)
end

#slack_channelObject



21
22
23
24
25
# File 'lib/pairity/slackbot.rb', line 21

def slack_channel
  channel = Config.get(:channel)
  return "#" + channel unless channel =~ /^#/
  channel
end