lib/robit/plugins/alias_nick.rb in robit-1.0.2 vs lib/robit/plugins/alias_nick.rb in robit-1.0.3

- old
+ new

@@ -24,29 +24,37 @@ def handle time, sender_nick, message if message =~ /^#aliases\s+@??(.+)/ handle_aliases "@#{$1}" - elsif message =~ /^#alias\s+@??(.+?)\s+(@.*+)/ + elsif message =~ /^#aliases\s*$/ + handle_aliases + elsif message =~ /^#alias\s+@??(\w+?)\W\s*(@.*+)/ handle_alias "@#{$1}", $2.split(' ') elsif sent_to_me?(message) # nop else - mentions = message.scan /@\S+/ + mentions = message.scan /@\w+/ handle_notification sender_nick, mentions, message end end private - def handle_aliases nick - puts 'handle_aliases nick=%s' % nick.inspect - rooms = db[nick] - if rooms.empty? - reply "Couldn't find any aliases." + def handle_aliases nick=nil + if nick + puts 'handle_aliases nick=%s' % nick.inspect + rooms = db[nick] + if rooms.empty? + reply "Couldn't find any aliases." + else + reply rooms.join(', ') + end else - reply rooms.join(', ') + db.each do |nick, rooms| + reply '%s: %s' % [ nick, rooms.join(', ') ] + end end end def handle_alias nick, rooms \ No newline at end of file