diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-07 22:26:08 +0100 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2009-01-07 22:26:08 +0100 |
commit | ed9d2da6f7421c68305102cb0a8e49fa25f65903 (patch) | |
tree | d32a73cf06fd538f041691eed38e6c05c298757d /data/rbot/plugins | |
parent | a997331268e0d8f31c68673bcf26144620f0d719 (diff) |
autorejoin: option to kick the kicker
Diffstat (limited to 'data/rbot/plugins')
-rw-r--r-- | data/rbot/plugins/autorejoin.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/data/rbot/plugins/autorejoin.rb b/data/rbot/plugins/autorejoin.rb index 0ea46205..4966938a 100644 --- a/data/rbot/plugins/autorejoin.rb +++ b/data/rbot/plugins/autorejoin.rb @@ -7,6 +7,14 @@ class AutoRejoinPlugin < Plugin Config.register Config::BooleanValue.new('rejoin.insult', :default => true, :desc => "Determines if the bot will insult whoever kicked it, after rejoin") + Config.register Config::BooleanValue.new('rejoin.kick', + :default => false, + :desc => "Determines if the bot will kick whoever kicked it, after rejoin") + + def initialize + super + @should_kick = Hash.new + end def help(plugin, topic="") "performs an automatic rejoin if the bot is kicked from a channel" @@ -16,6 +24,9 @@ class AutoRejoinPlugin < Plugin password = m.channel.mode[:k].value if m.address? + if @bot.config['rejoin.kick'] + @should_kick[m.channel.downcase] = m.sourcenick + end r = rand(10) if r > 0 @bot.timer.add_once(r) { @@ -28,6 +39,23 @@ class AutoRejoinPlugin < Plugin end end end + + def modechange(m) + # if we got opped on a channel we want to kick somebody from, + # do the kicking + + # getting opped on a channel is a channel mode change, so bail out if this + # is not a channel mode change + return unless m.target.kind_of? Channel + # bail out if we are not op, too + return unless @bot.myself.is_op?(m.target) + # bail out if there's nobody to kick + to_kick = @should_kick.delete(m.target.downcase) + return unless to_kick + # kick the evil user that kicked us + @bot.kick m.target, to_kick, _("for kicking me out earlier") + end + end plugin = AutoRejoinPlugin.new |