blob: 36f9314cb16a751fea9c3f20f3b28c5a5a807c59 (
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
46
|
#-- 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 if m.source == @bot.myself
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
|