Bundled Plugins

Banking

Scriptabit plugin that implements a banking feature. Allows deposits and withdrawals from a custom bank.

If neither a deposit or withdrawal is specified, then the balance is reported but not changed.

Deposits and withdrawals are capped to the amount available, so a simple way to deposit or withdraw all the gold is to specify an amount larger than the balance.

class scriptabit.plugins.banking.Banking[source]

Implements the banking plugin.

__init__()[source]

Initialises the Banking instance.

calculate_fee(amount)[source]

Calculates the fee for a given transaction amount.

Parameters:amount (float) – The transaction amount.
Returns:the transaction fee.
Return type:float
deposit()[source]

Deposit money to the bank.

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

static get_balance_from_string(s)[source]

Gets the bank balance from the formatted string

static get_balance_string(amount)[source]

Gets the formatted bank balance string for a given amount

initialise(configuration, habitica_service, data_dir)[source]

Initialises the banking plugin.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
pay_tax()[source]

Pays taxes, trying first from the main balance, and then from the bank.

static supports_dry_runs()[source]

The Banking plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

Update the banking plugin.

Returns: bool: False

update_bank_balance(new_balance)[source]

Updates the bank balance.

Parameters:new_balance (float) – The new balance.
withdraw()[source]

Withdraw money from the bank.

CSV Bulk Importer

Bulk creation of Habitica tasks from CSV files.

class scriptabit.plugins.csv_tasks.CsvTasks[source]

Scriptabit batch CSV task importer for Habitica

_CsvTasks__fill_tag_placeholders()

Replace tag name placeholders with tag IDs

static _CsvTasks__parse_bool(csv_value)

parse a bool from a string value

static _CsvTasks__parse_enum(enum, name)

Parse an enum, trying both lookup by name and value. Returns the default if neither lookup succeeds.

__init__()[source]

Initialises the plugin. Generally nothing to do here other than initialise any class attributes.

activate()[source]

Called by the plugin framework when a plugin is activated.

deactivate()[source]

Called by the plugin framework when a plugin is deactivated.

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

Note that to avoid argument name conflicts, only long argument names should be used, and they should be prefixed with the plugin-name or unique abbreviation.

Returns: argparse.ArgParser: The ArgParser containing the argument definitions.

initialise(configuration, habitica_service, data_dir)[source]

Initialises the plugin.

Generally, any initialisation should be done here rather than in activate or __init__.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
static supports_dry_runs()[source]

The CSV plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

This update method will be called once on every update cycle, with the frequency determined by the value returned from update_interval_minutes().

If a plugin implements a single-shot function, then update should return False.

Returns: bool: True if further updates are required; False if the plugin is finished and the application should shut down.

Health Effects

Scriptabit plugin that implements various health-modification effects.

class scriptabit.plugins.health_effects.HealthEffects[source]

Implements the health effects plugin.

__init__()[source]

Initialises the plugin.

apply_health_delta(hp24=None, up=True)[source]

Applies the health delta.

Parameters:
  • hp24 (float) – The health change per 24 hours.
  • up (bool) – If True, then health is increased, otherwise health is decreased.
Returns:

the signed health delta that was applied.

Return type:

float

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

get_health_delta(hp24=None)[source]

Gets the health delta for the current update

initialise(configuration, habitica_service, data_dir)[source]

Initialises the plugin.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
logistic_growth(x, a=50, b=0.5, k_x_positive=0.2, k_x_negative=4.8)[source]

Returns the logistic growth function value for a given input x.

y = a / (1 + b * e^(kx))

For k > 0, larger values give a greater rate of change while smaller values lead to a slower approach to the function asymptotes.

For positive k, the return values is bounded by a to the left (large negative x) and by 0 to the right (large positive x). For negative k this is reversed.

Additionally, this method allows different k terms for positive and negative x, which allows finer-grained tuning of the output.

The y-intercept is given by a / (1 + b).

Parameters:
  • x (float) – The input value
  • a (float) – The upper limit on the function value.
  • b (float) – Influences the steepness of the function curve, and also contributes to the y-intercept. High values give a slower change and a lower y-intercept.
  • k_x_positive (float) – The k term used when x >= 0
  • k_x_negative (float) – The k term used when x < 0. Passing None will cause k_x_positive to be used for all x.
Returns:

The delta.

Return type:

float

poisoned()[source]

Simple health drain/poisoning

