Class: DevTrainingBot::SlackService

Inherits:
Object
  • Object
show all
Defined in:
lib/dev_training_bot/services/slack_service.rb

Instance Method Summary collapse

Constructor Details

#initializeSlackService

Returns a new instance of SlackService.



11
12
13
14
# File 'lib/dev_training_bot/services/slack_service.rb', line 11

def initialize
  @client = Slack::Web::Client.new
  @client.auth_test
end

Instance Method Details

#create_poll(topics) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/dev_training_bot/services/slack_service.rb', line 16

def create_poll(topics)
  return no_topics_available if topics.empty?

  next_friday = Chronic.parse('next friday').to_date

  @client.chat_command channel: ENV['SLACK_CHANNEL'],
                       command: '/poll',
                       text: "\"@here Vote for the next dev learning! [#{next_friday}]\" #{topics}"
end


32
33
34
35
36
# File 'lib/dev_training_bot/services/slack_service.rb', line 32

def link_doc
  @client.chat_postMessage channel: ENV['SLACK_CHANNEL'],
                           text: GoogleDriveService::DOC_URL,
                           as_user: true
end

#no_topics_availableObject



26
27
28
29
30
# File 'lib/dev_training_bot/services/slack_service.rb', line 26

def no_topics_available
  @client.chat_postMessage channel: ENV['SLACK_CHANNEL'],
                           text: '<!here> Please propose your topics for the next Dev Learning!',
                           as_user: true
end