5 class Core < CoreBotModule
\r
8 # handle incoming IRC PRIVMSG +m+
\r
10 return unless m.class <= PrivMessage
\r
11 if(m.private? && m.message =~ /^\001PING\s+(.+)\001/)
\r
12 @bot.notice m.sourcenick, "\001PING #$1\001"
\r
13 @bot.irclog "@ #{m.sourcenick} pinged me"
\r
19 when (/^join\s+(\S+)\s+(\S+)$/i)
\r
20 @bot.join $1, $2 if(@bot.auth.allow?("join", m.source, m.replyto))
\r
21 when (/^join\s+(\S+)$/i)
\r
22 @bot.join $1 if(@bot.auth.allow?("join", m.source, m.replyto))
\r
24 @bot.part m.target if(m.public? && @bot.auth.allow?("join", m.source, m.replyto))
\r
25 when (/^part\s+(\S+)$/i)
\r
26 @bot.part $1 if(@bot.auth.allow?("join", m.source, m.replyto))
\r
27 when (/^quit(?:\s+(.*))?$/i)
\r
28 @bot.quit $1 if(@bot.auth.allow?("quit", m.source, m.replyto))
\r
29 when (/^restart(?:\s+(.*))?$/i)
\r
30 @bot.restart $1 if(@bot.auth.allow?("quit", m.source, m.replyto))
\r
32 @bot.join 0 if(@bot.auth.allow?("join", m.source, m.replyto))
\r
34 if(@bot.auth.allow?("config", m.source, m.replyto))
\r
38 when (/^nick\s+(\S+)$/i)
\r
39 @bot.nickchg($1) if(@bot.auth.allow?("nick", m.source, m.replyto))
\r
40 when (/^say\s+(\S+)\s+(.*)$/i)
\r
41 @bot.say $1, $2 if(@bot.auth.allow?("say", m.source, m.replyto))
\r
42 when (/^action\s+(\S+)\s+(.*)$/i)
\r
43 @bot.action $1, $2 if(@bot.auth.allow?("say", m.source, m.replyto))
\r
44 # when (/^topic\s+(\S+)\s+(.*)$/i)
\r
45 # topic $1, $2 if(@bot.auth.allow?("topic", m.source, m.replyto))
\r
46 when (/^mode\s+(\S+)\s+(\S+)\s+(.*)$/i)
\r
47 @bot.mode $1, $2, $3 if(@bot.auth.allow?("mode", m.source, m.replyto))
\r
49 @bot.say m.replyto, "pong"
\r
51 if(@bot.auth.allow?("config", m.source, m.replyto))
\r
52 m.reply "saving ..."
\r
54 m.reply "rescanning ..."
\r
56 m.reply "done. #{@plugins.status(true)}"
\r
59 if(@bot.auth.allow?("talk", m.source, m.replyto))
\r
63 when (/^quiet in (\S+)$/i)
\r
65 if(@bot.auth.allow?("talk", m.source, m.replyto))
\r
67 where.gsub!(/^here$/, m.target) if m.public?
\r
68 @bot.set_quiet(where)
\r
71 if(@bot.auth.allow?("talk", m.source, m.replyto))
\r
75 when (/^talk in (\S+)$/i)
\r
77 if(@bot.auth.allow?("talk", m.source, m.replyto))
\r
78 where.gsub!(/^here$/, m.target) if m.public?
\r
79 @bot.reset_quiet(where)
\r
82 when (/^status\??$/i)
\r
83 m.reply status if @bot.auth.allow?("status", m.source, m.replyto)
\r
84 when (/^registry stats$/i)
\r
85 if @bot.auth.allow?("config", m.source, m.replyto)
\r
86 m.reply @registry.stat.inspect
\r
88 when (/^(help\s+)?config(\s+|$)/)
\r
90 when (/^(version)|(introduce yourself)$/i)
\r
91 @bot.say m.replyto, "I'm a v. #{$version} rubybot, (c) Tom Gilbert - http://linuxbrit.co.uk/rbot/"
\r
92 when (/^help(?:\s+(.*))?$/i)
\r
93 @bot.say m.replyto, help($1)
\r
94 #TODO move these to a "chatback" plugin
\r
95 when (/^(botsnack|ciggie)$/i)
\r
96 @bot.say m.replyto, @lang.get("thanks_X") % m.sourcenick if(m.public?)
\r
97 @bot.say m.replyto, @lang.get("thanks") if(m.private?)
\r
98 when (/^(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi(\W|$)|yo(\W|$)).*/i)
\r
99 @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick if(m.public?)
\r
100 @bot.say m.replyto, @lang.get("hello") if(m.private?)
\r
103 # stuff to handle when not addressed
\r
105 when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{Regexp.escape(@bot.nick)}$/i)
\r
106 @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick
\r
107 when (/^#{Regexp.escape(@bot.nick)}!*$/)
\r
108 @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick
\r
110 # @keywords.privmsg(m)
\r
115 # handle help requests for "core" topics
\r
119 return "quit [<message>] => quit IRC with message <message>"
\r
121 return "restart => completely stop and restart the bot (including reconnect)"
\r
123 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
125 return "part <channel> => part channel <channel>"
\r
127 return "hide => part all channels"
\r
129 return "save => save current dynamic data and configuration"
\r
131 return "rescan => reload modules and static facts"
\r
133 return "nick <nick> => attempt to change nick to <nick>"
\r
135 return "say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>"
\r
137 return "action <channel>|<nick> <message> => does a /me <message> to <channel> or in private message to <nick>"
\r
139 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
141 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
143 return "version => describes software version"
\r
145 return "botsnack => reward #{myself} for being good"
\r
147 return "hello|hi|hey|yo [#{myself}] => greet the bot"
\r
149 return "Core help topics: quit, restart, config, join, part, hide, save, rescan, nick, say, action, topic, quiet, talk, version, botsnack, hello"
\r