chatterbot 2.0.2 → 2.2.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.
Files changed (93) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +19 -0
  3. data/Gemfile +9 -17
  4. data/README.markdown +10 -23
  5. data/Rakefile +2 -18
  6. data/chatterbot.gemspec +17 -12
  7. data/docs/Gemfile +3 -0
  8. data/docs/README.md +3 -0
  9. data/docs/_config.yml +37 -0
  10. data/docs/_includes/footer.html +3 -0
  11. data/docs/_includes/header.html +4 -0
  12. data/docs/_includes/navigation.html +23 -0
  13. data/docs/_layouts/default.html +98 -0
  14. data/docs/_layouts/page.html +11 -0
  15. data/docs/_posts/.gitkeep +0 -0
  16. data/docs/_site/Gemfile +3 -0
  17. data/docs/_site/advanced.html +465 -0
  18. data/docs/_site/configuration.html +436 -0
  19. data/docs/_site/contributing.html +414 -0
  20. data/docs/_site/css/main.css +58 -0
  21. data/docs/_site/css/syntax.css +61 -0
  22. data/docs/_site/deploying.html +451 -0
  23. data/docs/_site/examples.html +559 -0
  24. data/docs/_site/features.html +496 -0
  25. data/docs/_site/images/01-create-application.png +0 -0
  26. data/docs/_site/images/02-application-permissions.png +0 -0
  27. data/docs/_site/images/03-mobile-number.png +0 -0
  28. data/docs/_site/images/04-access-token.png +0 -0
  29. data/docs/_site/index.html +461 -0
  30. data/docs/_site/javascripts/main.js +1 -0
  31. data/docs/_site/other-tools.html +419 -0
  32. data/docs/_site/params.json +1 -0
  33. data/docs/_site/rdoc.html +409 -0
  34. data/docs/_site/setup.html +491 -0
  35. data/docs/_site/stylesheets/pygment_trac.css +68 -0
  36. data/docs/_site/stylesheets/stylesheet.css +247 -0
  37. data/docs/_site/tut.html +402 -0
  38. data/docs/_site/twitter-docs.html +409 -0
  39. data/docs/_site/walkthrough.html +447 -0
  40. data/docs/advanced.md +62 -0
  41. data/docs/basics.md +12 -0
  42. data/docs/bin/jekyll-page +109 -0
  43. data/docs/configuration.md +32 -0
  44. data/docs/contributing.md +14 -0
  45. data/docs/css/main.css +58 -0
  46. data/docs/css/syntax.css +61 -0
  47. data/docs/deploying.md +47 -0
  48. data/docs/examples.md +120 -0
  49. data/docs/features.md +88 -0
  50. data/docs/images/01-create-application.png +0 -0
  51. data/docs/images/02-application-permissions.png +0 -0
  52. data/docs/images/03-mobile-number.png +0 -0
  53. data/docs/images/04-access-token.png +0 -0
  54. data/docs/index.md +69 -0
  55. data/docs/javascripts/main.js +1 -0
  56. data/docs/other-tools.md +17 -0
  57. data/docs/params.json +1 -0
  58. data/docs/rdoc.md +6 -0
  59. data/docs/setup.md +84 -0
  60. data/docs/stylesheets/pygment_trac.css +68 -0
  61. data/docs/stylesheets/stylesheet.css +247 -0
  62. data/docs/tips.md +22 -0
  63. data/docs/tut.md +6 -0
  64. data/docs/twitter-docs.md +6 -0
  65. data/docs/walkthrough.md +46 -0
  66. data/lib/chatterbot.rb +0 -1
  67. data/lib/chatterbot/bot.rb +7 -67
  68. data/lib/chatterbot/client.rb +2 -9
  69. data/lib/chatterbot/config.rb +1 -2
  70. data/lib/chatterbot/dsl.rb +20 -47
  71. data/lib/chatterbot/home_timeline.rb +1 -1
  72. data/lib/chatterbot/search.rb +26 -3
  73. data/lib/chatterbot/skeleton.rb +0 -2
  74. data/lib/chatterbot/tweet.rb +13 -3
  75. data/lib/chatterbot/ui.rb +0 -1
  76. data/lib/chatterbot/version.rb +1 -1
  77. data/spec/bot_spec.rb +1 -76
  78. data/spec/client_spec.rb +0 -3
  79. data/spec/config_manager_spec.rb +6 -5
  80. data/spec/config_spec.rb +4 -1
  81. data/spec/dsl_spec.rb +10 -35
  82. data/spec/fixtures/update_with_media.png +0 -0
  83. data/spec/search_spec.rb +40 -1
  84. data/spec/spec_helper.rb +1 -4
  85. data/spec/tweet_spec.rb +74 -34
  86. data/templates/skeleton.txt +0 -47
  87. metadata +81 -135
  88. data/.document +0 -5
  89. data/.travis.yml +0 -11
  90. data/examples/streaming_bot.rb +0 -48
  91. data/examples/tweet_logger.rb +0 -68
  92. data/lib/chatterbot/streaming.rb +0 -62
  93. data/spec/streaming_spec.rb +0 -172
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: dd3b277547610b8d5e0ec0993a5952d015cab80b
4
- data.tar.gz: 114e6d11f506a6bbb331081b66395613346e3a12
2
+ SHA256:
3
+ metadata.gz: 49208ab18cf0449b6e3e9edaee0be33e626ffb1871137bc1131ed7a4745404c1
4
+ data.tar.gz: 3f921764ebfb8121ac30fb3c6785f586d785102376abc1c5e41faa4e5f04bcca
5
5
  SHA512:
