GithubHelp home page GithubHelp logo

scriptabit's Introduction

Readme

Python scripting and scenarios for Habitica.

Travis CI

Documentation Status

Apache 2.0 License

PyPI

image

Note You can use the Github issues for bugs and feature requests, however most task and feature planning is carried out in a private Trello board. Access can be provided on request.

Installation

To install the latest release from PyPI:

pip install scriptabit

If you already have scriptabit installed, then upgrade with:

pip install --upgrade scriptabit

Habitica Credentials

You require an authentication credentials file in your home directory containing your Habitica API Key and User ID. The file should have a typical ini file structure, with the following section:

[habitica]
userid =
apikey =

Additional sections can be added, and the section name to use can be supplied as a command-line argument.

If you do not already have a .auth.cfg file, a default will be created when you first run scriptabit. You can then fill in your account values.

Once you have entered your Habitica credentials, test them with the -sud command (short for --show-user-data):

scriptabit -sud

If everything is set up correctly, you should see a summary of your character data printed to the console.

Note that your API key is effectively a password to your Habitica account. You should make sure the .auth.cfg file is protected, and never share the key with others. On Linux and related systems, you can set the permissions as follows:

chmod 600 .auth.cfg

Trello Credentials

If you wish to use the Trello plugin, you will need to add your Trello credentials to the .auth.cfg file as follows:

[trello]
apikey =
apisecret =
token =
tokensecret =

Your API key and API secret can be obtained here.

Your authorisation token and token secret will be obtained through an interactive process when you first run the trello plugin. You must first save your API key and API secret to the .auth.cfg file before you will be able to obtain the token and tokensecret.

Usage

scriptabit is a command-line application. Help on the available commands can be obtained by running:

$ scriptabit --help

Operations include:

  • `-sud`: Show user data.
  • `-hp n`: Set the user health to n
  • `-mp n`: Set the user's mana points to n
  • `-xp n`: Set experience points to n
  • `-gp n`: Set gold to n
  • `-ls`: List available plugins.

After running scriptabit at least once, configuration files will be created in ~/.config/scriptabit/. These can be edited to change the default options. You can revert to the installation defaults by deleting the files (they will be recreated on the next run).

See the detailed-usage section for detailed instructions on specific functionality.

Finally, most of the built-in plugins define a convenience command-line application name:

  • sb-banking is a shortcut for scriptabit --run banking
  • sb-csv is a shortcut for scriptabit --run csv_tasks
  • sb-health is a shortcut for scriptabit --run health_effects
  • sb-pets is a shortcut for scriptabit --run pet_care
  • sb-trello is a shortcut for scriptabit --run trello
  • sb-tasks is a shortcut for scriptabit --run tasks

When using the shortcuts, all other command-line arguments are the same as when running scriptabit.

Notification Panel

By default, most scriptabit operations update a scoreless habit in Habitica with some status information. This can be useful when you have some functions running in an update loop.

The use of this panel can be controlled with the use-notification-panel argument, either on the command line or by setting a value into the scriptabit.cfg file. Set to 0 or False to suppress the panel.

Habitica Tags

By default, scriptabit applies the scriptabit tag to all the tasks it creates in Habitica. This behaviour can be controlled with the --tags option. It accepts a comma-separated list of tags.

To disable the use of tags, set the option to an empty string: --tags ""

Writing Plugins

User plugins should be placed into the scriptabit_plugins directory. This will be created in your home directory the first time scriptabit runs. Due to an initialisation order issue, this directory location cannot be specified on the command line (the plugin directory needs to be located before processing command line arguments so that plugins get a chance to add additional arguments). If the SCRIPTABIT_USER_PLUGIN_DIR environment variable is defined, then this location will be used instead of the default location.

Note that plugin data files may also be written to the user plugin directory

All plugins should subclass the IPlugin class. Refer to the API documentation for details of the available methods.

Also refer to the API documentation (and the view source option) for the sample plugin which can be used as a template for new plugins.

scriptabit's People

Contributors

dc23 avatar nightscape avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

scriptabit's Issues

Feeding pets doesn't work anymore

I have a cronjob, which triggers the following command every day:

sb-pets --feed-pets --quest-pets --magic-pets --tags '' --use-notification-panel 0

But checking my inventory on Habitica after some weeks/months, I found out, that I have a lot of food there. So I thought the last update did something with pet care and checked the output of the command.

The command gives the following error:

is_magic_pet() takes 2 positional arguments but 4 were given

no-raise option still doesn't work

