chatterbot 2.0.5 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +19 -0
- data/Gemfile +2 -2
- data/README.markdown +7 -21
- data/chatterbot.gemspec +3 -3
- data/docs/_site/advanced.html +43 -54
- data/docs/_site/configuration.html +23 -43
- data/docs/_site/contributing.html +18 -37
- data/docs/_site/deploying.html +44 -61
- data/docs/_site/examples.html +108 -123
- data/docs/_site/features.html +70 -71
- data/docs/_site/index.html +43 -64
- data/docs/_site/other-tools.html +22 -41
- data/docs/_site/rdoc.html +17 -36
- data/docs/_site/setup.html +62 -71
- data/docs/_site/tut.html +16 -36
- data/docs/_site/twitter-docs.html +17 -36
- data/docs/_site/walkthrough.html +35 -51
- data/docs/advanced.md +0 -5
- data/docs/deploying.md +0 -6
- data/docs/examples.md +0 -48
- data/docs/index.md +2 -3
- data/lib/chatterbot.rb +0 -1
- data/lib/chatterbot/bot.rb +5 -68
- data/lib/chatterbot/client.rb +2 -9
- data/lib/chatterbot/config.rb +0 -1
- data/lib/chatterbot/dsl.rb +0 -43
- data/lib/chatterbot/skeleton.rb +0 -2
- data/lib/chatterbot/version.rb +1 -1
- data/spec/bot_spec.rb +1 -76
- data/spec/client_spec.rb +0 -3
- data/spec/config_manager_spec.rb +6 -5
- data/spec/config_spec.rb +4 -1
- data/spec/dsl_spec.rb +1 -33
- data/templates/skeleton.txt +0 -47
- metadata +13 -21
- data/.document +0 -5
- data/.travis.yml +0 -9
- data/docs/_site/streaming.html +0 -506
- data/docs/streaming.md +0 -98
- data/examples/streaming_bot.rb +0 -49
- data/lib/chatterbot/streaming.rb +0 -72
- data/spec/streaming_spec.rb +0 -172
@@ -9,15 +9,15 @@
|
|
9
9
|
<meta name="description" content="twitter bots in ruby">
|
10
10
|
|
11
11
|
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
12
|
-
<link rel="stylesheet" href="/css/syntax.css">
|
13
|
-
<link rel="stylesheet" href="/css/main.css">
|
12
|
+
<link rel="stylesheet" href="/chatterbot/css/syntax.css">
|
13
|
+
<link rel="stylesheet" href="/chatterbot/css/main.css">
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
|
17
17
|
<div class="container">
|
18
18
|
<div class=row-fluid>
|
19
19
|
<div id=header class=span12>
|
20
|
-
<h4><a class=brand href="/">chatterbot</a>
|
20
|
+
<h4><a class=brand href="/chatterbot/">chatterbot</a>
|
21
21
|
<small>twitter bots in ruby</small>
|
22
22
|
</h4>
|
23
23
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
<div id=navigation class=span2>
|
32
32
|
<ul class="nav nav-list">
|
33
|
-
<li><a href="/">Home</a></li>
|
33
|
+
<li><a href="/chatterbot/">Home</a></li>
|
34
34
|
|
35
35
|
|
36
36
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<li data-order="">
|
58
58
|
|
59
|
-
<a href="/examples.html">Examples</a>
|
59
|
+
<a href="/chatterbot/examples.html">Examples</a>
|
60
60
|
|
61
61
|
</li>
|
62
62
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
<li data-order="">
|
84
84
|
|
85
|
-
<a href="/setup.html">Authorizing Your Bot</a>
|
85
|
+
<a href="/chatterbot/setup.html">Authorizing Your Bot</a>
|
86
86
|
|
87
87
|
</li>
|
88
88
|
|
@@ -97,14 +97,10 @@
|
|
97
97
|
|
98
98
|
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
100
|
|
105
101
|
<li data-order="">
|
106
102
|
|
107
|
-
<a href="/walkthrough.html">Walkthrough</a>
|
103
|
+
<a href="/chatterbot/walkthrough.html">Walkthrough</a>
|
108
104
|
|
109
105
|
</li>
|
110
106
|
|
@@ -119,7 +115,7 @@
|
|
119
115
|
|
120
116
|
<li data-order="">
|
121
117
|
|
122
|
-
<a href="/advanced.html">Advanced Features</a>
|
118
|
+
<a href="/chatterbot/advanced.html">Advanced Features</a>
|
123
119
|
|
124
120
|
</li>
|
125
121
|
|
@@ -129,7 +125,7 @@
|
|
129
125
|
|
130
126
|
<li data-order="">
|
131
127
|
|
132
|
-
<a href="/configuration.html">Configuration</a>
|
128
|
+
<a href="/chatterbot/configuration.html">Configuration</a>
|
133
129
|
|
134
130
|
</li>
|
135
131
|
|
@@ -143,7 +139,7 @@
|
|
143
139
|
|
144
140
|
<li data-order="">
|
145
141
|
|
146
|
-
<a href="/deploying.html">Running your Bot</a>
|
142
|
+
<a href="/chatterbot/deploying.html">Running your Bot</a>
|
147
143
|
|
148
144
|
</li>
|
149
145
|
|
@@ -157,7 +153,7 @@
|
|
157
153
|
|
158
154
|
<li data-order="">
|
159
155
|
|
160
|
-
<a href="/features.html">Basic Features</a>
|
156
|
+
<a href="/chatterbot/features.html">Basic Features</a>
|
161
157
|
|
162
158
|
</li>
|
163
159
|
|
@@ -180,16 +176,6 @@
|
|
180
176
|
|
181
177
|
|
182
178
|
|
183
|
-
|
184
|
-
<li data-order="">
|
185
|
-
|
186
|
-
<a href="/streaming.html">Streaming API</a>
|
187
|
-
|
188
|
-
</li>
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
179
|
|
194
180
|
|
195
181
|
|
@@ -218,7 +204,7 @@
|
|
218
204
|
|
219
205
|
<li data-order="">
|
220
206
|
|
221
|
-
<a href="/contributing.html">Contributing</a>
|
207
|
+
<a href="/chatterbot/contributing.html">Contributing</a>
|
222
208
|
|
223
209
|
</li>
|
224
210
|
|
@@ -259,10 +245,6 @@
|
|
259
245
|
|
260
246
|
|
261
247
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
248
|
|
267
249
|
|
268
250
|
|
@@ -305,7 +287,7 @@
|
|
305
287
|
|
306
288
|
<li data-order="">
|
307
289
|
|
308
|
-
<a href="/other-tools.html">Other Tools</a>
|
290
|
+
<a href="/chatterbot/other-tools.html">Other Tools</a>
|
309
291
|
|
310
292
|
</li>
|
311
293
|
|
@@ -330,10 +312,6 @@
|
|
330
312
|
|
331
313
|
|
332
314
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
315
|
|
338
316
|
<li data-order="">
|
339
317
|
|
@@ -364,17 +342,20 @@
|
|
364
342
|
<p>Bug fixes, features, etc are eagerly welcomed. Since this code is
|
365
343
|
being used to run current Twitter bots, any changes need to maintain
|
366
344
|
compatibility. If there are bugs or things you would like to improve,
|
367
|
-
fork the project and hack away. I
|
345
|
+
fork the project and hack away. I’ll pull anything back that makes
|
368
346
|
sense if requested.</p>
|
369
347
|
|
370
348
|
|
349
|
+
|
371
350
|
</div>
|
372
351
|
|
373
352
|
</div>
|
374
353
|
|
375
354
|
<div class=row-fluid>
|
376
355
|
<div id=footer class=span12>
|
377
|
-
|
356
|
+
<!--
|
357
|
+
Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
|
358
|
+
-->
|
378
359
|
|
379
360
|
</div>
|
380
361
|
</div>
|
data/docs/_site/deploying.html
CHANGED
@@ -9,15 +9,15 @@
|
|
9
9
|
<meta name="description" content="twitter bots in ruby">
|
10
10
|
|
11
11
|
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
12
|
-
<link rel="stylesheet" href="/css/syntax.css">
|
13
|
-
<link rel="stylesheet" href="/css/main.css">
|
12
|
+
<link rel="stylesheet" href="/chatterbot/css/syntax.css">
|
13
|
+
<link rel="stylesheet" href="/chatterbot/css/main.css">
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
|
17
17
|
<div class="container">
|
18
18
|
<div class=row-fluid>
|
19
19
|
<div id=header class=span12>
|
20
|
-
<h4><a class=brand href="/">chatterbot</a>
|
20
|
+
<h4><a class=brand href="/chatterbot/">chatterbot</a>
|
21
21
|
<small>twitter bots in ruby</small>
|
22
22
|
</h4>
|
23
23
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
<div id=navigation class=span2>
|
32
32
|
<ul class="nav nav-list">
|
33
|
-
<li><a href="/">Home</a></li>
|
33
|
+
<li><a href="/chatterbot/">Home</a></li>
|
34
34
|
|
35
35
|
|
36
36
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<li data-order="">
|
58
58
|
|
59
|
-
<a href="/examples.html">Examples</a>
|
59
|
+
<a href="/chatterbot/examples.html">Examples</a>
|
60
60
|
|
61
61
|
</li>
|
62
62
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
<li data-order="">
|
84
84
|
|
85
|
-
<a href="/setup.html">Authorizing Your Bot</a>
|
85
|
+
<a href="/chatterbot/setup.html">Authorizing Your Bot</a>
|
86
86
|
|
87
87
|
</li>
|
88
88
|
|
@@ -97,14 +97,10 @@
|
|
97
97
|
|
98
98
|
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
100
|
|
105
101
|
<li data-order="">
|
106
102
|
|
107
|
-
<a href="/walkthrough.html">Walkthrough</a>
|
103
|
+
<a href="/chatterbot/walkthrough.html">Walkthrough</a>
|
108
104
|
|
109
105
|
</li>
|
110
106
|
|
@@ -119,7 +115,7 @@
|
|
119
115
|
|
120
116
|
<li data-order="">
|
121
117
|
|
122
|
-
<a href="/advanced.html">Advanced Features</a>
|
118
|
+
<a href="/chatterbot/advanced.html">Advanced Features</a>
|
123
119
|
|
124
120
|
</li>
|
125
121
|
|
@@ -129,7 +125,7 @@
|
|
129
125
|
|
130
126
|
<li data-order="">
|
131
127
|
|
132
|
-
<a href="/configuration.html">Configuration</a>
|
128
|
+
<a href="/chatterbot/configuration.html">Configuration</a>
|
133
129
|
|
134
130
|
</li>
|
135
131
|
|
@@ -143,7 +139,7 @@
|
|
143
139
|
|
144
140
|
<li data-order="">
|
145
141
|
|
146
|
-
<a href="/deploying.html">Running your Bot</a>
|
142
|
+
<a href="/chatterbot/deploying.html">Running your Bot</a>
|
147
143
|
|
148
144
|
</li>
|
149
145
|
|
@@ -157,7 +153,7 @@
|
|
157
153
|
|
158
154
|
<li data-order="">
|
159
155
|
|
160
|
-
<a href="/features.html">Basic Features</a>
|
156
|
+
<a href="/chatterbot/features.html">Basic Features</a>
|
161
157
|
|
162
158
|
</li>
|
163
159
|
|
@@ -180,16 +176,6 @@
|
|
180
176
|
|
181
177
|
|
182
178
|
|
183
|
-
|
184
|
-
<li data-order="">
|
185
|
-
|
186
|
-
<a href="/streaming.html">Streaming API</a>
|
187
|
-
|
188
|
-
</li>
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
179
|
|
194
180
|
|
195
181
|
|
@@ -218,7 +204,7 @@
|
|
218
204
|
|
219
205
|
<li data-order="">
|
220
206
|
|
221
|
-
<a href="/contributing.html">Contributing</a>
|
207
|
+
<a href="/chatterbot/contributing.html">Contributing</a>
|
222
208
|
|
223
209
|
</li>
|
224
210
|
|
@@ -259,10 +245,6 @@
|
|
259
245
|
|
260
246
|
|
261
247
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
248
|
|
267
249
|
|
268
250
|
|
@@ -305,7 +287,7 @@
|
|
305
287
|
|
306
288
|
<li data-order="">
|
307
289
|
|
308
|
-
<a href="/other-tools.html">Other Tools</a>
|
290
|
+
<a href="/chatterbot/other-tools.html">Other Tools</a>
|
309
291
|
|
310
292
|
</li>
|
311
293
|
|
@@ -330,10 +312,6 @@
|
|
330
312
|
|
331
313
|
|
332
314
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
315
|
|
338
316
|
<li data-order="">
|
339
317
|
|
@@ -361,46 +339,49 @@
|
|
361
339
|
</h2>
|
362
340
|
</div>
|
363
341
|
|
364
|
-
<p>There
|
342
|
+
<p>There’s a couple ways of running your bot:</p>
|
365
343
|
|
366
344
|
<h2 id="manually">Manually</h2>
|
367
345
|
|
368
346
|
<p>Run it on the command-line whenever you like. Whee!</p>
|
369
347
|
|
370
348
|
<h2 id="cron">Cron</h2>
|
349
|
+
<p>Run it via cron. Here’s an example of running a bot every two minutes</p>
|
371
350
|
|
372
|
-
<
|
373
|
-
|
374
|
-
</code></pre></div>
|
375
|
-
<h2 id="looping">Looping</h2>
|
351
|
+
<pre><code>*/2 * * * * . ~/.bash_profile; cd /path/to/bot/; ./bot.rb
|
352
|
+
</code></pre>
|
376
353
|
|
354
|
+
<h2 id="looping">Looping</h2>
|
377
355
|
<p>Run it as a background process. Just put the guts of your bot in a loop like this:</p>
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
356
|
+
|
357
|
+
<p>```rb
|
358
|
+
loop do
|
359
|
+
search “twitter” do |tweet|
|
360
|
+
# here you could do something with a tweet
|
361
|
+
# if you want to retweet
|
362
|
+
retweet(tweet[:id])
|
363
|
+
end</p>
|
364
|
+
|
365
|
+
<p>replies do |tweet|
|
366
|
+
# do stuff
|
367
|
+
end</p>
|
368
|
+
|
369
|
+
<p># explicitly update our config
|
370
|
+
update_config</p>
|
371
|
+
|
372
|
+
<p>sleep 60
|
373
|
+
end
|
374
|
+
```</p>
|
375
|
+
|
395
376
|
<p><strong>NOTE:</strong> You need to call <code>update_config</code> to update the last tweet your script
|
396
|
-
has processed
|
377
|
+
has processed – if you don’t have this call, you will get duplicate
|
397
378
|
tweets.</p>
|
398
379
|
|
399
380
|
<h2 id="streaming">Streaming</h2>
|
400
381
|
|
401
382
|
<p>Chatterbot has rough support for the Streaming API. If your bot can
|
402
|
-
use it, it
|
403
|
-
You can read more about setting up a bot to use <a href="
|
383
|
+
use it, it’s a great option, because you get your data immediately.
|
384
|
+
You can read more about setting up a bot to use <a href="streaming.html">streaming</a>.</p>
|
404
385
|
|
405
386
|
|
406
387
|
</div>
|
@@ -409,7 +390,9 @@ You can read more about setting up a bot to use <a href="/streaming.html">stream
|
|
409
390
|
|
410
391
|
<div class=row-fluid>
|
411
392
|
<div id=footer class=span12>
|
412
|
-
|
393
|
+
<!--
|
394
|
+
Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
|
395
|
+
-->
|
413
396
|
|
414
397
|
</div>
|
415
398
|
</div>
|
data/docs/_site/examples.html
CHANGED
@@ -9,15 +9,15 @@
|
|
9
9
|
<meta name="description" content="twitter bots in ruby">
|
10
10
|
|
11
11
|
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
|
12
|
-
<link rel="stylesheet" href="/css/syntax.css">
|
13
|
-
<link rel="stylesheet" href="/css/main.css">
|
12
|
+
<link rel="stylesheet" href="/chatterbot/css/syntax.css">
|
13
|
+
<link rel="stylesheet" href="/chatterbot/css/main.css">
|
14
14
|
</head>
|
15
15
|
<body>
|
16
16
|
|
17
17
|
<div class="container">
|
18
18
|
<div class=row-fluid>
|
19
19
|
<div id=header class=span12>
|
20
|
-
<h4><a class=brand href="/">chatterbot</a>
|
20
|
+
<h4><a class=brand href="/chatterbot/">chatterbot</a>
|
21
21
|
<small>twitter bots in ruby</small>
|
22
22
|
</h4>
|
23
23
|
|
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
<div id=navigation class=span2>
|
32
32
|
<ul class="nav nav-list">
|
33
|
-
<li><a href="/">Home</a></li>
|
33
|
+
<li><a href="/chatterbot/">Home</a></li>
|
34
34
|
|
35
35
|
|
36
36
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
<li data-order="">
|
58
58
|
|
59
|
-
<a href="/examples.html">Examples</a>
|
59
|
+
<a href="/chatterbot/examples.html">Examples</a>
|
60
60
|
|
61
61
|
</li>
|
62
62
|
|
@@ -82,7 +82,7 @@
|
|
82
82
|
|
83
83
|
<li data-order="">
|
84
84
|
|
85
|
-
<a href="/setup.html">Authorizing Your Bot</a>
|
85
|
+
<a href="/chatterbot/setup.html">Authorizing Your Bot</a>
|
86
86
|
|
87
87
|
</li>
|
88
88
|
|
@@ -97,14 +97,10 @@
|
|
97
97
|
|
98
98
|
|
99
99
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
100
|
|
105
101
|
<li data-order="">
|
106
102
|
|
107
|
-
<a href="/walkthrough.html">Walkthrough</a>
|
103
|
+
<a href="/chatterbot/walkthrough.html">Walkthrough</a>
|
108
104
|
|
109
105
|
</li>
|
110
106
|
|
@@ -119,7 +115,7 @@
|
|
119
115
|
|
120
116
|
<li data-order="">
|
121
117
|
|
122
|
-
<a href="/advanced.html">Advanced Features</a>
|
118
|
+
<a href="/chatterbot/advanced.html">Advanced Features</a>
|
123
119
|
|
124
120
|
</li>
|
125
121
|
|
@@ -129,7 +125,7 @@
|
|
129
125
|
|
130
126
|
<li data-order="">
|
131
127
|
|
132
|
-
<a href="/configuration.html">Configuration</a>
|
128
|
+
<a href="/chatterbot/configuration.html">Configuration</a>
|
133
129
|
|
134
130
|
</li>
|
135
131
|
|
@@ -143,7 +139,7 @@
|
|
143
139
|
|
144
140
|
<li data-order="">
|
145
141
|
|
146
|
-
<a href="/deploying.html">Running your Bot</a>
|
142
|
+
<a href="/chatterbot/deploying.html">Running your Bot</a>
|
147
143
|
|
148
144
|
</li>
|
149
145
|
|
@@ -157,7 +153,7 @@
|
|
157
153
|
|
158
154
|
<li data-order="">
|
159
155
|
|
160
|
-
<a href="/features.html">Basic Features</a>
|
156
|
+
<a href="/chatterbot/features.html">Basic Features</a>
|
161
157
|
|
162
158
|
</li>
|
163
159
|
|
@@ -180,16 +176,6 @@
|
|
180
176
|
|
181
177
|
|
182
178
|
|
183
|
-
|
184
|
-
<li data-order="">
|
185
|
-
|
186
|
-
<a href="/streaming.html">Streaming API</a>
|
187
|
-
|
188
|
-
</li>
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
179
|
|
194
180
|
|
195
181
|
|
@@ -218,7 +204,7 @@
|
|
218
204
|
|
219
205
|
<li data-order="">
|
220
206
|
|
221
|
-
<a href="/contributing.html">Contributing</a>
|
207
|
+
<a href="/chatterbot/contributing.html">Contributing</a>
|
222
208
|
|
223
209
|
</li>
|
224
210
|
|
@@ -259,10 +245,6 @@
|
|
259
245
|
|
260
246
|
|
261
247
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
248
|
|
267
249
|
|
268
250
|
|
@@ -305,7 +287,7 @@
|
|
305
287
|
|
306
288
|
<li data-order="">
|
307
289
|
|
308
|
-
<a href="/other-tools.html">Other Tools</a>
|
290
|
+
<a href="/chatterbot/other-tools.html">Other Tools</a>
|
309
291
|
|
310
292
|
</li>
|
311
293
|
|
@@ -330,10 +312,6 @@
|
|
330
312
|
|
331
313
|
|
332
314
|
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
315
|
|
338
316
|
<li data-order="">
|
339
317
|
|
@@ -361,153 +339,158 @@
|
|
361
339
|
</h2>
|
362
340
|
</div>
|
363
341
|
|
364
|
-
<p>Here
|
342
|
+
<p>Here’s a couple examples of working bots.</p>
|
365
343
|
|
366
|
-
<h2 id="
|
344
|
+
<h2 id="echoesbot">@echoes_bot</h2>
|
367
345
|
|
368
346
|
<p>This is a working bot. It responds to any mentions with the incoming
|
369
347
|
text:</p>
|
370
348
|
|
371
349
|
<blockquote class="twitter-tweet" lang="en"><p><a href="https://twitter.com/muffinista">@muffinista</a> hello there!</p>— Echo Echo (@echoes_bot) <a href="https://twitter.com/echoes_bot/status/515166110950256640">September 25, 2014</a></blockquote>
|
350
|
+
<script async="" src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
372
351
|
|
373
|
-
<
|
352
|
+
<p>Here’s the code. This is right out of the git repo for chatterbot:</p>
|
374
353
|
|
375
|
-
<p
|
376
|
-
|
377
|
-
## chatterbot. It looks for mentions of
|
354
|
+
<p>```
|
355
|
+
## This is a very simple working example of a bot you can build with
|
356
|
+
## chatterbot. It looks for mentions of ‘@echoes_bot’ (the twitter
|
378
357
|
## handle the bot uses), and sends replies with the name switched to
|
379
|
-
## the handle of the sending user
|
358
|
+
## the handle of the sending user</p>
|
380
359
|
|
381
|
-
|
360
|
+
<p>#
|
382
361
|
# require the dsl lib to include all the methods you see below.
|
383
362
|
#
|
384
|
-
require
|
385
|
-
require
|
363
|
+
require ‘rubygems’
|
364
|
+
require ‘chatterbot/dsl’</p>
|
386
365
|
|
387
|
-
puts
|
366
|
+
<p>puts “Loading echoes_bot.rb”</p>
|
388
367
|
|
368
|
+
<h1 id="section">#</h1>
|
369
|
+
<p>## If I wanted to exclude some terms from triggering this bot, I would list them here.
|
370
|
+
## For now, we’ll block URLs to keep this from being a source of spam
|
389
371
|
##
|
390
|
-
|
391
|
-
## For now, we'll block URLs to keep this from being a source of spam
|
392
|
-
##
|
393
|
-
exclude "http://"
|
372
|
+
exclude “http://”</p>
|
394
373
|
|
395
|
-
blacklist
|
374
|
+
<p>blacklist “mean_user, private_user”</p>
|
396
375
|
|
397
|
-
puts
|
376
|
+
<p>puts “checking for replies to me”
|
398
377
|
replies do |tweet|
|
399
378
|
# replace the incoming username with #USER#, which will be replaced
|
400
379
|
# with the handle of the user who tweeted us by the
|
401
380
|
# replace_variables helper
|
402
|
-
src = tweet.text.gsub(/@echoes_bot/,
|
381
|
+
src = tweet.text.gsub(/@echoes_bot/, “#USER#”) </p>
|
403
382
|
|
404
|
-
|
383
|
+
<p># send it back!
|
405
384
|
reply src, tweet
|
406
385
|
end
|
407
|
-
|
408
|
-
|
386
|
+
```</p>
|
387
|
+
|
388
|
+
<h2 id="spacejamcheck">@SpaceJamCheck</h2>
|
409
389
|
|
410
390
|
<p>This is another working bot. It checks the website for the movie Space
|
411
391
|
Jam to see if it is still online (it does this by using the spacejam
|
412
392
|
gem), and tweets the results of that check.</p>
|
413
|
-
<div class="highlight"><pre><code class="language-text" data-lang="text">#!/usr/bin/env ruby
|
414
393
|
|
415
|
-
|
416
|
-
|
394
|
+
<p>```
|
395
|
+
#!/usr/bin/env ruby</p>
|
417
396
|
|
418
|
-
require
|
419
|
-
require
|
397
|
+
<p>require ‘rubygems’
|
398
|
+
require ‘bundler/setup’</p>
|
420
399
|
|
421
|
-
|
400
|
+
<p>require ‘chatterbot/dsl’
|
401
|
+
require ‘spacejam’</p>
|
402
|
+
|
403
|
+
<p>#
|
422
404
|
# this is the script for the twitter bot SpaceJamCheck
|
423
405
|
# generated on 2013-11-04 16:24:46 -0500
|
424
|
-
|
406
|
+
#</p>
|
425
407
|
|
426
|
-
consumer_key
|
427
|
-
consumer_secret
|
408
|
+
<p>consumer_key ‘key’
|
409
|
+
consumer_secret ‘secret’</p>
|
428
410
|
|
429
|
-
secret
|
430
|
-
token
|
411
|
+
<p>secret ‘secret’
|
412
|
+
token ‘token’</p>
|
431
413
|
|
414
|
+
<p>check_url = “http://www2.warnerbros.com/spacejam/movie/jam.htm”
|
415
|
+
check_string = “<title>Space Jam</title>”</p>
|
432
416
|
|
433
|
-
|
434
|
-
|
417
|
+
<p>uptime_messages = [
|
418
|
+
“Hooray! Space Jam is still online!”,
|
419
|
+
“It’s #{Time.now.year} and the Space Jam website is still online”,
|
420
|
+
“In case you were worried, Space Jam is still online”,
|
421
|
+
“Looks like the Space Jam website is still there”,
|
422
|
+
“Yes”,
|
423
|
+
“Yep”,
|
424
|
+
“Still Kickin”,
|
425
|
+
“The Space Jam website is still online”,
|
426
|
+
“Still Online”
|
427
|
+
]</p>
|
435
428
|
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
"In case you were worried, Space Jam is still online",
|
440
|
-
"Looks like the Space Jam website is still there",
|
441
|
-
"Yes",
|
442
|
-
"Yep",
|
443
|
-
"Still Kickin",
|
444
|
-
"The Space Jam website is still online",
|
445
|
-
"Still Online"
|
446
|
-
]
|
429
|
+
<p>downtime_messages = [
|
430
|
+
“Hmm, looks like Space Jam isn’t online. Hopefully it’s a fluke ;(“
|
431
|
+
]</p>
|
447
432
|
|
448
|
-
|
449
|
-
"Hmm, looks like Space Jam isn't online. Hopefully it's a fluke ;("
|
450
|
-
]
|
433
|
+
<p>x = Spacejam::HTTPCheck.new(url:check_url, body:check_string)</p>
|
451
434
|
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
# pick a random tweet according to the website status
|
456
|
-
result = if x.online?
|
435
|
+
<h1 id="pick-a-random-tweet-according-to-the-website-status">pick a random tweet according to the website status</h1>
|
436
|
+
<p>result = if x.online?
|
457
437
|
uptime_messages
|
458
438
|
else
|
459
439
|
downtime_messages
|
460
|
-
end.sample
|
440
|
+
end.sample</p>
|
441
|
+
|
442
|
+
<h1 id="add-a-timestamp-this-helps-to-prevent-duplicate-tweet-issues">add a timestamp. this helps to prevent duplicate tweet issues</h1>
|
443
|
+
<p>result « ” (#{Time.now.utc})”</p>
|
461
444
|
|
462
|
-
|
463
|
-
result
|
445
|
+
<h1 id="tweet-it-out">tweet it out!</h1>
|
446
|
+
<p>tweet result
|
447
|
+
```</p>
|
464
448
|
|
465
|
-
# tweet it out!
|
466
|
-
tweet result
|
467
|
-
</code></pre></div>
|
468
449
|
<h2 id="streaming-bot">Streaming Bot</h2>
|
469
|
-
<div class="highlight"><pre><code class="language-text" data-lang="text">#!/usr/bin/env ruby
|
470
450
|
|
471
|
-
|
472
|
-
|
451
|
+
<p>```
|
452
|
+
#!/usr/bin/env ruby</p>
|
473
453
|
|
474
|
-
|
454
|
+
<h2 id="this-is-a-very-simple-working-example-of-a-bot-using-the-streaming">This is a very simple working example of a bot using the streaming</h2>
|
455
|
+
<p>## API. It’s basically a copy of echoes_bot.rb, just using streaming.</p>
|
456
|
+
|
457
|
+
<p>#
|
475
458
|
# require the dsl lib to include all the methods you see below.
|
476
459
|
#
|
477
|
-
require
|
478
|
-
require
|
460
|
+
require ‘rubygems’
|
461
|
+
require ‘chatterbot/dsl’</p>
|
479
462
|
|
480
|
-
consumer_secret
|
481
|
-
secret
|
482
|
-
token
|
483
|
-
consumer_key
|
463
|
+
<p>consumer_secret ‘foo’
|
464
|
+
secret ‘bar’
|
465
|
+
token ‘biz’
|
466
|
+
consumer_key ‘bam’</p>
|
484
467
|
|
468
|
+
<p>puts “Loading echoes_bot.rb using the streaming API”</p>
|
485
469
|
|
486
|
-
|
470
|
+
<p>exclude “http://”, “https://”</p>
|
487
471
|
|
488
|
-
|
472
|
+
<p>blacklist “mean_user, private_user”</p>
|
489
473
|
|
490
|
-
|
491
|
-
|
492
|
-
streaming do
|
474
|
+
<p>streaming do
|
493
475
|
favorited do |user, tweet|
|
494
|
-
reply
|
495
|
-
end
|
476
|
+
reply “@#{user.screen_name} thanks for the fave!”, tweet
|
477
|
+
end</p>
|
496
478
|
|
497
|
-
|
498
|
-
tweet
|
479
|
+
<p>followed do |user|
|
480
|
+
tweet “@#{user.screen_name} just followed me!”
|
499
481
|
follow user
|
500
|
-
end
|
482
|
+
end</p>
|
501
483
|
|
502
|
-
|
503
|
-
favorite tweet
|
484
|
+
<p>replies do |tweet|
|
485
|
+
favorite tweet</p>
|
486
|
+
|
487
|
+
<pre><code>puts "It's a tweet!"
|
488
|
+
src = tweet.text.gsub(/@echoes_bot/, "#USER#")
|
489
|
+
reply src, tweet end end
|
490
|
+
</code></pre>
|
491
|
+
|
492
|
+
<p>```</p>
|
504
493
|
|
505
|
-
puts "It's a tweet!"
|
506
|
-
src = tweet.text.gsub(/@echoes_bot/, "#USER#")
|
507
|
-
reply src, tweet
|
508
|
-
end
|
509
|
-
end
|
510
|
-
</code></pre></div>
|
511
494
|
|
512
495
|
</div>
|
513
496
|
|
@@ -515,7 +498,9 @@ end
|
|
515
498
|
|
516
499
|
<div class=row-fluid>
|
517
500
|
<div id=footer class=span12>
|
518
|
-
|
501
|
+
<!--
|
502
|
+
Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
|
503
|
+
-->
|
519
504
|
|
520
505
|
</div>
|
521
506
|
</div>
|