chatterbot 2.0.0.pre → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +19 -0
  3. data/Gemfile +9 -17
  4. data/README.markdown +27 -34
  5. data/Rakefile +2 -18
  6. data/bin/chatterbot-register +6 -2
  7. data/chatterbot.gemspec +11 -12
  8. data/docs/Gemfile +3 -0
  9. data/docs/README.md +3 -0
  10. data/docs/_config.yml +37 -0
  11. data/docs/_includes/footer.html +3 -0
  12. data/docs/_includes/header.html +4 -0
  13. data/docs/_includes/navigation.html +23 -0
  14. data/docs/_layouts/default.html +98 -0
  15. data/docs/_layouts/page.html +11 -0
  16. data/docs/_posts/.gitkeep +0 -0
  17. data/docs/_site/Gemfile +3 -0
  18. data/docs/_site/advanced.html +465 -0
  19. data/docs/_site/configuration.html +436 -0
  20. data/docs/_site/contributing.html +414 -0
  21. data/docs/_site/css/main.css +58 -0
  22. data/docs/_site/css/syntax.css +61 -0
  23. data/docs/_site/deploying.html +451 -0
  24. data/docs/_site/examples.html +559 -0
  25. data/docs/_site/features.html +496 -0
  26. data/docs/_site/images/01-create-application.png +0 -0
  27. data/docs/_site/images/02-application-permissions.png +0 -0
  28. data/docs/_site/images/03-mobile-number.png +0 -0
  29. data/docs/_site/images/04-access-token.png +0 -0
  30. data/docs/_site/index.html +461 -0
  31. data/docs/_site/javascripts/main.js +1 -0
  32. data/docs/_site/other-tools.html +419 -0
  33. data/docs/_site/params.json +1 -0
  34. data/docs/_site/rdoc.html +409 -0
  35. data/docs/_site/setup.html +491 -0
  36. data/docs/_site/stylesheets/pygment_trac.css +68 -0
  37. data/docs/_site/stylesheets/stylesheet.css +247 -0
  38. data/docs/_site/tut.html +402 -0
  39. data/docs/_site/twitter-docs.html +409 -0
  40. data/docs/_site/walkthrough.html +447 -0
  41. data/docs/advanced.md +62 -0
  42. data/docs/basics.md +12 -0
  43. data/docs/bin/jekyll-page +109 -0
  44. data/docs/configuration.md +32 -0
  45. data/docs/contributing.md +14 -0
  46. data/docs/css/main.css +58 -0
  47. data/docs/css/syntax.css +61 -0
  48. data/docs/deploying.md +47 -0
  49. data/docs/examples.md +120 -0
  50. data/docs/features.md +88 -0
  51. data/docs/images/01-create-application.png +0 -0
  52. data/docs/images/02-application-permissions.png +0 -0
  53. data/docs/images/03-mobile-number.png +0 -0
  54. data/docs/images/04-access-token.png +0 -0
  55. data/docs/index.md +69 -0
  56. data/docs/javascripts/main.js +1 -0
  57. data/docs/other-tools.md +17 -0
  58. data/docs/params.json +1 -0
  59. data/docs/rdoc.md +6 -0
  60. data/docs/setup.md +84 -0
  61. data/docs/stylesheets/pygment_trac.css +68 -0
  62. data/docs/stylesheets/stylesheet.css +247 -0
  63. data/docs/tips.md +22 -0
  64. data/docs/tut.md +6 -0
  65. data/docs/twitter-docs.md +6 -0
  66. data/docs/walkthrough.md +46 -0
  67. data/ext/mkrf_conf.rb +28 -0
  68. data/lib/chatterbot.rb +0 -1
  69. data/lib/chatterbot/bot.rb +7 -63
  70. data/lib/chatterbot/client.rb +6 -12
  71. data/lib/chatterbot/config.rb +2 -2
  72. data/lib/chatterbot/config_manager.rb +7 -1
  73. data/lib/chatterbot/dsl.rb +20 -47
  74. data/lib/chatterbot/home_timeline.rb +1 -2
  75. data/lib/chatterbot/search.rb +26 -3
  76. data/lib/chatterbot/skeleton.rb +1 -3
  77. data/lib/chatterbot/tweet.rb +14 -3
  78. data/lib/chatterbot/ui.rb +88 -20
  79. data/lib/chatterbot/version.rb +1 -1
  80. data/spec/bot_spec.rb +2 -77
  81. data/spec/client_spec.rb +2 -6
  82. data/spec/config_manager_spec.rb +6 -5
  83. data/spec/config_spec.rb +4 -1
  84. data/spec/dsl_spec.rb +10 -35
  85. data/spec/fixtures/update_with_media.png +0 -0
  86. data/spec/search_spec.rb +40 -1
  87. data/spec/spec_helper.rb +1 -4
  88. data/spec/tweet_spec.rb +75 -38
  89. data/templates/skeleton.txt +26 -56
  90. metadata +84 -141
  91. data/.document +0 -5
  92. data/.travis.yml +0 -8
  93. data/examples/streaming_bot.rb +0 -48
  94. data/examples/tweet_logger.rb +0 -68
  95. data/lib/chatterbot/streaming.rb +0 -60
  96. data/spec/streaming_spec.rb +0 -170
