X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=data%2Frbot%2Fplugins%2Fautorejoin.rb;h=14a2f29c77b0723ab19c96404815384ba7b3c4ba;hb=41ea4232df0ed0b3f922b0476444ca8e38f3301f;hp=aba46507b20e6c68b3ef3e6eb1411f6d8c506fed;hpb=21949774b91eaec6ecde4eaa8ad121e2c0a36b87;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git diff --git a/data/rbot/plugins/autorejoin.rb b/data/rbot/plugins/autorejoin.rb index aba46507..14a2f29c 100644 --- a/data/rbot/plugins/autorejoin.rb +++ b/data/rbot/plugins/autorejoin.rb @@ -1,16 +1,26 @@ class AutoRejoinPlugin < Plugin + Config.register Config::BooleanValue.new('rejoin.insult', + :default => true, + :desc => "Determines if the bot will insult whoever kicked it, after rejoin") + def help(plugin, topic="") "performs an automatic rejoin if the bot is kicked from a channel" end + def kick(m) if m.address? - @bot.timer.add_once(10, m) {|m| - @bot.join m.channel - @bot.say m.channel, @bot.lang.get("insult") % m.sourcenick - } + r = rand(10) + if r > 0 + @bot.timer.add_once(r) { + @bot.join m.channel + @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult'] + } + else + @bot.join m.channel + @bot.say(m.channel, @bot.lang.get("insult") % m.sourcenick) if @bot.config['rejoin.insult'] + end end end end plugin = AutoRejoinPlugin.new -plugin.register("autorejoin")