lib/chatterbot/dsl.rb in chatterbot-0.7.0 vs lib/chatterbot/dsl.rb in chatterbot-0.7.1

- old
+ new

@@ -3,11 +3,14 @@ module Chatterbot # # very basic DSL to handle the common stuff you would want to do with a bot. module DSL - + def client + bot.client + end + # # search twitter for the specified terms, then pass any matches to # the block. # @example # search("chatterbot is cool!") do |tweet| @@ -82,10 +85,11 @@ opts.on('-c', '--config [ARG]', "Specify a config file to use") { |c| ENV["chatterbot_config"] = c } opts.on('-t', '--test', "Run the bot without actually sending any tweets") { params[:debug_mode] = true } opts.on('-v', '--verbose', "verbose output to stdout") { params[:verbose] = true } opts.on('--dry-run', "Run the bot in test mode, and also don't update the database") { params[:debug_mode] = true ; params[:no_update] = true } opts.on('-s', '--since_id [ARG]', "Check for tweets since tweet id #[ARG]") { |s| params[:since_id] = s.to_i } + opts.on('-m', '--since_id_reply [ARG]', "Check for mentions since tweet id #[ARG]") { |s| params[:since_id_reply] = s.to_i } opts.on('-r', '--reset', "Reset your bot to ignore old tweets") { params[:debug_mode] = true params[:reset_since_id] = true } @@ -143,10 +147,15 @@ else bot.blacklist += list end end + # + # return a list of users following the bot. This passes directly + # to the underlying Twitter API call + # @see http://rdoc.info/gems/twitter/Twitter/API/FriendsAndFollowers#followers-instance_method + # def followers(opts={}) bot.followers(opts) end # @@ -169,11 +178,14 @@ # # The ID of the most recent tweet processed by the bot # - def since_id + def since_id(s=nil) + if s + bot.config[:since_id] = s + end bot.config[:since_id] end def consumer_secret(s) bot.config[:consumer_secret] = s @@ -187,10 +199,14 @@ bot.config[:secret] = s end def token(s) bot.config[:token] = s end - + + def since_id_reply + bot.config[:since_id_reply] + end + # # explicitly save the configuration/state of the bot. # def update_config bot.update_config