Skip to content

Instantly share code, notes, and snippets.

View bumbleshoot's full-sized avatar

Bumbleshoot bumbleshoot

View GitHub Profile
@bumbleshoot
bumbleshoot / webhook-contents_leveledUp_quest-completed.json
Last active May 13, 2023 21:47
Webhook Contents: leveledUp (quest completed)
{
"type": "leveledUp",
"initialLvl": 51,
"finalLvl": 52,
"webhookType": "userActivity",
"user": {
"_id": "3cf895d2-7939-4446-bfb7-8ef8dfe1ec70"
}
}
@bumbleshoot
bumbleshoot / fetch.gs
Last active May 13, 2023 21:49
Calling the Habitica API in Google Apps Script
const USER_ID = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const API_TOKEN = "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
const PARAMS = {
"headers": {
"x-api-user": USER_ID,
"x-api-key": API_TOKEN,
"x-client": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx-ScriptName"
},
"muteHttpExceptions": true
@bumbleshoot
bumbleshoot / temporaryTrigger.gs
Last active May 13, 2023 21:48
Temporary Trigger in Google Apps Script
let scriptProperties = PropertiesService.getScriptProperties();
/**
* doPost(e)
*
* This function is called by webhooks. Stores webhook data in
* a script property and creates a temporary trigger that will
* run in the next ~5 mins or so to process the webhook. This
* is necessary if a Google Apps Script might run longer than
* 30s, because there's no way to send a response in GAS besides
@bumbleshoot
bumbleshoot / logToSpreadsheet.gs
Last active May 13, 2023 21:48
Logging to a Spreadsheet in Google Apps Script
const LOG_SCRIPT_OUTPUT = true;
const LOG_SPREADSHEET_URL = "https://docs.google.com/spreadsheets/d/15tnycb0m9i2ypy_VWvB1XtHKz5jWOnLEotukHYECLL0";
const LOG_SPREADSHEET_TAB_NAME = "Sheet1";
const LOG_SPREADSHEET_MAX_ROWS = 2000; // if too many rows, spreadsheet cannot fit in RAM and will crash
/**
* log(output)
*
* Logs output to the console and, if LOG_SCRIPT_OUTPUT is true, to the
* spreadsheet. Replace all instances of console.log() with log() in your
@bumbleshoot
bumbleshoot / webhook-contents_taskScored.json
Last active May 13, 2023 21:48
Webhook Contents: taskScored
{
"type": "scored",
"direction": "up",
"delta": 0.5798096619915684,
"task": {
"repeat": {
"m": true,
"t": true,
"w": true,
"th": true,
@bumbleshoot
bumbleshoot / webhook-contents_leveledUp_task-scored.json
Last active May 13, 2023 21:48
Webhook Contents: leveledUp (task scored)
{
"type": "scored",
"direction": "up",
"delta": 0.6935255111371725,
"task": {
"repeat": {
"m": true,
"t": true,
"w": true,
"th": true,
@bumbleshoot
bumbleshoot / webhook-contents_questInvited.json
Last active May 13, 2023 21:48
Webhook Contents: questInvited
{
"type": "questInvited",
"group": {
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "Habit Kickers Elite"
},
"quest": {
"key": "taskwoodsTerror2",
"questOwner": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
@bumbleshoot
bumbleshoot / webhook-contents_questFinished.json
Last active May 13, 2023 21:48
Webhook Contents: questFinished
{
"type": "questFinished",
"group": {
"id": "9c574405-6dc0-4c7f-82d9-740852ef6436",
"name": "Habit Kickers Elite"
},
"quest": {
"key": "moonstone3"
},
"webhookType": "questActivity",
@bumbleshoot
bumbleshoot / webhook-contents_groupChatReceived.json
Last active May 13, 2023 21:48
Webhook Contents: groupChatReceived
{
"group": {
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "HK Sandbox"
},
"chat": {
"flagCount": 0,
"flags": {},
"_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",