@@ -0,0 +1,559 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6
+ <meta name="viewport" content="width=device-width">
7
+
8
+ <title>chatterbot : Examples</title>
9
+ <meta name="description" content="twitter bots in ruby">
10
+
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="/chatterbot/css/syntax.css">
13
+ <link rel="stylesheet" href="/chatterbot/css/main.css">
14
+ </head>
15
+ <body>
16
+
17
+ <div class="container">
18
+ <div class=row-fluid>
19
+ <div id=header class=span12>
20
+ <h4><a class=brand href="/chatterbot/">chatterbot</a>
21
+ <small>twitter bots in ruby</small>
22
+ </h4>
23
+
24
+
25
+ </div>
26
+ </div>
27
+
28
+ <div class=row-fluid>
29
+
30
+
31
+ <div id=navigation class=span2>
32
+ <ul class="nav nav-list">
33
+ <li><a href="/chatterbot/">Home</a></li>
34
+
35
+
36
+
37
+ <li class=nav-header>Getting Started</li>
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+
51
+
52
+
53
+
54
+
55
+
56
+
57
+ <li data-order="">
58
+
59
+ <a href="/chatterbot/examples.html">Examples</a>
60
+
61
+ </li>
62
+
63
+
64
+
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+ <li data-order="">
84
+
85
+ <a href="/chatterbot/setup.html">Authorizing Your Bot</a>
86
+
87
+ </li>
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+ <li data-order="">
102
+
103
+ <a href="/chatterbot/walkthrough.html">Walkthrough</a>
104
+
105
+ </li>
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <li class=nav-header>Documentation</li>
113
+
114
+
115
+
116
+ <li data-order="">
117
+
118
+ <a href="/chatterbot/advanced.html">Advanced Features</a>
119
+
120
+ </li>
121
+
122
+
123
+
124
+
125
+
126
+ <li data-order="">
127
+
128
+ <a href="/chatterbot/configuration.html">Configuration</a>
129
+
130
+ </li>
131
+
132
+
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+ <li data-order="">
141
+
142
+ <a href="/chatterbot/deploying.html">Running your Bot</a>
143
+
144
+ </li>
145
+
146
+
147
+
148
+
149
+
150
+
151
+
152
+
153
+
154
+ <li data-order="">
155
+
156
+ <a href="/chatterbot/features.html">Basic Features</a>
157
+
158
+ </li>
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
171
+
172
+
173
+
174
+
175
+
176
+
177
+
178
+
179
+
180
+
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+ <li class=nav-header>Developers</li>
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+ <li data-order="">
206
+
207
+ <a href="/chatterbot/contributing.html">Contributing</a>
208
+
209
+ </li>
210
+
211
+
212
+
213
+
214
+
215
+
216
+
217
+
218
+
219
+
220
+
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+
243
+
244
+
245
+
246
+
247
+
248
+
249
+
250
+
251
+
252
+
253
+
254
+
255
+
256
+ <li class=nav-header>Resources</li>
257
+
258
+
259
+
260
+
261
+
262
+
263
+
264
+
265
+
266
+
267
+
268
+
269
+
270
+
271
+
272
+
273
+
274
+
275
+
276
+
277
+
278
+
279
+
280
+
281
+
282
+
283
+
284
+
285
+
286
+
287
+
288
+ <li data-order="">
289
+
290
+ <a href="/chatterbot/other-tools.html">Other Tools</a>
291
+
292
+ </li>
293
+
294
+
295
+
296
+
297
+
298
+ <li data-order="">
299
+
300
+ <a href="http://rubydoc.info/gems/chatterbot">rdoc</a>
301
+
302
+ </li>
303
+
304
+
305
+
306
+
307
+
308
+
309
+
310
+
311
+
312
+
313
+
314
+
315
+
316
+ <li data-order="">
317
+
318
+ <a href="https://dev.twitter.com/rest/public">Twitter API docs</a>
319
+
320
+ </li>
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+
329
+ <!-- List additional links. It is recommended to add a divider
330
+ e.g. <li class=divider></li> first to break up the content. -->
331
+ </ul>
332
+
333
+ </div>
334
+
335
+ <div id=content class=span10>
336
+ <div class=page-header>
337
+ <h2>Examples
338
+
339
+ </h2>
340
+ </div>
341
+
342
+ <p>Here’s a couple examples of working bots.</p>
343
+
344
+ <h2 id="echoesbot">@echoes_bot</h2>
345
+
346
+ <p>This is a working bot. It responds to any mentions with the incoming
347
+ text:</p>
348
+
349
+ <blockquote class="twitter-tweet" lang="en"><p><a href="https://twitter.com/muffinista">@muffinista</a> hello there!</p>&mdash; 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>
351
+
352
+ <p>Here’s the code. This is right out of the git repo for chatterbot:</p>
353
+
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
357
+ ## handle the bot uses), and sends replies with the name switched to
358
+ ## the handle of the sending user</p>
359
+
360
+ <p>#
361
+ # require the dsl lib to include all the methods you see below.
362
+ #
363
+ require ‘rubygems’
364
+ require ‘chatterbot/dsl’</p>
365
+
366
+ <p>puts “Loading echoes_bot.rb”</p>
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
371
+ ##
372
+ exclude “http://”</p>
373
+
374
+ <p>blacklist “mean_user, private_user”</p>
375
+
376
+ <p>puts “checking for replies to me”
377
+ replies do |tweet|
378
+ # replace the incoming username with #USER#, which will be replaced
379
+ # with the handle of the user who tweeted us by the
380
+ # replace_variables helper
381
+ src = tweet.text.gsub(/@echoes_bot/, “#USER#”) </p>
382
+
383
+ <p># send it back!
384
+ reply src, tweet
385
+ end
386
+ ```</p>
387
+
388
+ <h2 id="spacejamcheck">@SpaceJamCheck</h2>
389
+
390
+ <p>This is another working bot. It checks the website for the movie Space
391
+ Jam to see if it is still online (it does this by using the spacejam
392
+ gem), and tweets the results of that check.</p>
393
+
394
+ <p>```
395
+ #!/usr/bin/env ruby</p>
396
+
397
+ <p>require ‘rubygems’
398
+ require ‘bundler/setup’</p>
399
+
400
+ <p>require ‘chatterbot/dsl’
401
+ require ‘spacejam’</p>
402
+
403
+ <p>#
404
+ # this is the script for the twitter bot SpaceJamCheck
405
+ # generated on 2013-11-04 16:24:46 -0500
406
+ #</p>
407
+
408
+ <p>consumer_key ‘key’
409
+ consumer_secret ‘secret’</p>
410
+
411
+ <p>secret ‘secret’
412
+ token ‘token’</p>
413
+
414
+ <p>check_url = “http://www2.warnerbros.com/spacejam/movie/jam.htm”
415
+ check_string = “<title>Space Jam</title>”</p>
416
+
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>
428
+
429
+ <p>downtime_messages = [
430
+ “Hmm, looks like Space Jam isn’t online. Hopefully it’s a fluke ;(“
431
+ ]</p>
432
+
433
+ <p>x = Spacejam::HTTPCheck.new(url:check_url, body:check_string)</p>
434
+
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?
437
+ uptime_messages
438
+ else
439
+ downtime_messages
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>
444
+
445
+ <h1 id="tweet-it-out">tweet it out!</h1>
446
+ <p>tweet result
447
+ ```</p>
448
+
449
+ <h2 id="streaming-bot">Streaming Bot</h2>
450
+
451
+ <p>```
452
+ #!/usr/bin/env ruby</p>
453
+
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>#
458
+ # require the dsl lib to include all the methods you see below.
459
+ #
460
+ require ‘rubygems’
461
+ require ‘chatterbot/dsl’</p>
462
+
463
+ <p>consumer_secret ‘foo’
464
+ secret ‘bar’
465
+ token ‘biz’
466
+ consumer_key ‘bam’</p>
467
+
468
+ <p>puts “Loading echoes_bot.rb using the streaming API”</p>
469
+
470
+ <p>exclude “http://”, “https://”</p>
471
+
472
+ <p>blacklist “mean_user, private_user”</p>
473
+
474
+ <p>streaming do
475
+ favorited do |user, tweet|
476
+ reply “@#{user.screen_name} thanks for the fave!”, tweet
477
+ end</p>
478
+
479
+ <p>followed do |user|
480
+ tweet “@#{user.screen_name} just followed me!”
481
+ follow user
482
+ end</p>
483
+
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>
493
+
494
+
495
+ </div>
496
+
497
+ </div>
498
+
499
+ <div class=row-fluid>
500
+ <div id=footer class=span12>
501
+ <!--
502
+ Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
503
+ -->
504
+
505
+ </div>
506
+ </div>
507
+ </div>
508
+
509
+ <script>
510
+ function orderNav() {
511
+ var list,
512
+ section,
513
+ header,
514
+ sections = [],
515
+ lists = {},
516
+ headers = {};
517
+
518
+ var navUl = document.querySelectorAll('#navigation ul')[0],
519
+ navLis = document.querySelectorAll('#navigation ul li');
520
+
521
+ if (!navUl) return;
522
+
523
+ for (var i = 0; i < navLis.length; i++) {
524
+ var order, li = navLis[i];
525
+
526
+ if (li.classList.contains('nav-header')) {
527
+ section = li.textContent || li.innerText;
528
+ sections.push(section);
529
+ headers[section] = li;
530
+ continue;
531
+ }
532
+
533
+ if (!lists[section]) {
534
+ lists[section] = [];
535
+ }
536
+
537
+ order = parseFloat(li.getAttribute('data-order'))
538
+ lists[section].push([order, li]);
539
+ }
540
+
541
+ for (var i = 0; i < sections.length; i++) {
542
+ section = sections[i];
543
+ list = lists[section].sort(function(a, b) {
544
+ return a[0] - b[0];
545
+ });
546
+
547
+ if (header = headers[section]) {
548
+ navUl.appendChild(header);
549
+ }
550
+ for (var j = 0; j < list.length; j++) {
551
+ navUl.appendChild(list[j][1]);
552
+ }
553
+ }
554
+ }
555
+
556
+ if (document.querySelectorAll) orderNav();
557
+ </script>
558
+ </body>
559
+ </html>