Sha256: ab7aacbd2696c834759824b238d3b6d412f6dcefe303a0ee16aed7551969abcd
Contents?: true
Size: 903 Bytes
Versions: 1
Compression:
Stored size: 903 Bytes
Contents
module Lita module Handlers class TaskScheduler < Handler # insert handler code here # on :unhandled_message, :rebroadcast def rebroadcast(payload) serialized = serialize_message(payload) resend(serialized) end def resend(serialized) user = Lita::User.new(serialized.fetch(:user_name)) room = Lita::Room.new(serialized.fetch(:room_name)) source = Lita::Source.new(user: user, room: room) newmsg = Lita::Message.new( robot, "#{robot.name} double #{rand(1..100)}", source ) robot.receive newmsg end def serialize_message(payload) msg = payload.fetch(:message) { user_name: msg.user.name, room_name: msg.source.room, body: msg.body } end Lita.register_handler(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-task-scheduler-0.1.0 | lib/lita/handlers/task_scheduler.rb |