summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/autorejoin.rb
blob: fde8827ccb1299ff72c3dc14acad19cc629dc6ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class AutoRejoinPlugin < Plugin
  BotConfig.register BotConfigBooleanValue.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?
      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