anybot package

Submodules

anybot.action module

class anybot.action.Action(only_during_daylight=False)[source]

Bases: object

Continuous Action that executes in steps over time

begin(api)[source]
cancel()[source]
day_begins_at = 7
day_ends_at = 24
done = False
end(api)[source]
random_interval = 0
restart()[source]
run(api)[source]
step(api)[source]
class anybot.action.CandidateActions(action, per_hour=30, min_candidates=100)[source]

Bases: anybot.action.QueuedActions

before_update(api)[source]
begin(api)[source]
create_gen(api)[source]
get_score(api, candidate)[source]
update(api)[source]
class anybot.action.QueuedActions(per_interval=30, interval=3600, **kwargs)[source]

Bases: anybot.action.Action

Action that can queue commands and then execute them sequentially at a rate of ‘per_interval’ commands in the time ‘interval’. :param per_interval: number of actions to execute in one interval :param interval: time in seconds for interval

add(action, *args)[source]

Add an action onto the queue to be executed later :param action: :param args:

step(api)[source]
update(api)[source]

anybot.bot module

class anybot.bot.Bot(api, actions=())[source]

Bases: object

add_action(action)[source]

Add an Action to the queue of actions. This does not start the action, it only creates a Thread ready to execute it. :param action: function or instance of Action :return:

close(block=True)[source]

Stop and remove all currently running actions :param block: Whether to wait for actions to be stopped

remove_action(_id)[source]

Remove an Action from the queue of actions. Once this is done the Bot cannot restart the action. :param _id:

run(threaded=False)[source]

Run the Bot, executing all actions, even ones added in the future :param threaded: Whether to block or defer the main loop to a Thread

running

Is the bot running and available to submit Actions :return: boolean: running

start()[source]

Start all the actions currently in the queue

start_action(_id)[source]

Run an action :param _id:

stop()[source]

Set stop flag to kill all running actions

stop_action(_id, block=True)[source]

Stop a currently running action :param _id: :param block:

wait(_id)[source]

Wait for an Action to finish executing :param _id: :return:

anybot.cli module

Console script for anybot.

anybot.utils module

anybot.utils.ensure_time(wait)[source]

Ensure the executed code takes at least ‘wait’ seconds to complete :param wait: max number of seconds to wait after execution

anybot.utils.only_daylight_hours(wakeup_at=7, sleep_at=24, random_add=0)[source]

Only execute code during the day (mimics a human sleep cycle) :param wakeup_at: hour to begin executing :param sleep_at: hour to stop executing :param random_add: interval for random wait after expected time

anybot.utils.random_intervals(n, total_time)[source]

Generator of n random values (each approximately total_time/n) where the sum of the values is exactly total_time :param n: :param total_time: :return:

anybot.utils.random_intervals_generator(n, total_time)[source]

Generator that yields new random intervals forever :param n: :param total_time: :return:

Module contents

Top-level package for Anybot API Automation.

class anybot.Bot(api, actions=())[source]

Bases: object

add_action(action)[source]

Add an Action to the queue of actions. This does not start the action, it only creates a Thread ready to execute it. :param action: function or instance of Action :return:

close(block=True)[source]

Stop and remove all currently running actions :param block: Whether to wait for actions to be stopped

remove_action(_id)[source]

Remove an Action from the queue of actions. Once this is done the Bot cannot restart the action. :param _id:

run(threaded=False)[source]

Run the Bot, executing all actions, even ones added in the future :param threaded: Whether to block or defer the main loop to a Thread

running

Is the bot running and available to submit Actions :return: boolean: running

start()[source]

Start all the actions currently in the queue

start_action(_id)[source]

Run an action :param _id:

stop()[source]

Set stop flag to kill all running actions

stop_action(_id, block=True)[source]

Stop a currently running action :param _id: :param block:

wait(_id)[source]

Wait for an Action to finish executing :param _id: :return:

class anybot.Action(only_during_daylight=False)[source]

Bases: object

Continuous Action that executes in steps over time

begin(api)[source]
cancel()[source]
day_begins_at = 7
day_ends_at = 24
done = False
end(api)[source]
random_interval = 0
restart()[source]
run(api)[source]
step(api)[source]
class anybot.QueuedActions(per_interval=30, interval=3600, **kwargs)[source]

Bases: anybot.action.Action

Action that can queue commands and then execute them sequentially at a rate of ‘per_interval’ commands in the time ‘interval’. :param per_interval: number of actions to execute in one interval :param interval: time in seconds for interval

add(action, *args)[source]

Add an action onto the queue to be executed later :param action: :param args:

step(api)[source]
update(api)[source]
class anybot.CandidateActions(action, per_hour=30, min_candidates=100)[source]

Bases: anybot.action.QueuedActions

before_update(api)[source]
begin(api)[source]
create_gen(api)[source]
get_score(api, candidate)[source]
update(api)[source]