From 8473982fbfa276ced1394bf704e6de379a0f3e65 Mon Sep 17 00:00:00 2001 From: "Robin H. Johnson" Date: Sat, 13 Mar 2010 09:31:28 +0000 Subject: 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 --- lib/rbot/core/basics.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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' -- cgit v1.2.3