6
- metadata.gz: 92c72bf9e9ab384e2a5a00756d78af0128998efd1dd7d1eba9ac069b8fe427042e5ea73aeed03e2ae9dd30a140833382f9e239090b6c835794fe9207073e6d98
7
- data.tar.gz: 3d6c202746806977bd602b9ad2f196cec49ef4dd091582ce38711906b1e7ddb9fd93be34b517b6aadeb7492e024e07784c12c4002d74e0220247bd623616fea6
6
+ metadata.gz: 46c3805f65a29e1f538e03aaa5d506f966b33fad6b879bb818929ff2086a940f15ab3e68f6584daac61182650b100b962c02ede0d5e83c93e4ed1ab13437cc02
7
+ data.tar.gz: 89fdcbd28704b4547b0bf3593e1b4384dcba7755d7a7fda4ee6f9836bc6fe9c4d05677da208d85e6a74229d01114f89d120d5666cf17bf90c88ab5270b01878a
@@ -0,0 +1,19 @@
1
+ ---
2
+ name: Run tests
3
+ on: [push, pull_request]
4
+ jobs:
5
+ build:
6
+ strategy:
7
+ fail-fast: false
8
+ matrix:
9
+ os: [ubuntu-latest, macos-latest, windows-latest]
10
+ ruby: [2.5, 2.6, 2.7]
11
+ runs-on: ${{ matrix.os }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: ${{ matrix.ruby }}
17
+ bundler-cache: true
18
+ - name: rspec
19
+ run: bundle exec rake
data/Gemfile CHANGED
@@ -2,29 +2,21 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
4
 
5
- #gem "twitter_oauth"
6
- #gem "sequel"
5
+ gem 'rake'
6
+ gem 'yard'
7
7
 
8
8
  # Add dependencies to develop your gem here.
9
9
  # Include everything needed to run rake, tests, features, etc.
10
10
  group :development do
11
- #gem 'simplecov', :require => false, :group => :test
12
-
13
- #gem "shoulda", ">= 0"
14
- #gem "rspec"
15
- #gem "rake"
16
- #gem "twitter", "~> 4.4.0"
17
-
18
- #gem "watchr"
11
+ gem 'pry'
19
12
  end
20
13
 
21
- gem "pry"
22
14
 
23
- #
24
- # couple extra gems for testing db connectivity
25
- #
26
15
  group :test do
27
- gem "sequel"
28
- gem "mysql"
29
- gem "sqlite3"
16
+ gem 'rspec', '~> 3.10.0'
17
+ gem 'rspec-mocks', '~> 3.10.0'
18
+ gem 'simplecov', '>= 0'
19
+ gem 'observr', '>= 0'
30
20
  end
21
+
22
+
data/README.markdown CHANGED
@@ -22,7 +22,6 @@ Features
22
22
  * Simple blocklist system to limit your annoyance of users
23
23
  * Avoid your bot making a fool of itself by ignoring tweets with
24
24
  certain bad words
25
- * Basic Streaming API support
26
25
 
27
26
 
28
27
  Using Chatterbot
@@ -79,8 +78,9 @@ Or you can write a bot using more traditional ruby classes, extend it if needed,
79
78
  ```
80
79
  class MyBot < Chatterbot::Bot
81
80
  def do_stuff
82
- search("'surely you must be joking'") do |tweet|
83
- reply "@#{tweet_user(tweet)} I am serious, and don't call me Shirley!", tweet
81
+ home_timeline do |tweet|
82
+ puts "I like to favorite things"
83
+ favorite tweet
84
84
  end
85
85
  end
86
86
  end
@@ -101,25 +101,12 @@ that you should just be using the Twitter gem directly.
101
101
  Streaming
102
102
  ---------
103
103
 
104
- Chatterbot has some basic support for the Streaming API. If you want
105
- to do something complicated, you should probably consider using the
106
- [Twitter gem](https://github.com/sferik/twitter#streaming) directly.
107
-
108
- Basic usage is very straightforward:
109
-
110
- use_streaming true
111
- home_timeline do |tweet|
112
- puts "someone i follow tweeted! #{tweet.text}"
113
- end
114
-
115
-
116
- You can also run a search:
117
-
118
- use_streaming true
119
- search("pizza") do |tweet|
120
- puts "someone is talking about pizza! #{tweet.text}"
121
- end
122
-
104
+ Chatterbot used to have some basic support for the Streaming API, but
105
+ I've removed it because Twitter is removing and/or restricting access
106
+ to those APIs. If you need the Streaming API, I highly recommend using
107
+ the the [Twitter
108
+ gem](https://github.com/sferik/twitter#streaming). Chatterbot is built
109
+ on the Twitter gem, it works great, and has support for streaming.
123
110
 
124
111
 
125
112
  What Can I Do?
@@ -354,7 +341,7 @@ I can work with you on that.
354
341
  Copyright/License
355
342
  -----------------
356
343
 
357
- Copyright (c) 2016 Colin Mitchell. Chatterbot is distributed under the
344
+ Copyright (c) 2018 Colin Mitchell. Chatterbot is distributed under the
358
345
  MIT licence -- Please see LICENSE.txt for further details.
359
346
 
360
347
  http://muffinlabs.com
data/Rakefile CHANGED
@@ -1,30 +1,12 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
- require "chatterbot/version"
5
-
6
4
  require 'rspec/core'
7
5
  require 'rspec/core/rake_task'
8
6
  RSpec::Core::RakeTask.new(:spec) do |spec|
9
7
  spec.pattern = FileList['spec/**/*_spec.rb']
10
8
  end
11
9
 
12
- RSpec::Core::RakeTask.new(:rcov) do |spec|
13
- spec.pattern = 'spec/**/*_spec.rb'
14
- spec.rcov_opts = %w{--exclude .bundler,.rvm}
15
- spec.rcov = true
16
- end
17
-
18
- task :default => :spec
19
-
20
- require 'rdoc/task'
21
- Rake::RDocTask.new do |rdoc|
22
- rdoc.main = "README.rdoc"
23
- rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
24
- rdoc.rdoc_dir = 'rdoc'
25
- rdoc.title = "'chatterbot #{Chatterbot::VERSION}'"
26
- end
27
-
28
10
  task :console do
29
11
  require 'irb'
30
12
  require 'irb/completion'
@@ -32,3 +14,5 @@ task :console do
32
14
  ARGV.clear
33
15
  IRB.start
34
16
  end
17
+
18
+ task :default => :spec
data/chatterbot.gemspec CHANGED
@@ -1,5 +1,8 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ #$:.push File.expand_path("../lib", __FILE__)
3
6
  require "chatterbot/version"
4
7
 
5
8
  Gem::Specification.new do |s|
@@ -20,18 +23,20 @@ Gem::Specification.new do |s|
20
23
  s.require_paths = ["lib"]
21
24
  s.licenses = ["MIT"]
22
25
 
23
- s.add_development_dependency(%q<redcarpet>, [">= 0"])
24
- s.add_runtime_dependency(%q<oauth>, ["~> 0.4.7"])
25
- s.add_runtime_dependency(%q<twitter>, ["~> 5.16.0"])
26
+ s.required_ruby_version = '>= 2.2'
27
+
28
+ s.add_runtime_dependency(%q<oauth>, ["~> 0.5.6"])
29
+ s.add_runtime_dependency(%q<twitter>, ["~> 7"])
26
30
  s.add_runtime_dependency(%q<launchy>, [">= 2.4.2"])
27
31
  s.add_runtime_dependency(%q<colorize>, [">= 0.7.3"])
28
- s.add_development_dependency(%q<yard>, [">= 0"])
29
- s.add_development_dependency(%q<shoulda>, [">= 0"])
30
- s.add_development_dependency(%q<rake>, ["< 11"])
31
- s.add_development_dependency(%q<rspec>, ["~> 3.0.0"])
32
- s.add_development_dependency(%q<rspec-mocks>, ["~> 3.0.2"])
33
- s.add_development_dependency(%q<rdoc>, [">= 0"])
34
- s.add_development_dependency(%q<simplecov>, [">= 0"])
35
- s.add_development_dependency(%q<observr>, [">= 0"])
32
+
33
+ s.add_development_dependency 'bundler', '~> 2.0'
34
+
35
+
36
+ s.post_install_message = %q{This version of chatterbot removes
37
+ activesupport as a dependency -- if you are using it, you might need
38
+ to install it separately!
39
+
40
+ }
36
41
  end
37
42
 
data/docs/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'github-pages'
3
+
data/docs/README.md ADDED
@@ -0,0 +1,3 @@
1
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/bruth/jekyll-docs-template/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
2
+
3
+ Read the docs: http://bruth.github.io/jekyll-docs-template
data/docs/_config.yml ADDED
@@ -0,0 +1,37 @@
1
+ # Site title and subtitle. This is used in _includes/header.html
2
+ title: 'chatterbot'
3
+ subtitle: 'twitter bots in ruby'
4
+
5
+ # Enable/show navigation. There are there options:
6
+ # 0 - always hide
7
+ # 1 - always show
8
+ # 2 - show only if posts are present
9
+ navigation: 1
10
+
11
+ # URL to source code, used in _includes/footer.html
12
+ codeurl: 'https://github.com/muffinista/chatterbot'
13
+
14
+ # Default categories (in order) to appear in the navigation
15
+ sections: [
16
+ ['tut', 'Getting Started'],
17
+ ['doc', 'Documentation'],
18
+ ['dev', 'Developers'],
19
+ ['links', 'Resources']
20
+ ]
21
+
22
+ # Keep as an empty string if served up at the root. If served up at a specific
23
+ # path (e.g. on GitHub pages) leave off the trailing slash, e.g. /my-project
24
+ baseurl: '/chatterbot'
25
+
26
+ # Dates are not included in permalinks
27
+ permalink: none
28
+
29
+ # Syntax highlighting
30
+ highlighter: 'rouge'
31
+
32
+ # Since these are pages, it doesn't really matter
33
+ future: true
34
+
35
+ # Exclude non-site files
36
+ exclude: ['bin', 'README.md']
37
+
@@ -0,0 +1,3 @@
1
+ <!--
2
+ Documentation for <a href="{% if site.codeurl %}{{ site.codeurl }}{% else %}{{ site.baseurl }}{% endif %}">{{ site.title }}</a>
3
+ -->
@@ -0,0 +1,4 @@
1
+ <h4><a class=brand href="{{ site.baseurl }}/">{{ site.title }}</a>
2
+ {% if site.subtitle %}<small>{{ site.subtitle }}</small>{% endif %}
3
+ </h4>
4
+
@@ -0,0 +1,23 @@
1
+ <ul class="nav nav-list">
2
+ <li><a href="{{ site.baseurl }}/">Home</a></li>
3
+ {% for section in site.sections %}
4
+ {% assign attr = section[0] %}
5
+ {% assign label = section[1] %}
6
+ <li class=nav-header>{{ label }}</li>
7
+ {% for page in site.pages %}
8
+ {% if page.published != false %}
9
+ {% if page.category == attr %}
10
+ <li data-order="{{ page.order }}">
11
+ {% if page.link %}
12
+ <a href="{{ page.link }}">{{ page.title }}</a>
13
+ {% else %}
14
+ <a href="{{ site.baseurl }}{{ page.url }}">{{ page.title }}</a>
15
+ {% endif %}
16
+ </li>
17
+ {% endif %}
18
+ {% endif %}
19
+ {% endfor %}
20
+ {% endfor %}
21
+ <!-- List additional links. It is recommended to add a divider
22
+ e.g. <li class=divider></li> first to break up the content. -->
23
+ </ul>
@@ -0,0 +1,98 @@
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>{{ site.title }}{% if page.title %} : {{ page.title }}{% endif %}</title>
9
+ <meta name="description" content="{{ site.subtitle }}">
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="{{ site.baseurl }}/css/syntax.css">
13
+ <link rel="stylesheet" href="{{ site.baseurl }}/css/main.css">
14
+ </head>
15
+ <body>
16
+
17
+ <div class="container">
18
+ <div class=row-fluid>
19
+ <div id=header class=span12>
20
+ {% include header.html %}
21
+ </div>
22
+ </div>
23
+
24
+ <div class=row-fluid>
25
+ {% assign post_count = site.posts|size %}
26
+ {% if site.navigation != 0 and site.navigation == 1 or post_count > 0 %}
27
+ <div id=navigation class=span2>
28
+ {% include navigation.html %}
29
+ </div>
30
+
31
+ <div id=content class=span10>
32
+ {{ content }}
33
+ </div>
34
+ {% else %}
35
+ <div id=content class=span12>
36
+ {{ content }}
37
+ </div>
38
+ {% endif %}
39
+ </div>
40
+
41
+ <div class=row-fluid>
42
+ <div id=footer class=span12>
43
+ {% include footer.html %}
44
+ </div>
45
+ </div>
46
+ </div>
47
+
48
+ <script>
49
+ function orderNav() {
50
+ var list,
51
+ section,
52
+ header,
53
+ sections = [],
54
+ lists = {},
55
+ headers = {};
56
+
57
+ var navUl = document.querySelectorAll('#navigation ul')[0],
58
+ navLis = document.querySelectorAll('#navigation ul li');
59
+
60
+ if (!navUl) return;
61
+
62
+ for (var i = 0; i < navLis.length; i++) {
63
+ var order, li = navLis[i];
64
+
65
+ if (li.classList.contains('nav-header')) {
66
+ section = li.textContent || li.innerText;
67
+ sections.push(section);
68
+ headers[section] = li;
69
+ continue;
70
+ }
71
+
72
+ if (!lists[section]) {
73
+ lists[section] = [];
74
+ }
75
+
76
+ order = parseFloat(li.getAttribute('data-order'))
77
+ lists[section].push([order, li]);
78
+ }
79
+
80
+ for (var i = 0; i < sections.length; i++) {
81
+ section = sections[i];
82
+ list = lists[section].sort(function(a, b) {
83
+ return a[0] - b[0];
84
+ });
85
+
86
+ if (header = headers[section]) {
87
+ navUl.appendChild(header);
88
+ }
89
+ for (var j = 0; j < list.length; j++) {
90
+ navUl.appendChild(list[j][1]);
91
+ }
92
+ }
93
+ }
94
+
95
+ if (document.querySelectorAll) orderNav();
96
+ </script>
97
+ </body>
98
+ </html>
@@ -0,0 +1,11 @@
1
+ ---
2
+ layout: default
3
+ ---
4
+
5
+ <div class=page-header>
6
+ <h2>{{ page.title }}
7
+ {% if page.subtitle %}<small>{{ page.subtitle }}</small>{% endif %}
8
+ </h2>
9
+ </div>
10
+
11
+ {{ content }}
File without changes
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ gem 'github-pages'
3
+
@@ -0,0 +1,465 @@
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 : Advanced Features</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>Advanced Features
338
+
339
+ </h2>
340
+ </div>
341
+
342
+ <h2 id="direct-client-access">Direct Client Access</h2>
343
+
344
+ <p>If you want to do something not provided directly by Chatterbot, you
345
+ have access to an instance of Twitter::Client provided by the
346
+ <strong>client</strong> method. In theory, you can do something like this in your
347
+ bot to unfollow users who DM you:</p>
348
+
349
+ <pre><code>client.direct_messages_received(:since_id =&gt; since_id).each do |m|
350
+ client.unfollow(m.user.name)
351
+ end
352
+ </code></pre>
353
+
354
+ <h2 id="storing-config-in-the-database">Storing Config in the Database</h2>
355
+ <p>Sometimes it is preferable to store the authorization credentials for
356
+ your bot in a database.</p>
357
+
358
+ <p>Chatterbot can manage configurations that are stored in the database,
359
+ but to do this you will need to specify how to connect to the
360
+ database. You can do this by specifying the connection string
361
+ either in one of the global config files by setting</p>
362
+
363
+ <p><code>
364
+ :db_uri:mysql://username:password@host/database
365
+ </code></p>
366
+
367
+ <p>Or you can specify the connection on the command-line by using the
368
+ –db=”db_uri” configuration option. Any calls to the database are
369
+ handled by the Sequel gem, and MySQL and Sqlite should work. The DB
370
+ URI should be in the form of</p>
371
+
372
+ <pre><code>mysql://username:password@host/database
373
+ </code></pre>
374
+
375
+ <p>see http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
376
+ for details.</p>
377
+
378
+ <h2 id="logging-tweets-to-the-database">Logging Tweets to the Database</h2>
379
+
380
+ <p>Chatterbot can log tweet activity to a database if desired. This can
381
+ be handy for archival purposes, or for tracking what’s going on with
382
+ your bot.</p>
383
+
384
+ <p>If you’ve configured your bot for database access, you can store a
385
+ tweet to the database by calling the <code>log</code> method like this:</p>
386
+
387
+ <p><code>
388
+ search "chatterbot" do |tweet|
389
+ log tweet
390
+ end
391
+ </code></p>
392
+
393
+ <p>See <code>Chatterbot::Logging</code> for details on this.</p>
394
+
395
+ <h2 id="streaming">Streaming</h2>
396
+
397
+ <p>Chatterbot has basic support for Twitter’s Streaming API. You can read
398
+ more about it <a href="streaming.html">here</a></p>
399
+
400
+
401
+ </div>
402
+
403
+ </div>
404
+
405
+ <div class=row-fluid>
406
+ <div id=footer class=span12>
407
+ <!--
408
+ Documentation for <a href="https://github.com/muffinista/chatterbot">chatterbot</a>
409
+ -->
410
+
411
+ </div>
412
+ </div>
413
+ </div>
414
+
415
+ <script>
416
+ function orderNav() {
417
+ var list,
418
+ section,
419
+ header,
420
+ sections = [],
421
+ lists = {},
422
+ headers = {};
423
+
424
+ var navUl = document.querySelectorAll('#navigation ul')[0],
425
+ navLis = document.querySelectorAll('#navigation ul li');
426
+
427
+ if (!navUl) return;
428
+
429
+ for (var i = 0; i < navLis.length; i++) {
430
+ var order, li = navLis[i];
431
+
432
+ if (li.classList.contains('nav-header')) {
433
+ section = li.textContent || li.innerText;
434
+ sections.push(section);
435
+ headers[section] = li;
436
+ continue;
437
+ }
438
+
439
+ if (!lists[section]) {
440
+ lists[section] = [];
441
+ }
442
+
443
+ order = parseFloat(li.getAttribute('data-order'))
444
+ lists[section].push([order, li]);
445
+ }
446
+
447
+ for (var i = 0; i < sections.length; i++) {
448
+ section = sections[i];
449
+ list = lists[section].sort(function(a, b) {
450
+ return a[0] - b[0];
451
+ });
452
+
453
+ if (header = headers[section]) {
454
+ navUl.appendChild(header);
455
+ }
456
+ for (var j = 0; j < list.length; j++) {
457
+ navUl.appendChild(list[j][1]);
458
+ }
459
+ }
460
+ }
461
+
462
+ if (document.querySelectorAll) orderNav();
463
+ </script>
464
+ </body>
465
+ </html>