Sha256: f6ff9dbdcb227bbcbd7e95d06e4fdbe11ae7373f0a31a38ddf64702bbf6215da
Contents?: true
Size: 933 Bytes
Versions: 1
Compression:
Stored size: 933 Bytes
Contents
module Lita module Handlers class Whoami < Handler REDIS_KEY = 'lita-whoami' route(/^(\w+) is (.+)/, :assign_person, command: true, help: { "SOMEONE is SOMETHING" => "Tell everbot that someone is something." }) route(/^who ?is (\w+)/, :describe_person, command: true, help: { "who is PERSON" => "Everbot will tell you who somebody is." }) def key_for_person name "#{REDIS_KEY}:#{name}" end def assign_person(chat) name, thing = chat.matches[0] return if name == 'who' redis.rpush key_for_person(name), thing chat.reply "Okay, #{name} is #{thing}!" end def describe_person(chat) name = chat.matches[0][0] descriptors = redis.lrange(key_for_person(name), 0, -1).uniq chat.reply "#{name} is #{descriptors.join ', '}" end Lita.register_handler(self) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lita-whoami-0.1.2 | lib/lita/handlers/whoami.rb |