blob: 9d2292a04a84320df6e0efa6540b068fce75abda (
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#-- vim:sw=2:et
#++
#
# :title: Greet Plugin
#
# Author:: Raine Virta <rane@kapsi.fi>
# Copyright:: (C) 2009 Raine Virta
# License:: GPL v2
#
# Description:: Greet people when they join a channel
class GreetPlugin < Plugin
Config.register Config::ArrayValue.new('greet.channels',
:desc => _("Greet people on these channels."),
:default => [])
Config.register Config::ArrayValue.new('greet.messages',
:desc => _("By default, greetings are fetched from lang files. You can use this to specify custom messages, use %s to represent a nick."),
:default => [])
Config.register Config::BooleanValue.new('greet.delay',
:desc => _("Greet with delay so that the greeting seems human-like."),
:default => false)
def join(m)
return unless @bot.config['greet.channels'].include?(m.channel.to_s)
greeting = if @bot.config['greet.messages'].empty?
@bot.lang.get("hello_X")
else
@bot.config['greet.messages'].pick_one
end
msg = Proc.new { @bot.say m.channel, greeting % m.sourcenick }
if @bot.config['greet.delay']
@bot.timer.add_once(2+rand(3)) { msg.call }
else
msg.call
end
end
end
plugin = GreetPlugin.new
|