regenerating()[source]

Simple health regeneration

summarise_task_performance(tasks, window_hours=24)[source]

Summarises overall task performance within a time window back from the current time.

Parameters:
  • tasks (list) – The list of Habitica tasks to summarise.
  • window_hours (float) – Size of the time window in hours

Returns:

summarise_task_score(task, now, window)[source]

Summarises the task score changes within a time window.

Parameters:
  • task (dict) – The task.
  • now (datetime) – The most recent time to consider.
  • window (timedelta) – The time window to consider prior to now.
Returns:

Total of the score changes within the time window. int: Number of times the score went up. int: Number of times the score went down.

Return type:

float

static supports_dry_runs()[source]

The HealthEffects plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

Update the health effects plugin.

Returns: bool: True if further updates are required; False if the plugin is finished and the application should shut down.

vampire()[source]

Vampire mode.

Lose health during daylight hours. Gain small amounts of health at night, and large amounts by feeding.

Pet Care

Habitica pet care.

Options for batch hatching and feeding pets.

class scriptabit.plugins.pet_care.PetCare[source]

Habitica pet care

__init__()[source]

Initialises the plugin.

consume_food(food)[source]

Consumes a food, updating the cached quantity.

Parameters:food (str) – The food.
feed_pets()[source]

Feeds all current pets.

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

Returns: argparse.ArgParser: The ArgParser containing the argument definitions.

get_eggs(base=True, quest=False)[source]

Gets the filtered dictionary of available eggs. Values indicate current quantity.

Parameters:
  • base (bool) – Includes or excludes standard eggs.
  • eggs (bool) – Includes or excludes quest eggs.
Returns:

The dictionary of eggs and quantities.

Return type:

dict

get_food_for_pet(pet)[source]

Gets a food item for a pet

Parameters:pet (str) – The composite pet name (animal-potion)
Returns:
The name of a suitable food if that food is in stock.
If no suitable food is available, then None is returned.
Return type:str
get_hatching_potions(base=True, magic=False)[source]

Gets the filtered dictionary of available hatching potions. Values indicate current quantity.

Parameters:
  • base (bool) – Includes or excludes standard potions.
  • magic (bool) – Includes or excludes magic potions.
Returns:

The dictionary of potions and quantities.

Return type:

dict

get_pets(base=True, magic=False, quest=False, rare=False, feedable_only=False)[source]

Gets a filtered list of current user pets.

Parameters:
  • base (bool) – Includes or excludes base pets.
  • magic (bool) – Includes or excludes magic pets.
  • quest (bool) – Includes or excludes quest pets.
  • rare (bool) – Includes or excludes rare pets.
  • feedable_only (bool) – If true, only feedable pets are included. Pets where a matching mount exists are not feedable.
Returns:

the filtered pet list.

Return type:

list

has_any_food()[source]

Checks whether any food is left.

Returns:True if some food remains, otherwise False.
Return type:bool
has_food(food)[source]

Returns True if the food is in stock, otherwise False.

Parameters:food (str) – The food to check
Returns:True if the food is in stock, otherwise False.
Return type:bool
hatch_pets()[source]

Hatch all available pets.

initialise(configuration, habitica_service, data_dir)[source]

Initialises the plugin.

Generally, any initialisation should be done here rather than in activate or __init__.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
is_base_pet(pet)[source]

Is this a base pet?

Parameters:pet (str) – The full pet name.
is_magic_pet(pet)[source]

Is this a magic pet?

Parameters:pet (str) – The full pet name.
is_magic_potion(potion)[source]

Is this a magic potion?

In the current API, any potion not in the core list of standard potions is a magic potion.

Parameters:potion (str) – The potion name.
is_quest_egg(egg)[source]

Is this a quest egg?

In the current API, magic and base pets share the same core set of eggs, so anything not in that list is assumed to be a quest egg.

Parameters:egg (str) – The egg name.
is_quest_pet(pet)[source]

Is this a quest pet?

Parameters:pet (str) – The full pet name.
is_rare_pet(pet)[source]

Is this a rare pet?

Parameters:pet (str) – The full pet name.
static list_pet_items(items)[source]

Lists all pet-related inventory items.

Parameters:items (dict) – The Habitica user.items dictionary.
notify(message, **kwargs)[source]

Notify the Habitica user.

If this is a dry run, then the message is logged. Otherwise the message is logged and posted to the Habitica notification panel.