`sb-pets --feed-pets --no-raise :(
scriptabit version 2.0.1
verbose mode: False
Loading credentials from /home/william/.auth.cfg
Habitica API at 'https://habitica.com/api/v3/' is up
** pet_care running

Scriptabit Pet Care Services: looking after your pets since yesterday
pet_care update 0 @ Tue Feb 7 22:36:28 2017
PandaCub-Golden (10): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (15): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (20): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (25): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (30): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (35): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (40): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (45): Bébé panda Doré•e apprécie vraiment le/la Miel !
PandaCub-Golden (-1): Vous avez dompté Bébé panda Doré•e, allez faire un tour !
🐲 Checked 4 pets, fed 9 pieces of food, raised 1 mounts
tags: ['scriptabit']

** pet_care done`

It was supposed to not get raised, right ?

Hi, I'm new to Github but I want to suggest a possible application for this code

Hi, I'm a Habitica user and looking for a way to implement possible subclasses in the game.
I came across this website and find a possible way to implement subclasses using a script which changes character values.

https://habitica.com/challenges/df9d2e11-8a7b-4c01-82d1-a280c7165162

I tried Scriptabit and It's possible to make a change on character values, can we make a reward that fulfills one of the possible subclasses changes explained on the link?
Is it possible to implement it in an integration?

Sorry if I mess up a bit, this is my first approach to Github and API's programming.
By the way thanks for the code It works fine.

Regards

Make the task tags configurable

Currently, most tasks created by scriptabit are tagged with 'scriptabit' (and sometime other tags as well depending on the plugin).

The use of tags should be configurable, with a program option accepting a comma separated list of tags to apply. The empty string should cause no tags to be applied.

The default value should retain the current behavior.

Banking doesn't seem to work anymore

python3 /home/user/.local/bin/sb-banking -d 1000

scriptabit version 2.1.2
verbose mode: False
Loading credentials from /home/user/.auth.cfg
Habitica API at 'https://habitica.com/api/v3/' is up
** banking running

banking update 0 @ Sat Feb 12 20:47:12 2022
Plugin Update failed
400 Client Error: Bad Request for url: https://habitica.com/api/v3/tasks/ef5141f1-2df2-4260-aec2-9ee56672a868
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.10/site-packages/scriptabit/scriptabit.py", line 292, in run_scriptabit
    updating = plugin.update()
  File "/home/user/.local/lib/python3.10/site-packages/scriptabit/plugins/banking.py", line 202, in update
    self.deposit()
  File "/home/user/.local/lib/python3.10/site-packages/scriptabit/plugins/banking.py", line 258, in deposit
    self.update_bank_balance(self.__bank_balance + nett_amount)
  File "/home/user/.local/lib/python3.10/site-packages/scriptabit/plugins/banking.py", line 321, in update_bank_balance
    self._hs.upsert_task(self.__bank)
  File "/home/user/.local/lib/python3.10/site-packages/scriptabit/habitica_service.py", line 331, in upsert_task
    response.raise_for_status()
  File "/usr/lib/python3.10/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://habitica.com/api/v3/tasks/ef5141f1-2df2-4260-aec2-9ee56672a868
Sleeping for 5.000000 minutes

But also

python2 /home/user/.local/bin/sb-banking -d 1000
Traceback (most recent call last):
  File "/home/user/.local/bin/sb-banking", line 15, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

It's a shame, I really wanted to use this again. Maybe I'm missing something...

Issues with new special potions: Bad Request

scriptabit gives me bad request for new special potions trying to hatch a sheep.

command:
sb-pets --hatch-pets --quest-pets --magic-pets --tags ''

output:

scriptabit version 2.0.2
verbose mode: False
Loading credentials from /home/maxmoon/.auth.cfg
Habitica API at 'https://habitica.com/api/v3/' is up
** pet_care running

Scriptabit Pet Care Services: looking after your pets since yesterday
pet_care update 0 @ Fri Feb  9 18:07:47 2018
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Thunderstorm
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Holly
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Peppermint
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Cupid
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Aquatic
400 Client Error: Bad Request for url: https://habitica.com/api/v3/user/hatch/Sheep/Ember
:dragon: Hatched 0 new pets
tags:  []

** pet_care done
Exiting

sb-pets does not hatch all kinds of eggs

  • scriptabit version 1.16.0

sb-pets --hatch-pets says:

"Hatched 0 new pets"

But there are hatchable eggs in the inventory, like rooster, spider, tyrannosaur and whale eggs. Maybe those are just too new.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.