6 class AutoRejoinPlugin < Plugin
7 Config.register Config::BooleanValue.new('rejoin.insult',
9 :desc => "Determines if the bot will insult whoever kicked it, after rejoin")
10 Config.register Config::BooleanValue.new('rejoin.kick',
12 :desc => "Determines if the bot will kick whoever kicked it, after rejoin")
13 Config.register Config::ArrayValue.new('rejoin.no_kick_list',
14 :default => ["owner"],
15 :desc => "List of botusers that can kick the bot without being kicked")
20 @should_kick = Hash.new
23 def help(plugin, topic="")
24 "performs an automatic rejoin if the bot is kicked from a channel"
28 password = m.channel.mode[:k].value
31 if @bot.config['rejoin.kick'] and not @bot.config['rejoin.no_kick_list'].include? m.source.botuser.username
32 @should_kick[m.channel.downcase] = m.sourcenick
36 @bot.timer.add_once(r) {
37 @bot.join m.channel, password
38 @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult']
41 @bot.join m.channel, password
42 @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult']
48 # if we got opped on a channel we want to kick somebody from,
51 # getting opped on a channel is a channel mode change, so bail out if this
52 # is not a channel mode change
53 return unless m.target.kind_of? Channel
54 # bail out if we are not op, too
55 return unless @bot.myself.is_op?(m.target)
56 # bail out if there's nobody to kick
57 to_kick = @should_kick.delete(m.target.downcase)
59 # kick the evil user that kicked us
60 @bot.kick m.target, to_kick, _("for kicking me out earlier")
65 plugin = AutoRejoinPlugin.new