Created
January 29, 2021 19:22
-
-
Save m4r10k/b043597dbce695c2ac5ccdbb9d712a36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import escape | |
from flask import request | |
import json | |
import requests | |
def gitlab_habitica_google_function(request): | |
"""HTTP Cloud Function. | |
Args: | |
request (flask.Request): The request object. | |
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data> | |
Returns: | |
The response text, or any set of values that can be turned into a | |
Response object using `make_response` | |
<https://flask.palletsprojects.com/en/1.1.x/api/#flask.make_response>. | |
""" | |
y = json.loads(request.get_data()) | |
# only on issue change | |
if "updated_at" in y["changes"]: | |
# only if closed == 2 | |
if y["object_attributes"]["state_id"] == 2: | |
task_id = "<your-task-id>" | |
xapikey = "<your-x-api-key>" | |
xapiuser = "<your-x-api-user>" | |
headers = { | |
'x-api-key': xapikey, | |
'x-api-user': xapiuser | |
} | |
url = "https://habitica.com/api/v3/tasks/" + task_id + "/score/up" | |
r = requests.post(url = url, headers = headers) | |
print(r.status_code) | |
return "loaded" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment