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"
|
post_uri = f"https://{endpoint}/api/v1/statuses"
|
||||||
note_to_post = ""
|
note_to_post = ""
|
||||||
headers = { "Content-Type" : "application/json",
|
headers = { "Content-Type" : "application/json",
|
||||||
"Authorization" : f"Bearer {fyrfli_token}",
|
"Authorization" : f"Bearer {api_token}",
|
||||||
"User-Agent" : "fyrfliBOT" }
|
"User-Agent" : "fyrfliBOT" }
|
||||||
mention_id = ""
|
mention_id = ""
|
||||||
created_note = ""
|
created_note = ""
|
||||||
|
@ -37,7 +37,7 @@ async def hello(uri):
|
||||||
|
|
||||||
case "update"|"status.update":
|
case "update"|"status.update":
|
||||||
the_update = dm.fromDict(json.loads(decoded.payload))
|
the_update = dm.fromDict(json.loads(decoded.payload))
|
||||||
print(the_update)
|
print(json.dumps(the_update))
|
||||||
if the_update.reblog:
|
if the_update.reblog:
|
||||||
print(
|
print(
|
||||||
"a reblog of ",
|
"a reblog of ",
|
||||||
|
@ -63,10 +63,9 @@ async def hello(uri):
|
||||||
plain_text_content,
|
plain_text_content,
|
||||||
"\n===>\n"
|
"\n===>\n"
|
||||||
)
|
)
|
||||||
strings_to_listen_for = ["folks" in plain_text_content.lower(),
|
if the_update.mentions:
|
||||||
"love" in plain_text_content.lower(),
|
for mention in the_update.mentions:
|
||||||
"you" in plain_text_content.lower()]
|
if mention.username == "botsy":
|
||||||
if any(strings_to_listen_for):
|
|
||||||
note_to_post = {
|
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 ~ ",
|
"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,
|
"in_reply_to_id": the_update.id,
|
||||||
|
@ -79,19 +78,33 @@ async def hello(uri):
|
||||||
json=note_to_post
|
json=note_to_post
|
||||||
)
|
)
|
||||||
print(r.reason, r.status_code)
|
print(r.reason, r.status_code)
|
||||||
|
break
|
||||||
|
|
||||||
case "notification":
|
case "notification":
|
||||||
the_notification = dm.fromDict(json.loads(decoded.payload))
|
the_notif = dm.fromDict(json.loads(decoded.payload))
|
||||||
print(
|
print(
|
||||||
"a ",
|
"a ",
|
||||||
the_notification.type,
|
the_notif.type,
|
||||||
" notification\n",
|
" notification\n",
|
||||||
" from ",
|
" from ",
|
||||||
the_notification.account.acct,
|
the_notif.account.acct,
|
||||||
" id ", the_notification.id, "\n",
|
" id ", the_notif.id, "\n",
|
||||||
" created at ", the_notification.created_at,
|
" created at ", the_notif.created_at,
|
||||||
"\n===>\n"
|
"\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 _:
|
case _:
|
||||||
print('unknown event: ', decoded.event, "\n",
|
print('unknown event: ', decoded.event, "\n",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue