lib/chatterbot/dsl.rb in chatterbot-0.9.2 vs lib/chatterbot/dsl.rb in chatterbot-0.9.3
- old
+ new
@@ -12,20 +12,40 @@
end
#
# search twitter for the specified terms, then pass any matches to
# the block.
+ # @param opts [Hash] options. these will be passed directly to
+ # Twitter via the twitter gem. You can see the possible arguments
+ # at http://www.rubydoc.info/gems/twitter/Twitter/REST/Search#search-instance_method
+ # There is one extra argument:
+ # @option options [Integer] :limit limit the number of tweets to
+ # return per search
+
# @example
# search("chatterbot is cool!") do |tweet|
# puts tweet.text # this is the actual tweeted text
# reply "I agree!", tweet
# end
def search(query, opts = {}, &block)
bot.search(query, opts, &block)
end
#
+ # handle tweets that are on the bot's home timeline. this includes
+ # tweets from accounts the bot is following, as well as its own tweets
+ #
+ # @example
+ # home_timeline do |tweet|
+ # puts tweet.text # this is the actual tweeted text
+ # favorite tweet # i like to fave tweets
+ # end
+ def home_timeline(opts = {}, &block)
+ bot.home_timeline(opts, &block)
+ end
+
+ #
# handle replies to the bot. Each time this is called, chatterbot
# will pass any replies since the last call to the specified block
#
# @example
# replies do |tweet|
@@ -85,17 +105,25 @@
# @param [Tweet] source the original tweet you are replying to
def reply(txt, source)
bot.reply(txt, source)
end
+ #
+ # handle getting/setting the profile text.
+ # @param [p] p The new value for the profile. If this isn't passed in, the method will simply return the current value
+ # @return profile text
def profile_text(p=nil)
if p.nil?
bot.profile_text
else
bot.profile_text(p)
end
end
+ #
+ # handle getting/setting the profile website
+ # @param [p] p The new value for the website. If this isn't passed in, the method will simply return the current value
+ # @return profile website
def profile_website(w=nil)
if w.nil?
bot.profile_website
else
bot.profile_website(w)