# :title: rbot basic management from IRC
#
# Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
-# Copyright:: (C) 2006,2007 Giuseppe Bilotta
-# License:: GPL v2
class BasicsModule < CoreBotModule
+ Config.register Config::BooleanValue.new('irc.join_after_identify',
+ :default => false, :wizard => true, :requires_restart => true,
+ :desc => "Should the bot wait until its identification is confirmed before joining any channels?")
+
+ def join_channels
+ @bot.config['irc.join_channels'].each { |c|
+ debug "autojoining channel #{c}"
+ if(c =~ /^(\S+)\s+(\S+)$/i)
+ @bot.join $1, $2
+ else
+ @bot.join c if(c)
+ end
+ }
+ end
+
+ def identified
+ join_channels
+ end
+
+ # on connect, we join the default channels unless we have to wait for
+ # identification. Observe that this means the bot may not connect any channels
+ # until the 'identified' method gets delegated
+ def connect
+ join_channels unless @bot.config['irc.join_after_identify']
+ end
+
def ctcp_listen(m)
who = m.private? ? "me" : m.target
case m.ctcp.intern
when :PING
m.ctcp_reply m.message
- @bot.irclog "@ #{m.source} pinged #{who}"
when :TIME
m.ctcp_reply Time.now.to_s
- @bot.irclog "@ #{m.source} asked #{who} what time it is"
end
end
_("part <channel> => part channel <channel>")
when "hide"
_("hide => part all channels")
- when "nick"
- _("nick <nick> => attempt to change nick to <nick>")
when "say"
_("say <channel>|<nick> <message> => say <message> to <channel> or in private message to <nick>")
when "action"
# when "hello"
# return "hello|hi|hey|yo [#{@bot.myself}] => greet the bot"
else
- _("%{name}: quit, restart, join, part, hide, save, nick, say, action, topic, quiet, talk, ping, mode") % {:name=>name}
+ _("%{name}: quit, restart, join, part, hide, save, say, action, topic, quiet, talk, ping, mode") % {:name=>name}
#, botsnack, hello
end
end
:action => 'bot_mode',
:auth_path => 'talk::do'
-basics.map "join :chan :pass",
+basics.map "join :chan :pass",
:action => 'bot_join',
:defaults => {:pass => nil},
:auth_path => 'move'