summaryrefslogtreecommitdiff
path: root/data/rbot/plugins/greet.rb
diff options
context:
space:
mode:
authorRaine Virta <rane@kapsi.fi>2009-04-05 23:55:21 +0300
committerRaine Virta <rane@kapsi.fi>2009-04-29 23:26:52 +0300
commitf16c5d38c3ca206557434ecae6665c128831ebc8 (patch)
tree69bdacb704f17c244b51138f9845629f341ebaf5 /data/rbot/plugins/greet.rb
parentbeefd7fc3973320ee6ecc6ac0b6201343ed2549d (diff)
greet plugin
Diffstat (limited to 'data/rbot/plugins/greet.rb')
-rw-r--r--data/rbot/plugins/greet.rb45
1 files changed, 45 insertions, 0 deletions
diff --git a/data/rbot/plugins/greet.rb b/data/rbot/plugins/greet.rb
new file mode 100644
index 00000000..9d2292a0
--- /dev/null
+++ b/data/rbot/plugins/greet.rb
@@ -0,0 +1,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 \ No newline at end of file