Module: ImmosquareSlack::Channel
- Extended by:
- SharedMethods
- Defined in:
- lib/immosquare-slack/channel.rb
Class Method Summary collapse
-
.list_channels ⇒ Object
## Pour récupérer la liste des channels ============================================================##.
-
.post_message(channel_name, text, notify: nil, notify_text: nil, bot_name: nil) ⇒ Object
## Pour poster un message dans un channel ============================================================##.
Class Method Details
.list_channels ⇒ Object
##
Pour récupérer la liste des channels
##
9 10 11 |
# File 'lib/immosquare-slack/channel.rb', line 9 def list_channels fetch_paginated_data("https://slack.com/api/conversations.list", "channels") end |
.post_message(channel_name, text, notify: nil, notify_text: nil, bot_name: nil) ⇒ Object
##
Pour poster un message dans un channel
##
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/immosquare-slack/channel.rb', line 16 def (channel_name, text, notify: nil, notify_text: nil, bot_name: nil) channel_id = get_channel_id_by_name(channel_name) raise("Channel not found") if channel_id.nil? url = "https://slack.com/api/chat.postMessage" text = "#{build_notification_text(channel_id, notify, notify_text) if notify.present?}#{text}" body = { :channel => channel_id, :text => text, :username => bot_name.presence } make_slack_api_call(url, :method => :post, :body => body) end |