chatterbot 2.0.3 → 2.0.4

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 (76) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -5
  3. data/Gemfile +9 -17
  4. data/Rakefile +2 -18
  5. data/chatterbot.gemspec +10 -11
  6. data/docs/Gemfile +3 -0
  7. data/docs/README.md +3 -0
  8. data/docs/_config.yml +37 -0
  9. data/docs/_includes/footer.html +3 -0
  10. data/docs/_includes/header.html +4 -0
  11. data/docs/_includes/navigation.html +23 -0
  12. data/docs/_layouts/default.html +98 -0
  13. data/docs/_layouts/page.html +11 -0
  14. data/docs/_posts/.gitkeep +0 -0
  15. data/docs/_site/Gemfile +3 -0
  16. data/docs/_site/advanced.html +476 -0
  17. data/docs/_site/configuration.html +456 -0
  18. data/docs/_site/contributing.html +433 -0
  19. data/docs/_site/css/main.css +58 -0
  20. data/docs/_site/css/syntax.css +61 -0
  21. data/docs/_site/deploying.html +468 -0
  22. data/docs/_site/examples.html +574 -0
  23. data/docs/_site/features.html +497 -0
  24. data/docs/_site/images/01-create-application.png +0 -0
  25. data/docs/_site/images/02-application-permissions.png +0 -0
  26. data/docs/_site/images/03-mobile-number.png +0 -0
  27. data/docs/_site/images/04-access-token.png +0 -0
  28. data/docs/_site/index.html +482 -0
  29. data/docs/_site/javascripts/main.js +1 -0
  30. data/docs/_site/other-tools.html +438 -0
  31. data/docs/_site/params.json +1 -0
  32. data/docs/_site/rdoc.html +428 -0
  33. data/docs/_site/setup.html +500 -0
  34. data/docs/_site/streaming.html +506 -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 +422 -0
  38. data/docs/_site/twitter-docs.html +428 -0
  39. data/docs/_site/walkthrough.html +463 -0
  40. data/docs/advanced.md +67 -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 +53 -0
  48. data/docs/examples.md +168 -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 +70 -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/streaming.md +98 -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/examples/streaming_bot.rb +11 -10
  68. data/ext/mkrf_conf.rb +28 -0
  69. data/lib/chatterbot/bot.rb +5 -1
  70. data/lib/chatterbot/config.rb +1 -1
  71. data/lib/chatterbot/home_timeline.rb +1 -1
  72. data/lib/chatterbot/streaming.rb +11 -1
  73. data/lib/chatterbot/version.rb +1 -1
  74. data/spec/spec_helper.rb +1 -4
  75. metadata +71 -122
  76. data/examples/tweet_logger.rb +0 -68
