summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2010-03-13 09:31:28 +0000
committerRobin H. Johnson <robbat2@gentoo.org>2010-03-14 21:08:48 +0000
commit8473982fbfa276ced1394bf704e6de379a0f3e65 (patch)
tree4eade0cda9c43bb37b6867e176aa095334509498
parent53c82a94714e439c63a65fccdaf2512383cffb7a (diff)
basics: implement a channel list status query
This gets the list of channels we think we are in (not what the server says we are in). Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r--lib/rbot/core/basics.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/rbot/core/basics.rb b/lib/rbot/core/basics.rb
index d5ff5fb9..24d45419 100644
--- a/lib/rbot/core/basics.rb
+++ b/lib/rbot/core/basics.rb
@@ -69,6 +69,20 @@ class BasicsModule < CoreBotModule
end
end
+ def bot_channel_list(m, param)
+ ret = _('I am in: ')
+ # sort the channels by the base name and then map with prefixes for the
+ # mode and display.
+ ret << @bot.channels.compact.sort { |a,b|
+ a.name.downcase <=> b.name.downcase
+ }.map { |c|
+ c.modes_of(@bot.myself).map{ |mo|
+ m.server.prefix_for_mode(mo)
+ }.to_s + c.name
+ }.join(', ')
+ m.reply ret
+ end
+
def bot_quit(m, param)
@bot.quit param[:msg].to_s
end
@@ -212,6 +226,9 @@ basics.map "part :chan",
:action => 'bot_part',
:defaults => {:chan => nil},
:auth_path => 'move'
+basics.map "channels",
+ :action => 'bot_channel_list',
+ :auth_path => 'move'
basics.map "hide",
:action => 'bot_hide',
:auth_path => 'move'