Sha256: 7edc4a4dbef93798e3aad5c3c0c126f3219288874659d51b1c84ae6aad679ab0
Contents?: true
Size: 873 Bytes
Versions: 3
Compression:
Stored size: 873 Bytes
Contents
module Ruboty module Handlers class GoodNight < Base BRAIN_NAMESPACE = 'ruboty-goodnight' on /おやすみ/, name: 'greet', description: 'greet to ruboty' def initialize(*args) super if robot.brain.data[BRAIN_NAMESPACE] trap_message(room) end end def greet(message) save(message) message.reply('まだ寝ないよ!') end private def save(message) robot.brain.data[BRAIN_NAMESPACE] = message.original.except(:robot) trap_message(message) end def room Ruboty::Message.new(robot.brain.data[BRAIN_NAMESPACE].merge(robot: robot)) end def trap_message(message) Signal.trap('TERM') do message.reply('おやすみ〜') Process.kill 'QUIT', Process.pid end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruboty-good-night-0.1.4 | lib/ruboty/handlers/good_night.rb |
ruboty-good-night-0.1.3 | lib/ruboty/handlers/good_night.rb |
ruboty-good-night-0.1.2 | lib/ruboty/handlers/good_night.rb |