/habitica-gas-template

Template for Google Apps Script interfacing Habitica

Primary LanguageJavaScriptGNU General Public License v3.0GPL-3.0

Google Apps Script template for Habitica

The GAS Template is a broadly usable template to create scripts, that are to be used in connection with Habitica.

It provides users with a simple interface to install, update and deinstall their script - without the need to provide the Web App URL manually or to keep track of the installation status. On the other hand, it provides various helper functions to script authors and takes care of the most common tasks around Habitica webhooks. This also ensures reliable and consistent execution among all scripts using this template, since utility functions aren't implemented again and again, but updated on all scripts as soon a issue arises.

Features

For users:

  • simplified installation procedure
  • visual interface for script maintenance (installation, updating, deinstallation)

For script authors:

  • pre-written section for user options and customizations
  • pre-formed functions for option validation and installation of triggers / webhooks
  • ready-to-use functions for webhook and trigger processing
  • API functions handling caching, rate limiting and error detection
  • numerous utility functions for common actions
  • improved logging capabilities

Installation

The installation instructions are given on the Wiki page.

Usage (as script author)

Assuming you have some experience with scripting within Google Apps Script, the following steps are way less detailed than the instructions for users.

To start authoring your own script based on the GAS Template, the rough steps are as follows:

  • Get a copy of the template
  • Prepare everything for configuration and installation of your script in setup.gs
    • Enter your User ID under AUTHOR_ID and enter the name of your script in SCRIPT_NAME for the X-Client header
    • Add options and customizations to the top of the script - accompanied by corresponding validations in validateOptions()
    • Modify createTriggers and createWebhooks, adding everything your script will need
  • Implement all your functionality in code.gs
    • There is an example function processTrigger(), that may be used for regularly recurring tasks
    • Webhooks are handled by the processWebhook() functions - one for immediate reactions and one for heavy work, that is not time critical

For most applications, this should be more than enough to fulfill all your needs. But feel free to also look under the hood and modify the template, if something special is needed.

Contributions

Users and authors alike can contribute to this template and a hassle-free script experience for everyone:

🐞 Issues If you detect an issue, feel free to raise it
Questions Any questions you have, are welcome
💡 Suggestions I will be happy to discuss your suggestions

Acknowledgement