class Ruboty::Adapters::ChatworkWebhook
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/ruboty/adapters/chatwork_webhook.rb, line 13 def initialize(*args) super server end
Public Instance Methods
run()
click to toggle source
# File lib/ruboty/adapters/chatwork_webhook.rb, line 18 def run listen end
say(message)
click to toggle source
# File lib/ruboty/adapters/chatwork_webhook.rb, line 22 def say(message) ChatWork::Message.create(room_id: message[:original][:room_id], body: message[:body]) end
Private Instance Methods
listen()
click to toggle source
# File lib/ruboty/adapters/chatwork_webhook.rb, line 28 def listen server.start end
server()
click to toggle source
# File lib/ruboty/adapters/chatwork_webhook.rb, line 32 def server server = WEBrick::HTTPServer.new({ Port: ENV['WEBHOOK_LISTEN_PORT'], }) server.mount_proc '/' do |req, res| mention = Mention.new(req.body) pp 'received-> ' + mention.body robot.receive(body: mention.body, from_id: mention.from_account_id, room_id: mention.room_id, mention: mention) end server end