Class: Chatterbot::Bot

Inherits:
Object
  • Object
show all
Includes:
Blacklist, Client, Config, DB, Favorite, Followers, Helpers, Logging, Profile, Reply, Retweet, Search, Streaming, Tweet, UI, Utils
Defined in:
lib/chatterbot/bot.rb

Overview

primary Bot object, includes all the other modules

Constant Summary

Constants included from Config

Config::MAX_TWEET_ID

Instance Attribute Summary

Attributes included from Client

#client, #screen_name, #search_client, #streaming_client

Attributes included from Config

#config

Attributes included from Blacklist

#blacklist, #exclude

Instance Method Summary collapse

Methods included from Helpers

#botname, #botname=, #from_user, #replace_variables, #tweet_user

Methods included from DB

#db, #display_db_config_notice

Methods included from Client

#base_url, #consumer, #default_opts, #generate_authorize_url, #get_screen_name, #init_client, #login, #request_token, #require_login, #reset!, #reset_client, #reset_since_id, #reset_since_id_reply

Methods included from UI

#display_oauth_error, #get_api_key, #get_oauth_verifier

Methods included from Followers

#follow, #followers

Methods included from Reply

#replies

Methods included from Favorite

#favorite

Methods included from Retweet

#retweet

Methods included from Profile

#profile_text, #profile_website

Methods included from Tweet

#reply, #tweet

Methods included from Search

#exclude_retweets, #search

Methods included from Logging

#critical, #debug, #log

Methods included from Config

#bot_config, #chatterbot_helper?, #client_params, #config_file, #config_to_save, #db_config, #debug_mode=, #debug_mode?, #global_config, #global_config_files, #has_config?, #has_db?, #has_sequel?, #load_config, #log_dest, #log_tweets?, #logging?, #max_id_from, #needs_api_key?, #needs_auth_token?, #no_update=, #reset_bot?, #since_id, #since_id=, #since_id_reply, #since_id_reply=, #slurp_file, #store_database_config, #store_local_config, #update_config, #update_config?, #update_config_at_exit, #update_since_id, #update_since_id_reply, #verbose=, #verbose?, #working_dir

Methods included from Streaming

#authenticated_user, #do_streaming, #handle_streaming_object

Methods included from Blacklist

#add_to_blacklist, #on_blacklist?, #on_global_blacklist?, #skip_me?

Methods included from Utils

#id_from_tweet, #id_from_user

Constructor Details

#initialize(params = {}) ⇒ Bot

Create a new bot. No options for now.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/chatterbot/bot.rb', line 25

def initialize(params={})
  if params.has_key?(:name)
    @botname = params.delete(:name)
  end

  @config = load_config(params)

  if reset_bot?
    reset_since_id
    update_config
    puts "Reset to #{@config[:since_id]}"
    exit
  else
    # update config when we exit
    at_exit do
      raise $! if $!
      update_config_at_exit
    end  
  end
end