Class: Elephrame::Bots::MarkovBot
- Inherits:
-
GenerativeBot
- Object
- BaseBot
- GenerativeBot
- Elephrame::Bots::MarkovBot
- Defined in:
- lib/elephrame/mix/bots.rb
Overview
A more general purpose markov bot. Reads in data from a supplied source
Constant Summary
Constants inherited from GenerativeBot
GenerativeBot::SavedFileName, GenerativeBot::SavedFilterFileName
Constants inherited from BaseBot
BaseBot::FNGabLink, BaseBot::NoBotRegex
Instance Attribute Summary
Attributes inherited from GenerativeBot
#char_limit, #cw, #filter, #filter_by, #filter_filename, #filter_words, #following, #model, #model_filename, #model_hash, #retry_limit, #visibility
Attributes included from Command
#cmd_hash, #cmd_regex, #commands, #not_found, #prefix
Attributes included from Reply
Attributes included from Scheduler
Attributes included from Streaming
Attributes inherited from BaseBot
#client, #failed, #max_retries, #strip_html, #username
Instance Method Summary collapse
-
#initialize(interval, *sources, **options) ⇒ MarkovBot
constructor
Creates a new Ebooks bot.
Methods inherited from GenerativeBot
#add_filter_word, #add_privileged_command, #default_help, #filter_and_post, #load_file, #run, #save_file
Methods included from Command
#add_command, #if_not_found, #run_commands, #set_help, #set_prefix, #setup_command
Methods included from Reply
#reply, #reply_with_mentions, #run_reply
Methods included from Scheduler
#run_scheduled, #setup_scheduler
Methods included from Streaming
Methods inherited from BaseBot
backup_method, #fetch_account_id, #fetch_list_id, #find_ancestor, #no_bot?, #post
Constructor Details
#initialize(interval, *sources, **options) ⇒ MarkovBot
Creates a new Ebooks bot
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
# File 'lib/elephrame/mix/bots.rb', line 357 def initialize(interval, *sources, **) super(interval, ) raise 'no sources provided!' if sources.empty? # initialize the model to contain the specified source text if @model_hash[:model].tokens.empty? sources.each do |source| if Dir.exists? source Dir.open source do |file| next if file =~ /^\.\.?$/ read_and_consume "#{source}/#{file}" end elsif File.exists? source read_and_consume source else raise "source #{source} could not be loaded" end end save_file(@model_filename, @model_hash[:model].to_hash.to_yaml) end end |