public
Description: An extensible bot for the Campfire web-based chat system #crc
Homepage:
Clone URL: git://github.com/timriley/campfire-bot.git
got the markov plugin to a working state. it now responds to the channel with 
generated lines
timriley (author)
Fri Oct 31 00:16:26 -0700 2008
commit  9077b5a2d50e21ce2fe2f55a7e0eeff2ae52af04
tree    2999930bac64434c7087c2ce6238ce99eae7bbd0
parent  2c95f46594528e233b4e1f4000e2ff7efb680bf8
...
 
 
 
 
 
1
2
3
...
23
24
25
26
 
27
28
29
...
33
34
35
36
 
 
 
 
 
37
38
39
 
 
40
41
42
43
 
44
45
46
...
62
63
64
65
 
66
67
68
69
 
70
71
 
72
73
74
...
81
82
83
84
85
 
 
86
87
88
...
1
2
3
4
5
6
7
8
...
28
29
30
 
31
32
33
34
...
38
39
40
 
41
42
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
57
...
73
74
75
 
76
77
78
79
 
80
81
 
82
83
84
85
...
92
93
94
 
 
95
96
97
98
99
0
@@ -1,3 +1,8 @@
0
+# TODO
0
+#
0
+# - convert/filter out HTML entities like "
0
+# - do the right thing when a paste occurs (remove the 'view paste' but keep the content)
0
+
0
 class Boop < CampfireBot::Plugin
0
   
0
   # Markov chain implementation courtesy of http://blog.segment7.net/articles/2006/02/25/markov-chain
0
@@ -23,7 +28,7 @@ class Boop < CampfireBot::Plugin
0
   
0
   def random_chatter(msg)
0
     puts "random_chatter"
0
-    speak(get_sentences)
0
+    speak(generate_line)
0
   end
0
   
0
   def focused_chatter(msg)
0
@@ -33,14 +38,20 @@ class Boop < CampfireBot::Plugin
0
   def load_transcripts(msg)
0
     speak("Filling my brain with transcripts...")
0
     
0
-    bot.room.available_transcripts.each do |date|
0
+    puts "available transcripts - #{bot.room.available_transcripts.to_yaml}"
0
+    
0
+    bot.room.available_transcripts.to_a.each do |date|
0
+      puts "loading transcript #{date}"
0
+      
0
       transcript = bot.room.transcript(date)
0
       
0
       transcript.each do |message|
0
+        puts "message: #{message[:message]}"
0
+        
0
         filtered_text = strip_message(message)
0
         add_line(filtered_text.gsub(/([^\.])$/, '\1.')) unless filtered_text.blank?
0
         
0
-        puts filtered_text.gsub(/([^\.])$/, '\1.') unless filtered_text.blank?
0
+        puts "ACCEPTED: " + filtered_text.gsub(/([^\.])$/, '\1.') unless filtered_text.blank?
0
       end
0
     end
0
     
0
@@ -62,13 +73,13 @@ class Boop < CampfireBot::Plugin
0
   def generate_line
0
     # our seed phrase
0
     # phrase = words[0, phrase_length]
0
-    phrase = random_word
0
+    phrase = [random_word]
0
 
0
     output = []
0
 
0
-    @max_words.times do
0
+    @word_count.times do
0
       # grab all possibilities for our state
0
-      options = phrases[phrase]
0
+      options = @phrases[phrase]
0
 
0
       # add the first word to our output and discard
0
       output << phrase.shift
0
@@ -81,8 +92,8 @@ class Boop < CampfireBot::Plugin
0
       break if phrase.compact.empty? # all out of words
0
     end
0
 
0
-    # print out our output
0
-    puts output.join(' ')
0
+    # return our output
0
+    output.join(' ')
0
   end
0
     
0
   def random_word

Comments