public
Description: An extensible bot for the Campfire web-based chat system #crc
Homepage:
Clone URL: git://github.com/timriley/campfire-bot.git
merge in some sterling work by joshwand
timriley (author)
Mon Nov 24 04:44:26 -0800 2008
commit  a838b0d1ab643fb2dc6cd9b24f609fe344563b07
tree    77c87259bffec56f0f562304d7230888481b3102
parent  de33e1ff91a4ae39ea91541dc250e4ff5e25dd62
0
...
2
3
4
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
...
2
3
4
 
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
0
@@ -2,4 +2,22 @@ This is an under-heavy-development bot for the Campfire web-based chat system.
0
 
0
 It aims to be multi-purpose and extensible.
0
 
0
- - Tim Riley <tim at openmonkey dot com>
0
\ No newline at end of file
0
+ - Tim Riley <tim at openmonkey dot com>
0
0
+Requirements:
0
+
0
+rubygems
0
+timriley-tinder
0
+hpricot
0
+mime-types
0
+activesupport 
0
+
0
+Configuration: 
0
+
0
+in config.yml
0
+
0
+Running:
0
+
0
+Run script/bot with the environment name as the argument
0
+
0
+script/bot.rb development
0
\ No newline at end of file
...
21
22
23
24
 
25
26
27
28
29
30
31
32
 
 
 
 
 
 
 
 
 
 
 
33
34
35
...
21
22
23
 
24
25
26
27
28
29
 
 
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
0
@@ -21,15 +21,23 @@ module CampfireBot
0
     attr_reader :campfire, :room, :config
0
   
0
     def initialize
0
-      @config   = YAML::load(File.read("#{BOT_ROOT}/config.yml"))[BOT_ENVIRONMENT]
0
+      @config = YAML::load(File.read("#{BOT_ROOT}/config.yml"))[BOT_ENVIRONMENT]
0
     end
0
   
0
     def connect
0
       load_plugins
0
     
0
-      @campfire = Tinder::Campfire.new(@config['site'], :ssl => !!@config['use_ssl'])
0
-      @campfire.login(@config['username'], @config['password'])
0
-      @room = @campfire.find_room_by_name(@config['room'])
0
+      if @config['guesturl']
0
+        baseurl, guest_token = @config['guesturl'].split(/.com\//)
0
+        @campfire = Tinder::Campfire.new(@config['site'], :guesturl => @config['guesturl'], :ssl => !!@config['ssl'])
0
+        roomid    = @campfire.guestlogin(@config['guesturl'], @config['nickname'])
0
+        @room     = Tinder::Room.new(@campfire, roomid, @config['room'])
0
+      else
0
+        @campfire = Tinder::Campfire.new(@config['site'], :ssl => !!@config['use_ssl'])
0
+        @campfire.login(@config['username'], @config['password'])
0
+        @room = @campfire.find_room_by_name(@config['room'])
0
+      end
0
+      
0
       @room.join
0
       puts "Ready."
0
     end
...
39
40
41
42
 
43
44
45
...
39
40
41
 
42
43
44
45
0
@@ -39,7 +39,7 @@ module CampfireBot
0
           msg[:message][0..0] == '!' || 
0
           msg[:message]       =~ Regexp.new("^#{bot.config['nickname']},", Regexp::IGNORECASE)
0
         ) &&
0
-        msg[:message].gsub(/^!/, '').gsub(Regexp.new("#{bot.config['nickname']},\\s*", Regexp::IGNORECASE), '').split(' ')[0].to_s.downcase == @matcher.downcase
0
+        msg[:message].gsub(/^!/, '').gsub(Regexp.new("#{bot.config['nickname']}(,|:)?\\s*", Regexp::IGNORECASE), '').split(' ')[0].to_s.downcase == @matcher.downcase
0
         # FIXME - the above should be just done with one regexp to pull out the first non-! non-<bot name> word.
0
       end
0
   

Comments