modified white nonsense bot code to be used with any text file with a list of sayings; added notify function to globals and made pushover optional
This commit is contained in:
25
quip.py
Normal file
25
quip.py
Normal file
@ -0,0 +1,25 @@
|
||||
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)
|
Reference in New Issue
Block a user