@@ -0,0 +1,88 @@
1
+ ---
2
+ layout: page
3
+ title: "Basic Features"
4
+ category: doc
5
+ ---
6
+
7
+ Here's a list of some of the commonly-used methods in the Chatterbot DSL:
8
+
9
+ **search** -- You can use this to perform a search on Twitter:
10
+
11
+ search("'surely you must be joking'") do |tweet|
12
+ reply "#USER# I am serious, and don't call me Shirley!", tweet
13
+ end
14
+
15
+ By default, Chatterbot keeps track of the last time you ran the bot,
16
+ and it will only search for new tweets.
17
+
18
+ **replies** -- Use this to check for replies and mentions:
19
+
20
+ replies do |tweet|
21
+ reply "#USER# Thanks for contacting me!", tweet
22
+ end
23
+
24
+ Note that the string **#USER#** is automatically replaced with the
25
+ username of the person who sent the original tweet. Also, Chatterbot
26
+ will only return tweets that were sent since the last run of the bot.
27
+
28
+ **tweet** -- send a Tweet out for this bot:
29
+
30
+ tweet "I AM A BOT!!!"
31
+
32
+ **reply** -- reply to another tweet:
33
+
34
+ reply "THIS IS A REPLY TO #USER#!", original_tweet
35
+
36
+ **retweet** -- Chatterbot can retweet tweets as well:
37
+
38
+ ```rb
39
+ search "xyzzy" do |tweet|
40
+ retweet(tweet[:id])
41
+ end
42
+ ```
43
+
44
+ **blacklist** -- you can use this to specify a list of users you don't
45
+ want to interact with. If you put the following line at the top of
46
+ your bot:
47
+
48
+ blacklist "user1, user2, user3"
49
+
50
+ None of those users will trigger your bot if they come up in a
51
+ search. However, if a user replies to one of your tweets or mentions
52
+ your bot in a tweet, you will still receive that tweet when checking
53
+ for replies.
54
+
55
+ **exclude** -- similarly, you can specify a list of words/phrases
56
+ which shouldn't trigger your bot. If you use the following:
57
+
58
+ exclude "spam"
59
+
60
+ Any tweets or mentions with the word 'spam' in them will be ignored by
61
+ the bot. If you wanted to ignore any tweets with links in them (a wise
62
+ precaution if you want to avoid spreading spam), you could call:
63
+
64
+ exclude "http://"
65
+
66
+ The library actually comes with a pre-defined list of 'bad words'
67
+ which you can exclude by default by calling:
68
+
69
+ exclude bad_words
70
+
71
+ The word list is from Darius Kazemi's
72
+ [wordfilter](https://github.com/dariusk/wordfilter).
73
+
74
+
75
+ **whitelist**
76
+
77
+ **followers** -- get a list of your followers. This is an experimental
78
+ feature but should work for most purposes.
79
+
80
+ **follow**
81
+
82
+ **profile_text**
83
+ **profile_website**
84
+
85
+
86
+ For more details, check out
87
+ [dsl.rb](https://github.com/muffinista/chatterbot/blob/master/lib/chatterbot/dsl.rb)
88
+ in the source code.
@@ -0,0 +1,70 @@
1
+ ---
2
+ layout: default
3
+ title: "Chatterbot - ruby for Twitter bots"
4
+ ---
5
+
6
+ Chatterbot
7
+ ===========
8
+
9
+ [Chatterbot](https://github.com/muffinista/chatterbot) is a Ruby library for making bots on Twitter. It's
10
+ great for rapid development of bot ideas. It handles all of the basic
11
+ Twitter API features -- searches, replies, tweets, retweets, etc. and has
12
+ a simple blacklist/whitelist system to help minimize spam and unwanted
13
+ data.
14
+
15
+ A bot using chatterbot can be as simple as this:
16
+
17
+ ```
18
+ exclude "http://"
19
+ blacklist "mean_user, private_user"
20
+
21
+ puts "checking my timeline"
22
+ home_timeline do |tweet|
23
+ # i like to favorite things
24
+ favorite tweet
25
+ end
26
+
27
+ puts "checking for replies to my tweets and mentions of me"
28
+ replies do |tweet|
29
+ text = tweet.text
30
+ puts "message received: #{text}"
31
+ src = text.gsub(/@echoes_bot/, "#USER#")
32
+
33
+ # send it back!
34
+ reply src, tweet
35
+ end
36
+ ```
37
+
38
+ Or you can write a bot using more traditional ruby classes.
39
+
40
+ Chatterbot can actually generate a template bot file for you, and will
41
+ walk you through process of getting a bot authorized with Twitter.
42
+
43
+
44
+ Features
45
+ --------
46
+ * Handles search queries and replies to your bot
47
+ * Use a simple scripting language, or extend a Bot class if you need it
48
+ * Wraps the Twitter gem so you have access to the entire Twitter API
49
+ * Simple blacklistling system to limit your annoyance of users
50
+ * Avoid your bot making a fool of itself by ignoring tweets with
51
+ certain bad words
52
+ * Basic Streaming API support
53
+ * Optionally log tweets to the database for metrics and tracking purposes
54
+
55
+
56
+ Chatterbot uses the the Twitter gem
57
+ (https://github.com/sferik/twitter) to handle the underlying API
58
+ calls. Any calls to the search/reply methods will return
59
+ `Twitter::Tweet` objects.
60
+
61
+
62
+ Copyright/License
63
+ -----------------
64
+
65
+ Copyright (c) 2014 Colin Mitchell. Chatterbot is distributed under the
66
+ WTFPL license.
67
+
68
+
69
+ http://muffinlabs.com
70
+
@@ -0,0 +1 @@
1
+ console.log('This would be the main JS file.');
@@ -0,0 +1,17 @@
1
+ ---
2
+ layout: page
3
+ title: "Other Tools"
4
+ category: links
5
+ ---
6
+
7
+
8
+ * [twitter_ebooks](https://github.com/mispy/twitter_ebooks) from mispy
9
+ is powering a bunch of ebooks-ish accounts, and other things too.
10
+ * The [twitter gem](https://github.com/sferik/twitter) from sferik is
11
+ great, and is what sits beneath Chatterbot.
12
+ * [t](https://github.com/sferik/t), also by sferik, is a handy
13
+ command-line interface to Twitter.
14
+ * [twitterbot](https://github.com/thricedotted/twitterbot) from thricedotted.
15
+ * [tweepy](https://github.com/tweepy/tweepy).
16
+
17
+
@@ -0,0 +1 @@
1
+ {"name":"Chatterbot","tagline":"A straightforward ruby-based Twitter Bot Framework, using OAuth to authenticate.","body":"### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:\r\n\r\n```\r\n$ cd your_repo_root/repo_name\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `<a>` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."}
@@ -0,0 +1,6 @@
1
+ ---
2
+ layout: page
3
+ title: "rdoc"
4
+ category: links
5
+ link: http://rubydoc.info/gems/chatterbot
6
+ ---
@@ -0,0 +1,84 @@
1
+ ---
2
+ layout: page
3
+ title: "Authorizing Your Bot"
4
+ category: tut
5
+ ---
6
+
7
+ Getting a bot running on Twitter can be a little tricky. Twitter uses
8
+ a something called [OAuth](https://dev.twitter.com/oauth) to validate
9
+ requests, but it's a little more complicated than just specifying a
10
+ username/password.
11
+
12
+ * Login to Twitter with your bot account
13
+
14
+ * Go to https://apps.twitter.com/app/new
15
+
16
+ * Fill out the form. You need to put a name, description, and Website
17
+ URL, although the URL doesn't need to exist. <img
18
+ src="./images/01-create-application.png" />
19
+
20
+
21
+ * Save the form, and then click on the Permissions tab. You will need
22
+ to specify what level of access is needed for your bot. <img
23
+ src="./images/02-application-permissions.png" /> You have three
24
+ choices here: Read only, Read and Write, and Read and Write and
25
+ access DMs. If your bot isn't actually ever going to post to Twitter
26
+ (for example, if you're just running a search to find interesting
27
+ tweets), you can choose read-only. Otherwise, you should pick
28
+ read/write, or read/write/DMs. Chatterbot has limited support for
29
+ handling Direct Messages, but if you can imagine a situation where
30
+ you might want to handle them, you should pick this option.
31
+
32
+ * *NOTE:* When you try and save this form, there's a good chance that
33
+ you will get an error that tells you to add a mobile phone to your Twitter
34
+ profile. It will look a lot like this: <img src="./images/03-mobile-number.png" />
35
+
36
+ You can add your number here: https://twitter.com/settings/devices
37
+
38
+ After you add the number, Twitter will ask you to send them a text
39
+ message. Once you do this, you can finish updating the settings for
40
+ your application. Later, we'll remove the mobile number.
41
+
42
+
43
+ Once you've registered your application, you have two options. You can
44
+ create access tokens for your bot via Twitter, or you can run the
45
+ `chatterbot-register` script. Running the script will take care of
46
+ creating a template file for your bot, but if you don't want to do
47
+ that, here are the steps for doing this manually:
48
+
49
+ * click the 'Keys and Access Tokens' link. You should see this: <img src="./images/04-access-token.png" />
50
+ * click the 'Create my access token' link.
51
+ * It might take a few minutes for Twitter to actually generate the
52
+ token. You can refresh the page a couple times until they are there,
53
+ then you can copy the keys into your application. There's four keys
54
+ you will need for your bot, and a couple different ways to save
55
+ them:
56
+
57
+ **In a separate YAML config file**. Create a file named botname.yaml
58
+ -- the botname part must match your bot's username EXACTLY. Put the
59
+ following contents, pasting the credential values that you just
60
+ generated:
61
+
62
+ ```
63
+ ---
64
+ :consumer_secret: Consumer Secret (API Secret) GOES HERE
65
+ :consumer_key: Consumer Key (API Key) GOES HERE
66
+ :token: Access Token GOES HERE
67
+ :secret: Access Token Secret GOES HERE
68
+ ```
69
+
70
+ **in the script**. Add some lines to your bot script like this:
71
+ ```
72
+ consumer_key 'Consumer Secret (API Secret)'
73
+ consumer_secret 'Consumer Key (API Key)'
74
+ secret 'Access Token Secret'
75
+ token 'Access Token'
76
+ ```
77
+
78
+ **in a database**. If you've setup chatterbot to use a database, you
79
+ can store your configuration info in the **config** table.
80
+
81
+
82
+ **NOTE** At this point, you can remove the phone number from the bot
83
+ account if you like. From your bot's account, click 'Settings' ->
84
+ 'Mobile' -> 'Delete my phone'.
@@ -0,0 +1,98 @@
1
+ ---
2
+ layout: page
3
+ title: "Streaming API"
4
+ category: doc
5
+ ---
6
+
7
+ Chatterbot has basic support for Twitter's [Streaming API](https://dev.twitter.com/streaming/overview). If
8
+ you are an advanced developer, or want to create something very
9
+ involved, it might make more sense to use a different library.
10
+ However, if you do use Chatterbot, you can continue to use the DSL,
11
+ and you get access to a bunch of helpful routines.
12
+
13
+ Here's an example bot using the Streaming API:
14
+
15
+ ```
16
+ #!/usr/bin/env ruby
17
+
18
+ ## This is a very simple working example of a bot using the streaming
19
+ ## API. It's basically a copy of echoes_bot.rb, just using streaming.
20
+
21
+ #
22
+ # require the dsl lib to include all the methods you see below.
23
+ #
24
+ require 'rubygems'
25
+ require 'chatterbot/dsl'
26
+
27
+ consumer_secret 'foo'
28
+ secret 'bar'
29
+ token 'biz'
30
+ consumer_key 'bam'
31
+
32
+
33
+ puts "Loading echoes_bot.rb using the streaming API"
34
+
35
+ exclude "http://", "https://"
36
+
37
+ blacklist "mean_user, private_user"
38
+
39
+ streaming do
40
+ favorited do |user, tweet|
41
+ reply "@#{user.screen_name} thanks for the fave!", tweet
42
+ end
43
+
44
+ followed do |user|
45
+ tweet "@#{user.screen_name} just followed me!"
46
+ follow user
47
+ end
48
+
49
+ replies do |tweet|
50
+ favorite tweet
51
+
52
+ puts "It's a tweet!"
53
+ src = tweet.text.gsub(/@echoes_bot/, "#USER#")
54
+ reply src, tweet
55
+ end
56
+ end
57
+ ```
58
+
59
+ By default, chatterbot will use the
60
+ [user endpoint](https://dev.twitter.com/streaming/userstreams), which
61
+ returns events for the bot -- mentions, follows, etc. If you want to
62
+ perform a search, or use the sample endpoint, you will need to specify
63
+ that:
64
+
65
+
66
+ ```
67
+ #
68
+ # sample the twitter stream
69
+ #
70
+ streaming(endpoint:"sample") do
71
+ sample do |tweet|
72
+ puts tweet.text
73
+ end
74
+ end
75
+ ```
76
+
77
+
78
+ ```
79
+ #
80
+ # run a search
81
+ #
82
+ streaming(endpoint:"search") do
83
+ search("Streaming API") do |tweet|
84
+ puts tweet.text
85
+ end
86
+ end
87
+ ```
88
+
89
+ ```
90
+ #
91
+ # find geocoded tweets
92
+ #
93
+ streaming(endpoint: :filter, locations:"-180,-90,180,90") do
94
+ user do |tweet|
95
+ puts tweet.text
96
+ end
97
+ end
98
+ ```
@@ -0,0 +1,68 @@
1
+ .highlight .c { color: #999988; font-style: italic } /* Comment */
2
+ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
3
+ .highlight .k { font-weight: bold } /* Keyword */
4
+ .highlight .o { font-weight: bold } /* Operator */
5
+ .highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
6
+ .highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
7
+ .highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
8
+ .highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
9
+ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
10
+ .highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
11
+ .highlight .ge { font-style: italic } /* Generic.Emph */
12
+ .highlight .gr { color: #aa0000 } /* Generic.Error */
13
+ .highlight .gh { color: #999999 } /* Generic.Heading */
14
+ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
15
+ .highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
16
+ .highlight .go { color: #888888 } /* Generic.Output */
17
+ .highlight .gp { color: #555555 } /* Generic.Prompt */
18
+ .highlight .gs { font-weight: bold } /* Generic.Strong */
19
+ .highlight .gu { color: #800080; font-weight: bold; } /* Generic.Subheading */
20
+ .highlight .gt { color: #aa0000 } /* Generic.Traceback */
21
+ .highlight .kc { font-weight: bold } /* Keyword.Constant */
22
+ .highlight .kd { font-weight: bold } /* Keyword.Declaration */
23
+ .highlight .kn { font-weight: bold } /* Keyword.Namespace */
24
+ .highlight .kp { font-weight: bold } /* Keyword.Pseudo */
25
+ .highlight .kr { font-weight: bold } /* Keyword.Reserved */
26
+ .highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
27
+ .highlight .m { color: #009999 } /* Literal.Number */
28
+ .highlight .s { color: #d14 } /* Literal.String */
29
+ .highlight .na { color: #008080 } /* Name.Attribute */
30
+ .highlight .nb { color: #0086B3 } /* Name.Builtin */
31
+ .highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
32
+ .highlight .no { color: #008080 } /* Name.Constant */
33
+ .highlight .ni { color: #800080 } /* Name.Entity */
34
+ .highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
35
+ .highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
36
+ .highlight .nn { color: #555555 } /* Name.Namespace */
37
+ .highlight .nt { color: #CBDFFF } /* Name.Tag */
38
+ .highlight .nv { color: #008080 } /* Name.Variable */
39
+ .highlight .ow { font-weight: bold } /* Operator.Word */
40
+ .highlight .w { color: #bbbbbb } /* Text.Whitespace */
41
+ .highlight .mf { color: #009999 } /* Literal.Number.Float */
42
+ .highlight .mh { color: #009999 } /* Literal.Number.Hex */
43
+ .highlight .mi { color: #009999 } /* Literal.Number.Integer */
44
+ .highlight .mo { color: #009999 } /* Literal.Number.Oct */
45
+ .highlight .sb { color: #d14 } /* Literal.String.Backtick */
46
+ .highlight .sc { color: #d14 } /* Literal.String.Char */
47
+ .highlight .sd { color: #d14 } /* Literal.String.Doc */
48
+ .highlight .s2 { color: #d14 } /* Literal.String.Double */
49
+ .highlight .se { color: #d14 } /* Literal.String.Escape */
50
+ .highlight .sh { color: #d14 } /* Literal.String.Heredoc */
51
+ .highlight .si { color: #d14 } /* Literal.String.Interpol */
52
+ .highlight .sx { color: #d14 } /* Literal.String.Other */
53
+ .highlight .sr { color: #009926 } /* Literal.String.Regex */
54
+ .highlight .s1 { color: #d14 } /* Literal.String.Single */
55
+ .highlight .ss { color: #990073 } /* Literal.String.Symbol */
56
+ .highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
57
+ .highlight .vc { color: #008080 } /* Name.Variable.Class */
58
+ .highlight .vg { color: #008080 } /* Name.Variable.Global */
59
+ .highlight .vi { color: #008080 } /* Name.Variable.Instance */
60
+ .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
61
+
62
+ .type-csharp .highlight .k { color: #0000FF }
63
+ .type-csharp .highlight .kt { color: #0000FF }
64
+ .type-csharp .highlight .nf { color: #000000; font-weight: normal }
65
+ .type-csharp .highlight .nc { color: #2B91AF }
66
+ .type-csharp .highlight .nn { color: #000000 }
67
+ .type-csharp .highlight .s { color: #A31515 }
68
+ .type-csharp .highlight .sc { color: #A31515 }