Parameters:
  • message (str) – The message.
  • panel (bool) – If True, the Habitica panel is updated.
static supports_dry_runs()[source]

The PetCare plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

This update method will be called once on every update cycle, with the frequency determined by the value returned from update_interval_minutes().

If a plugin implements a single-shot function, then update should return False.

Returns: bool: True if further updates are required; False if the plugin is finished and the application should shut down.

update_interval_minutes()[source]

Indicates the required update interval in minutes.

Returns: float: The required update interval in minutes.

Sample

A sample plugin. Doesn’t do anything, but it makes a good template for new plugins. Unused methods can be deleted.

class scriptabit.plugins.sample.Sample[source]

Scriptabit sample plugin.

__init__()[source]

Initialises the plugin. Generally nothing to do here other than initialise any class attributes.

activate()[source]

Called by the plugin framework when a plugin is activated.

deactivate()[source]

Called by the plugin framework when a plugin is deactivated.

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

Note that to avoid argument name conflicts, only long argument names should be used, and they should be prefixed with the plugin-name or unique abbreviation.

Returns: argparse.ArgParser: The ArgParser containing the argument definitions.

initialise(configuration, habitica_service, data_dir)[source]

Initialises the plugin.

Generally, any initialisation should be done here rather than in activate or __init__.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
static supports_dry_runs()[source]

The Sample plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

This update method will be called once on every update cycle, with the frequency determined by the value returned from update_interval_minutes().

If a plugin implements a single-shot function, then update should return False.

Returns: bool: True if further updates are required; False if the plugin is finished and the application should shut down.

update_interval_minutes()[source]

Indicates the required update interval in minutes.

Returns: float: The required update interval in minutes.

Trello

Synchronisation of Trello cards to Habitica To-Dos.

class scriptabit.plugins.trello.trello.Trello[source]

Trello card synchronisation.

__tc

TrelloClient instance

__habitica_task_service

The HabiticaTaskService instance

__task_map_file

= Task mapping data file

__data_file

Sync data file name

__data

Trello.PersistentData – Persistent sync data

class PersistentData(filename=None)[source]

Data that needs to be persisted.

__init__(filename=None)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

save(filename)[source]

Saves the persistent data

_Trello__ensure_labels_exist(boards)

Ensures that the Trello labels used to mark task difficulty and Habitica character attributes exist.

Parameters:boards (list) – The list of boards that are being synchronised.
static _Trello__load_authentication_credentials(config_file_name=u'.auth.cfg', section=u'trello')

Loads authentication credentials from an ini-style configuration file.

Parameters:
  • config_file_name (str) – Basename of the configuration file.
  • section (str) – Configuration file section name.

Returns: dict: the selected credentials

_Trello__load_persistent_data()

Loads the persistent data

_Trello__notify(sync_stats)

notify the user about the sync stats.

Parameters:sync_stats (TaskSync.Stats) – Stats from the last sync.
_Trello__parse_board_configuration()

Parses the board configuration from the command line arguments

_Trello__save_persistent_data()

Saves the persistent data

__init__()[source]

Initialises the plugin. Generally nothing to do here other than initialise any class attributes.

get_arg_parser()[source]

Gets the argument parser containing any CLI arguments for the plugin.

Note that to avoid argument name conflicts, only long argument names should be used, and they should be prefixed with the plugin-name or unique abbreviation.

Returns: argparse.ArgParser: The ArgParser containing the argument definitions.

initialise(configuration, habitica_service, data_dir)[source]

Initialises the Trello plugin.

This involves loading the board and list configuration, confirming the API key and secret, obtaining the OAuth tokens if required, and instantiating the TrelloClient instance.

Parameters:
  • configuration (ArgParse.Namespace) – The application configuration.
  • habitica_service (scriptabit.HabiticaService) – the Habitica Service instance.
  • data_dir (str) – A writeable directory that the plugin can use for persistent data.
static supports_dry_runs()[source]

The Trello plugin supports dry runs.

Returns:True
Return type:bool
update()[source]

This update method will be called once on every update cycle, with the frequency determined by the value returned from update_interval_minutes().

If a plugin implements a single-shot function, then update should return False.

Returns: bool: True if further updates are required; False if the plugin is finished and the application should shut down.

update_interval_minutes()[source]

Indicates the required update interval in minutes.

Returns: float: The required update interval in minutes.