summaryrefslogtreecommitdiff
path: root/lib/rbot
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-06 21:36:41 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2008-08-06 22:06:10 +0200
commit2bd4a7ed4ba5ab7c3c522c4d8061c1ce35bdc336 (patch)
tree62e58524a6ff7e6a215b8fa84bc278bde12bca5c /lib/rbot
parent9a66dcadede5cadc00b4fde344f75a9bd78220d7 (diff)
basics: option to join channel after identification is confirmed
Sometimes it is necessary to wait for identification to be confirmed before certain channels may be joined. In this case the option irc.join_after_identify can be set to true, and the bot will wait for nickserv to confirm the identification before joining any channels. This solution is actually a rather ugly hack, but I can't think of a better way to approach the problem without rewriting the whole framework.
Diffstat (limited to 'lib/rbot')
-rw-r--r--lib/rbot/core/basics.rb26
-rw-r--r--lib/rbot/ircbot.rb9
2 files changed, 26 insertions, 9 deletions
diff --git a/lib/rbot/core/basics.rb b/lib/rbot/core/basics.rb
index fd7a085f..3fc794bc 100644
--- a/lib/rbot/core/basics.rb
+++ b/lib/rbot/core/basics.rb
@@ -7,6 +7,32 @@
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
diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb
index 01dbb12b..0d934e33 100644
--- a/lib/rbot/ircbot.rb
+++ b/lib/rbot/ircbot.rb
@@ -609,15 +609,6 @@ class Bot
@plugins.delegate("welcome", m)
@plugins.delegate("connect")
-
- @config['irc.join_channels'].each { |c|
- debug "autojoining channel #{c}"
- if(c =~ /^(\S+)\s+(\S+)$/i)
- join $1, $2
- else
- join c if(c)
- end
- }
}
# TODO the next two @client should go into rfc2812.rb, probably