reply formatted correctly; maybe - still need to test off-instance
This commit is contained in:
parent
4c3221af44
commit
6f9eea48b0
1 changed files with 25 additions and 18 deletions
|
@ -19,7 +19,7 @@ message = ""
|
|||
post_uri = f"https://{endpoint}/api/v1/statuses"
|
||||
note_to_post = ""
|
||||
headers = { "Content-Type" : "application/json",
|
||||
"Authorization" : "Bearer " + fyrfli_token,
|
||||
"Authorization" : f"Bearer {fyrfli_token}",
|
||||
"User-Agent" : "fyrfliBOT" }
|
||||
mention_id = ""
|
||||
created_note = ""
|
||||
|
@ -33,9 +33,11 @@ async def hello(uri):
|
|||
print(decoded.event, decoded.payload[1:49])
|
||||
match decoded.event:
|
||||
case "delete":
|
||||
print("a delete event for id ", decoded.payload)
|
||||
print("a delete event for id ", decoded.payload, "\n===>\n")
|
||||
|
||||
case "update"|"status.update":
|
||||
the_update = dm.fromDict(json.loads(decoded.payload))
|
||||
print(the_update)
|
||||
if the_update.reblog:
|
||||
print(
|
||||
"a reblog of ",
|
||||
|
@ -43,7 +45,8 @@ async def hello(uri):
|
|||
"\n id ",
|
||||
the_update.id,
|
||||
"\n created at ",
|
||||
the_update.created_at
|
||||
the_update.created_at,
|
||||
"\n===>\n"
|
||||
)
|
||||
else:
|
||||
plain_text_content = strip_html(the_update.content)
|
||||
|
@ -57,27 +60,26 @@ async def hello(uri):
|
|||
"\n created at ",
|
||||
the_update.created_at,
|
||||
"\n the content \n",
|
||||
plain_text_content
|
||||
plain_text_content,
|
||||
"\n===>\n"
|
||||
)
|
||||
# payload = { "status": "oh ... hi @" + decoded['account']['acct'],
|
||||
# "in_reply_to_id": decoded['status']['id'],
|
||||
# "visibility": "unlisted" }
|
||||
if "folks" in plain_text_content:
|
||||
strings_to_listen_for = ["folks" in plain_text_content.lower(),
|
||||
"love" in plain_text_content.lower(),
|
||||
"you" in plain_text_content.lower()]
|
||||
if any(strings_to_listen_for):
|
||||
note_to_post = {
|
||||
"status": """
|
||||
We come to love not by finding a
|
||||
perfect person, but by learning to
|
||||
see an imperfect person perfectly.\n
|
||||
- Sam Keen
|
||||
""",
|
||||
"status": f"[@{the_update.account.acct}](the_update.account.url) We come to love not by finding a perfect person, but by learning to see an imperfect person perfectly.\n ~ Sam Keen ~ ",
|
||||
"in_reply_to_id": the_update.id,
|
||||
"visibility": "mutuals_only"
|
||||
"visibility": "mutuals_only",
|
||||
"content_type": "text/markdown"
|
||||
}
|
||||
r = requests.post(
|
||||
post_uri,
|
||||
headers=header,
|
||||
data=note_to_post
|
||||
headers=headers,
|
||||
json=note_to_post
|
||||
)
|
||||
print(r.reason, r.status_code)
|
||||
|
||||
case "notification":
|
||||
the_notification = dm.fromDict(json.loads(decoded.payload))
|
||||
print(
|
||||
|
@ -87,18 +89,23 @@ async def hello(uri):
|
|||
" from ",
|
||||
the_notification.account.acct,
|
||||
" id ", the_notification.id, "\n",
|
||||
" created at ", the_notification.created_at
|
||||
" created at ", the_notification.created_at,
|
||||
"\n===>\n"
|
||||
)
|
||||
|
||||
case _:
|
||||
print('unknown event: ', decoded.event, "\n",
|
||||
" with payload beginning ",
|
||||
decoded.payload[1:100])
|
||||
|
||||
except asyncio.exceptions.CancelledError:
|
||||
print('keyboard interrupt received ... exiting')
|
||||
break
|
||||
|
||||
except KeyboardInterrupt:
|
||||
print('keyboard interrupt received ... exiting')
|
||||
break
|
||||
|
||||
except websockets.ConnectionClosed:
|
||||
break
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue