lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-1.0.1 vs lib/ruboty/adapters/slack_rtm.rb in ruboty-slack_rtm-1.1.0
- old
+ new
@@ -13,13 +13,20 @@
bind
connect
end
def say(message)
+ channel = message[:to]
+ if channel[0] == '#'
+ channel = resolve_channel_id(channel[1..-1])
+ end
+
+ return unless channel
+
realtime.send(
type: 'message',
- channel: message[:to],
+ channel: channel,
text: message[:code] ? "```\n#{message[:body]}\n```" : resolve_send_mention(message[:body]),
mrkdwn: true
)
end
@@ -217,9 +224,20 @@
{}
end
resp['channel']
end
+ end
+
+ def resolve_channel_id(name)
+ ret_id = nil
+ @channel_info_cahces.each_pair do |id, channel|
+ if channel['name'] == name
+ ret_id = id
+ break
+ end
+ end
+ return ret_id
end
end
end
end