#-- vim:sw=2:et\r
#++\r
-\r
+#\r
+# :title: rbot basic management from IRC\r
+#\r
+# Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>\r
+# Copyright:: (C) 2006,2007 Giuseppe Bilotta\r
+# License:: GPL v2\r
\r
class BasicsModule < CoreBotModule\r
\r
def listen(m)\r
return unless m.kind_of?(PrivMessage)\r
- if(m.private? && m.message =~ /^\001PING\s+(.+)\001/)\r
- @bot.notice m.sourcenick, "\001PING #$1\001"\r
- @bot.irclog "@ #{m.sourcenick} pinged me"\r
- return\r
+ if m.message =~ /^\001PING\s+(.+)\001/\r
+ ping_id = $1\r
+ if m.private?\r
+ @bot.notice m.source, "\001PING #{ping_id}\001"\r
+ @bot.irclog "@ #{m.source} pinged me"\r
+ else\r
+ @bot.notice m.source, "\001PING #{ping_id}\001"\r
+ @bot.irclog "@ #{m.source} pinged #{m.target}"\r
+ end\r
end\r
end\r
\r
\r
def bot_quiet(m, param)\r
if param.has_key?(:where)\r
- @bot.set_quiet param[:where].sub(/^here$/, m.target)\r
+ @bot.set_quiet param[:where].sub(/^here$/, m.target.downcase)\r
else\r
@bot.set_quiet\r
end\r
+ # Make sense when the commmand is given in private or in a non-quieted\r
+ # channel\r
+ m.okay\r
end\r
\r
def bot_talk(m, param)\r
if param.has_key?(:where)\r
- @bot.reset_quiet param[:where].sub(/^here$/, m.target)\r
+ @bot.reset_quiet param[:where].sub(/^here$/, m.target.downcase)\r
else\r
@bot.reset_quiet\r
end\r
+ # Make sense when the commmand is given in private or in a non-quieted\r
+ # channel\r
+ m.okay\r
end\r
\r
def bot_help(m, param)\r
# when (/^(botsnack|ciggie)$/i)\r
# @bot.say m.replyto, @lang.get("thanks_X") % m.sourcenick if(m.public?)\r
# @bot.say m.replyto, @lang.get("thanks") if(m.private?)\r
- # when (/^(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi(\W|$)|yo(\W|$)).*/i)\r
- # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick if(m.public?)\r
- # @bot.say m.replyto, @lang.get("hello") if(m.private?)\r
- # when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{Regexp.escape(@bot.nick)}$/i)\r
- # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick\r
# when (/^#{Regexp.escape(@bot.nick)}!*$/)\r
# @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick\r
\r
# handle help requests for "core" topics\r
- def help(plugin, topic="")\r
- case topic\r
+ def help(cmd, topic="")\r
+ case cmd\r
when "quit"\r
- return "quit [<message>] => quit IRC with message <message>"\r
+ _("quit [<message>] => quit IRC with message <message>")\r
when "restart"\r
- return "restart => completely stop and restart the bot (including reconnect)"\r
+ _("restart => completely stop and restart the bot (including reconnect)")\r
when "join"\r
- return "join <channel> [<key>] => join channel <channel> with secret key <key> if specified. #{myself} also responds to invites if you have the required access level"\r
+ _("join <channel> [<key>] => join channel <channel> with secret key <key> if specified. #{myself} also responds to invites if you have the required access level")\r
when "part"\r
- return "part <channel> => part channel <channel>"\r
+ _("part <channel> => part channel <channel>")\r
when "hide"\r
- return "hide => part all channels"\r
- when "save"\r
- return "save => save current dynamic data and configuration"\r
- when "rescan"\r
- return "rescan => reload modules and static facts"\r
+ _("hide => part all channels")\r
when "nick"\r
- return "nick <nick> => attempt to change nick to <nick>"\r
+ _("nick <nick> => attempt to change nick to <nick>")\r
when "say"\r
- return "say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>"\r
+ _("say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>")\r
when "action"\r
- return "action <channel>|<nick> <message> => does a /me <message> to <channel> or in private message to <nick>"\r
+ _("action <channel>|<nick> <message> => does a /me <message> to <channel> or in private message to <nick>")\r
when "quiet"\r
- return "quiet [in here|<channel>] => with no arguments, stop speaking in all channels, if \"in here\", stop speaking in this channel, or stop speaking in <channel>"\r
+ _("quiet [in here|<channel>] => with no arguments, stop speaking in all channels, if \"in here\", stop speaking in this channel, or stop speaking in <channel>")\r
when "talk"\r
- return "talk [in here|<channel>] => with no arguments, resume speaking in all channels, if \"in here\", resume speaking in this channel, or resume speaking in <channel>"\r
+ _("talk [in here|<channel>] => with no arguments, resume speaking in all channels, if \"in here\", resume speaking in this channel, or resume speaking in <channel>")\r
when "version"\r
- return "version => describes software version"\r
+ _("version => describes software version")\r
+ when "ping"\r
+ _("ping => replies with a pong")\r
+ when "mode"\r
+ _("mode <channel> <mode> <nicks> => set channel modes for <nicks> on <channel> to <mode>")\r
# when "botsnack"\r
# return "botsnack => reward #{myself} for being good"\r
# when "hello"\r
# return "hello|hi|hey|yo [#{myself}] => greet the bot"\r
else\r
- return "#{name}: quit, restart, join, part, hide, save, rescan, nick, say, action, topic, quiet, talk, version"#, botsnack, hello"\r
+ _("%{name}: quit, restart, join, part, hide, save, nick, say, action, topic, quiet, talk,version, ping, mode") % {:name=>name}\r
+ #, botsnack, hello\r
end\r
end\r
end\r
:defaults => { :msg => nil },\r
:auth_path => 'quit'\r
\r
-basics.map "quiet",\r
- :action => 'bot_quiet',\r
- :auth_path => 'talk::set'\r
-basics.map "quiet in :chan",\r
+basics.map "quiet [in] [:where]",\r
:action => 'bot_quiet',\r
:auth_path => 'talk::set'\r
-basics.map "talk",\r
+basics.map "talk [in] [:where]",\r
:action => 'bot_talk',\r
:auth_path => 'talk::set'\r
-basics.map "quiet in :chan",\r
- :action => 'bot_quiet',\r
- :auth_path => 'talk::set'\r
\r
basics.map "say :where *what",\r
:action => 'bot_say',\r