Sha256: f9885759383cf6d7d05c00086fe6b60fe25a4e2f31beed360eb9347d9f519a3a
Contents?: true
Size: 906 Bytes
Versions: 1
Compression:
Stored size: 906 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: { "SOMEONE is SOMETHING" => "Tell everbot that someone is something." }) def key_for_person name "#{REDIS_KEY}:#{name}" end def assign_person(chat) name, thing = chat.matches[0] 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.0 | lib/lita/handlers/whoami.rb |