Class: Elephrame::Bots::TraceryBot
- Defined in:
- lib/elephrame/mix/bots.rb
Overview
a bot that posts things on an interval but can also respond to interactions, providing a grammer object and a few helper methods to easily create bots with tracery.
set on_reply before running, otherwise the bot won’t react to mentions
Constant Summary
Constants inherited from BaseBot
Instance Attribute Summary
Attributes included from Trace
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, *dirs) ⇒ Elephrame::Bots::TraceryBot
constructor
create a new TraceryBot.
-
#run ⇒ Object
Runs the bot.
Methods included from Trace
#expand_and_post, #setup_tracery
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, *dirs) ⇒ Elephrame::Bots::TraceryBot
create a new TraceryBot
70 71 72 73 74 75 76 77 |
# File 'lib/elephrame/mix/bots.rb', line 70 def initialize interval, *dirs super() # set up our bot stuff setup_scheduler interval setup_streaming setup_tracery dirs end |
Instance Method Details
#run ⇒ Object
Runs the bot. requires a block for periodic post logic, but relies on on_* functions for interaction logic. See Elephrame::AllInteractions for more details.
84 85 86 87 88 89 90 91 |
# File 'lib/elephrame/mix/bots.rb', line 84 def run run_scheduled &Proc.new # if we have any logic for on_reply, we run that # otherwise we go past it and wait for our scheduler to finish run_reply unless @on_reply.nil? @scheduler.join end |