README.markdown in chatterbot-0.4.0 vs README.markdown in chatterbot-0.5.0

- old
+ new

@@ -34,11 +34,11 @@ Write your bot -------------- Chatterbot has a very simple DSL inspired by Sinatra and Twibot, an -earlier Twitter bot framework. Here's an example, based on +earlier Twitter bot framework. Here's an example, based on [@dr_rumack](http://twitter.com/#!/Dr_Rumack), an actual bot running on Twitter: require 'chatterbot/dsl' search("'surely you must be joking'") do |tweet| @@ -58,11 +58,11 @@ ------------- If you only want to use Chatterbot to search for tweets, it will work out of the box without any authorization. However, if you want to reply to tweets, or check for replies to your bot, you will have to -jump through a few authorization hoops with Twitter. +jump through a few authorization hoops with Twitter. Before you setup a bot for the first time, you will need to register an application with Twitter. Twitter requires all API communication to be via an app which is registered on Twitter. I would set one up and make it part of Chatterbot, but unfortunately Twitter doesn't allow developers @@ -76,15 +76,13 @@ process the first time you run your script. But if you prefer, here's the instructions if you want to do it yourself: 1. [Setup your own app](https://twitter.com/apps/new) on Twitter. -2. Choose 'Client' as the app type. +2. Put in whatever name, description, and website you want. -3. Choose 'Read & Write' access unless you don't need to send tweets. - -4. Take the consumer key/consumer secret values, and either run your bot, and enter them +3. Take the consumer key/consumer secret values, and either run your bot, and enter them in when prompted, or store them in a config file for your bot. (See below for details on this). It should look like this: --- :consumer_secret: CONSUMER SECRET GOES HERE @@ -139,16 +137,43 @@ */2 * * * * . ~/.bash_profile; cd /path/to/bot/; ./bot.rb Run it as a background process. Just put the guts of your bot in a loop like this: - loop do - replies do |tweet| - # do stuff - end +```rb +loop do + search "twitter" do |tweet| + # here you could do something with a tweet + # if you want to retweet + retweet(tweet[:id]) + end - sleep 60 - end + replies do |tweet| + # do stuff + end + + # explicitly update our config + update_config + + sleep 60 +end +``` + +**NOTE:** You need to call `update_config` to update the last tweet your script +has processed -- if you don't have this call, you will get duplicate +tweets. + +Retweet +------- + +Chatterbot can retweet the tweets found based upon the search: + +```rb + search "xyzzy" do |tweet| + retweet(tweet[:id]) + end +``` + Database logging ---------------- Chatterbot can log tweet activity to the database if desired. This