5 class BasicsModule < CoreBotModule
\r
8 return unless m.kind_of?(PrivMessage)
\r
9 if(m.private? && m.message =~ /^\001PING\s+(.+)\001/)
\r
10 @bot.notice m.sourcenick, "\001PING #$1\001"
\r
11 @bot.irclog "@ #{m.sourcenick} pinged me"
\r
16 def bot_join(m, param)
\r
18 @bot.join param[:chan], param[:pass]
\r
20 @bot.join param[:chan]
\r
24 def bot_part(m, param)
\r
26 @bot.part param[:chan]
\r
28 @bot.part m.target if m.public?
\r
32 def bot_quit(m, param)
\r
33 @bot.quit(param[:msg] ? param[:msg].join(" ") : nil)
\r
36 def bot_restart(m, param)
\r
37 @bot.restart(param[:msg] ? param[:msg].join(" ") : nil)
\r
40 def bot_hide(m, param)
\r
44 def bot_say(m, param)
\r
45 @bot.say param[:where], param[:what].join(" ")
\r
48 def bot_action(m, param)
\r
49 @bot.action param[:where], param[:what].join(" ")
\r
52 def bot_mode(m, param)
\r
53 @bot.mode param[:where], param[:what], param[:who].join(" ")
\r
56 def bot_ping(m, param)
\r
60 def bot_quiet(m, param)
\r
61 if param.has_key?(:where)
\r
62 @bot.set_quiet param[:where].sub(/^here$/, m.target)
\r
68 def bot_talk(m, param)
\r
69 if param.has_key?(:where)
\r
70 @bot.reset_quiet param[:where].sub(/^here$/, m.target)
\r
76 def bot_help(m, param)
\r
77 m.reply @bot.help(param[:topic].join(" "))
\r
80 #TODO move these to a "chatback" plugin
\r
81 # when (/^(botsnack|ciggie)$/i)
\r
82 # @bot.say m.replyto, @lang.get("thanks_X") % m.sourcenick if(m.public?)
\r
83 # @bot.say m.replyto, @lang.get("thanks") if(m.private?)
\r
84 # when (/^(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi(\W|$)|yo(\W|$)).*/i)
\r
85 # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick if(m.public?)
\r
86 # @bot.say m.replyto, @lang.get("hello") if(m.private?)
\r
87 # when (/^\s*(hello|howdy|hola|salut|bonjour|sup|niihau|hey|hi|yo(\W|$))[\s,-.]+#{Regexp.escape(@bot.nick)}$/i)
\r
88 # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick
\r
89 # when (/^#{Regexp.escape(@bot.nick)}!*$/)
\r
90 # @bot.say m.replyto, @lang.get("hello_X") % m.sourcenick
\r
92 # handle help requests for "core" topics
\r
93 def help(plugin, topic="")
\r
96 return "quit [<message>] => quit IRC with message <message>"
\r
98 return "restart => completely stop and restart the bot (including reconnect)"
\r
100 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
102 return "part <channel> => part channel <channel>"
\r
104 return "hide => part all channels"
\r
106 return "save => save current dynamic data and configuration"
\r
108 return "rescan => reload modules and static facts"
\r
110 return "nick <nick> => attempt to change nick to <nick>"
\r
112 return "say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>"
\r
114 return "action <channel>|<nick> <message> => does a /me <message> to <channel> or in private message to <nick>"
\r
116 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
118 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
120 return "version => describes software version"
\r
122 # return "botsnack => reward #{myself} for being good"
\r
124 # return "hello|hi|hey|yo [#{myself}] => greet the bot"
\r
126 return "#{name}: quit, restart, join, part, hide, save, rescan, nick, say, action, topic, quiet, talk, version"#, botsnack, hello"
\r
131 basics = BasicsModule.new
\r
133 basics.map "quit *msg",
\r
134 :action => 'bot_quit',
\r
135 :defaults => { :msg => nil },
\r
136 :auth_path => 'quit'
\r
137 basics.map "restart *msg",
\r
138 :action => 'bot_restart',
\r
139 :defaults => { :msg => nil },
\r
140 :auth_path => 'quit'
\r
142 basics.map "quiet",
\r
143 :action => 'bot_quiet',
\r
144 :auth_path => 'talk::set'
\r
145 basics.map "quiet in :chan",
\r
146 :action => 'bot_quiet',
\r
147 :auth_path => 'talk::set'
\r
149 :action => 'bot_talk',
\r
150 :auth_path => 'talk::set'
\r
151 basics.map "quiet in :chan",
\r
152 :action => 'bot_quiet',
\r
153 :auth_path => 'talk::set'
\r
155 basics.map "say :where *what",
\r
156 :action => 'bot_say',
\r
157 :auth_path => 'talk::do'
\r
158 basics.map "action :where *what",
\r
159 :action => 'bot_action',
\r
160 :auth_path => 'talk::do'
\r
161 basics.map "mode :where :what *who",
\r
162 :action => 'bot_mode',
\r
163 :auth_path => 'talk::do'
\r
165 basics.map "join :chan :pass",
\r
166 :action => 'bot_join',
\r
167 :defaults => {:pass => nil},
\r
168 :auth_path => 'move'
\r
169 basics.map "part :chan",
\r
170 :action => 'bot_part',
\r
171 :defaults => {:chan => nil},
\r
172 :auth_path => 'move'
\r
174 :action => 'bot_hide',
\r
175 :auth_path => 'move'
\r
178 :action => 'bot_ping',
\r
179 :auth_path => '!ping!'
\r
180 basics.map "help *topic",
\r
181 :action => 'bot_help',
\r
182 :default => { :topic => [""] },
\r
183 :auth_path => '!help!'
\r
185 basics.default_auth('*', false)
\r