6 # Author:: Raine Virta <rane@kapsi.fi>
7 # Copyright:: (C) 2009 Raine Virta
10 # Description:: Greet people when they join a channel
12 class GreetPlugin < Plugin
13 Config.register Config::ArrayValue.new('greet.channels',
14 :desc => _("Greet people on these channels."),
17 Config.register Config::ArrayValue.new('greet.messages',
18 :desc => _("By default, greetings are fetched from lang files. You can use this to specify custom messages, use %s to represent a nick."),
21 Config.register Config::BooleanValue.new('greet.delay',
22 :desc => _("Greet with delay so that the greeting seems human-like."),
27 return unless @bot.config['greet.channels'].include?(m.channel.to_s)
29 greeting = if @bot.config['greet.messages'].empty?
30 @bot.lang.get("hello_X")
32 @bot.config['greet.messages'].pick_one
35 msg = Proc.new { @bot.say m.channel, greeting % m.sourcenick }
37 if @bot.config['greet.delay']
38 @bot.timer.add_once(2+rand(3)) { msg.call }
45 plugin = GreetPlugin.new