diff --git a/gts_socket_listen.py b/gts_socket_listen.py index 7275303..feedf90 100644 --- a/gts_socket_listen.py +++ b/gts_socket_listen.py @@ -5,7 +5,7 @@ import json import requests import random from os import getenv -from munch import DefaultMunch as dm, Munch +from munch import munchify from lxml import html import pprint import csv, io @@ -25,7 +25,7 @@ headers = { "Content-Type" : "application/json", "Authorization" : f"Bearer {api_token}", "User-Agent" : "fyrfliBOT" } -status_dict = Munch({"status": "", +status_dict = munchify({"status": "", "in_reply_to_id": "", "local_only": False, "visibility": "mutuals_only", @@ -39,7 +39,8 @@ randomised_hellos = [ 'well hello there', 'mornin\' mornin\'', 'g\'day mate', - 'allo' + 'allo', + '\'sup' ] def get_random_quote(): @@ -48,7 +49,7 @@ def get_random_quote(): def process_request(the_post): print('processing ', the_post.url) - pprint.pprint(json.dumps(the_post), compact=True, indent=2) + # pprint.pprint(json.dumps(the_post), compact=True, indent=2) hellos = ["hey" in the_post.content.lower(),"hey you" in the_post.content.lower(), "hi" in the_post.content.lower(), "hello" in the_post.content.lower()] request_quote = ["random quote" in the_post.content.lower(), "quote please" in the_post.content.lower()] if any(hellos): @@ -72,10 +73,10 @@ async def hello(uri): async for ws in websockets.connect(uri): try: message = await ws.recv() - decoded = dm.fromDict(json.loads(message)) + decoded = munchify(json.loads(message)) print(decoded.event, decoded.payload[1:150]) if decoded.event != "delete": - the_post = dm.fromDict(json.loads(decoded.payload)) + the_post = munchify(json.loads(decoded.payload)) match decoded.event: case "delete": print("a delete event for id ", decoded.payload, "\n===>\n")