replying to mentions only now; still to come - respond based on substring found
This commit is contained in:
parent
6f9eea48b0
commit
17d1dd48e4
1 changed files with 36 additions and 23 deletions
|
@ -19,7 +19,7 @@ message = ""
|
|||
post_uri = f"https://{endpoint}/api/v1/statuses"
|
||||
note_to_post = ""
|
||||
headers = { "Content-Type" : "application/json",
|
||||
"Authorization" : f"Bearer {fyrfli_token}",
|
||||
"Authorization" : f"Bearer {api_token}",
|
||||
"User-Agent" : "fyrfliBOT" }
|
||||
mention_id = ""
|
||||
created_note = ""
|
||||
|
@ -37,7 +37,7 @@ async def hello(uri):
|
|||
|
||||
case "update"|"status.update":
|
||||
the_update = dm.fromDict(json.loads(decoded.payload))
|
||||
print(the_update)
|
||||
print(json.dumps(the_update))
|
||||
if the_update.reblog:
|
||||
print(
|
||||
"a reblog of ",
|
||||
|
@ -63,35 +63,48 @@ async def hello(uri):
|
|||
plain_text_content,
|
||||
"\n===>\n"
|
||||
)
|
||||
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": 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",
|
||||
"content_type": "text/markdown"
|
||||
}
|
||||
r = requests.post(
|
||||
post_uri,
|
||||
headers=headers,
|
||||
json=note_to_post
|
||||
)
|
||||
print(r.reason, r.status_code)
|
||||
if the_update.mentions:
|
||||
for mention in the_update.mentions:
|
||||
if mention.username == "botsy":
|
||||
note_to_post = {
|
||||
"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",
|
||||
"content_type": "text/markdown"
|
||||
}
|
||||
r = requests.post(
|
||||
post_uri,
|
||||
headers=headers,
|
||||
json=note_to_post
|
||||
)
|
||||
print(r.reason, r.status_code)
|
||||
break
|
||||
|
||||
case "notification":
|
||||
the_notification = dm.fromDict(json.loads(decoded.payload))
|
||||
the_notif = dm.fromDict(json.loads(decoded.payload))
|
||||
print(
|
||||
"a ",
|
||||
the_notification.type,
|
||||
the_notif.type,
|
||||
" notification\n",
|
||||
" from ",
|
||||
the_notification.account.acct,
|
||||
" id ", the_notification.id, "\n",
|
||||
" created at ", the_notification.created_at,
|
||||
the_notif.account.acct,
|
||||
" id ", the_notif.id, "\n",
|
||||
" created at ", the_notif.created_at,
|
||||
"\n===>\n"
|
||||
)
|
||||
note_to_post = {
|
||||
"status": f"[@{the_notif.account.acct}](the_notif.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_notif.id,
|
||||
"visibility": "mutuals_only",
|
||||
"content_type": "text/markdown"
|
||||
}
|
||||
r = requests.post(
|
||||
post_uri,
|
||||
headers=headers,
|
||||
json=note_to_post
|
||||
)
|
||||
print(r.reason, r.status_code)
|
||||
|
||||
|
||||
case _:
|
||||
print('unknown event: ', decoded.event, "\n",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue