alx / delicious-bot

Jabber bot to add bookmarks on delicious

This URL has Read+Write access

alx (author)
Sat May 03 04:58:24 -0700 2008
delicious-bot / delicious-bot.rb
100644 49 lines (39 sloc) 0.936 kb
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
47
48
49
#!/usr/bin/env ruby
require 'rubygems'
require 'jabber/bot'
require 'rdelicious'
require 'YAML'
 
###
### initialize configuration
###
 
@bot_settings = YAML::load_file("config.yml")
 
###
### Bot
###
 
bot = Jabber::Bot.new(
  :jabber_id => @bot_settings["jabber_id"],
  :password => @bot_settings["jabber_password"],
  :master => @bot_settings["jabber_master"],
  :is_public => true
)
 
###
### Delicious configuration
###
 
delicious = Rdelicious.new(@bot_settings["delicious_login"], @bot_settings["delicious_password"])
 
bot.add_command(
  :syntax => 'bookmark <url> [description]',
  :description => 'Bookmark link to delicious',
  :regex => /^bookmark\s+.+$/,
  :alias => [
      :syntax => 'b <url> [description]',
      :regex => /^b\s+.+$/
  ]
) do |sender, message|
  url = message.slice!(/^.[^\s]*/)
  delicious.add(url, message.strip) if delicious.is_connected?
  nil
end
 
###
### Life!
###
 
bot.connect