public
Description: An extensible bot for the Campfire web-based chat system #crc
Homepage:
Clone URL: git://github.com/timriley/campfire-bot.git
initial work on markov plugin
timriley (author)
Thu Oct 30 05:39:19 -0700 2008
commit  0f6e12195b145b9eb2d44d1148f698454b61e704
tree    2e12ea0359bcdad3e8190f47d80db75e76b396bb
parent  c08814cbaeb7a60c9003c1955765f700258c435e
0
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+- plugins need callbacks, like on_join, etc.
0
+
0
 - multi-room support
0
 
0
 - gem-ify the bot and have it provide an executable to generate an application directory 
...
31
32
33
 
34
35
36
...
31
32
33
34
35
36
37
0
@@ -31,6 +31,7 @@ module CampfireBot
0
       @campfire.login(@config['username'], @config['password'])
0
       @room = @campfire.find_room_by_name(@config['room'])
0
       @room.join
0
+      puts "Ready."
0
     end
0
   
0
     def run(interval = 5)
...
1
2
 
3
4
5
...
36
37
38
39
 
40
41
 
42
43
44
45
46
47
48
 
49
50
51
...
1
2
3
4
5
6
...
37
38
39
 
40
41
 
42
43
44
45
46
47
48
 
49
50
51
52
0
@@ -1,5 +1,6 @@
0
 module CampfireBot
0
   module Event
0
+    
0
     # This is an abstract base class for all event types, not to be used directly.
0
     class EventHandler
0
       
0
@@ -36,16 +37,16 @@ module CampfireBot
0
       def match?(msg)
0
         (
0
           msg[:message][0..0] == '!' || 
0
-          msg[:message]       =~ Regexp.new("^#{Bot.instance.config['nickname']},", Regexp::IGNORECASE)
0
+          msg[:message]       =~ Regexp.new("^#{bot.config['nickname']},", Regexp::IGNORECASE)
0
         ) &&
0
-        msg[:message].gsub(/^!/, '').gsub(Regexp.new("#{Bot.instance.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
   
0
       protected
0
   
0
       def filter_message(msg)
0
-        msg[:message] = msg[:message].gsub(Regexp.new("^(!|#{Bot.instance.config['nickname']},)\\s*#{@matcher}\\s*", Regexp::IGNORECASE), '')
0
+        msg[:message] = msg[:message].gsub(Regexp.new("^(!|#{bot.config['nickname']},)\\s*#{@matcher}\\s*", Regexp::IGNORECASE), '')
0
         msg
0
       end
0
     end

Comments