Files
bots/quip.py

26 lines
875 B
Python

from requests import get, post
from os import getenv
from random import randint
import csv,io
from json import loads
from globals import *
post_endpoint = bots_endpoint + '/api/v1/statuses'
response = get(quip_file)
if response.reason == "OK":
choices = response.text.split('\n')
choice = choices[randint(0, len(choices) - 1)]
headers = {"Authorization": "Bearer " + quip_token}
payload = {"status": f"{choice} \n\n {quip_tags} #Bot",
"visibility": "public"}
result = post(post_endpoint, headers=headers, data=payload)
if result.reason == "OK":
if po_user_token:
notify(-1, 'quip bot post url: ' + loads(result.text)['url'])
else:
notify(0, 'quip bot post failed: ' + result.status_code + ' - ' + result.reason)
else:
if po_user_token:
notify(1, 'quip file read failed: ' + response.status_code + ' - ' + response.reason)