]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blob - data/rbot/plugins/autorejoin.rb
autorejoin: standard header
[user/henk/code/ruby/rbot.git] / data / rbot / plugins / autorejoin.rb
1 #-- vim:sw=2:et
2 #++
3 #
4 # :title: Autorejoin
5
6 class AutoRejoinPlugin < Plugin
7   Config.register Config::BooleanValue.new('rejoin.insult',
8     :default => true,
9     :desc => "Determines if the bot will insult whoever kicked it, after rejoin")
10
11   def help(plugin, topic="")
12     "performs an automatic rejoin if the bot is kicked from a channel"
13   end
14
15   def kick(m)
16     password = m.channel.mode[:k].value
17
18     if m.address?
19       r = rand(10)
20       if r > 0
21         @bot.timer.add_once(r) {
22           @bot.join m.channel, password
23           @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult']
24         }
25       else
26         @bot.join m.channel, password
27         @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult']
28       end
29     end
30   end
31 end
32
33 plugin = AutoRejoinPlugin.new