Class: AsakusaRssMonitor::PostBot
- Inherits:
-
Object
- Object
- AsakusaRssMonitor::PostBot
- Defined in:
- lib/asakusa-rss-monitor/post-bot.rb
Instance Method Summary collapse
- #get_rooms ⇒ Object
-
#initialize(config) ⇒ PostBot
constructor
A new instance of PostBot.
- #post(message) ⇒ Object
Constructor Details
#initialize(config) ⇒ PostBot
Returns a new instance of PostBot.
7 8 9 |
# File 'lib/asakusa-rss-monitor/post-bot.rb', line 7 def initialize(config) @config = config[:bot_config] end |
Instance Method Details
#get_rooms ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/asakusa-rss-monitor/post-bot.rb', line 20 def get_rooms uri = URI(@config.entry_point) Net::HTTP.version_1_2 Net::HTTP.start(uri.host, uri.port) do |http| response = http.get(uri.path + "/room/list.json") p response.body end end |
#post(message) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/asakusa-rss-monitor/post-bot.rb', line 11 def post() uri = URI(@config.entry_point) Net::HTTP.version_1_2 Net::HTTP.start(uri.host, uri.port) do |http| p http.post(uri.path + "/message.json", "room_id=#{@config.room_id}&api_key=#{@config.api_key}&message=#{}") end end |