Pārlūkot izejas kodu

Initial commit

master
Noëlle pirms 2 gadiem
vecāks
revīzija
d02b1f4254
Šim parakstam datu bāzē netika atrasta zināma atslēga
1 mainītis faili ar 24 papildinājumiem un 0 dzēšanām
  1. 24
    0
      pingbot.py

+ 24
- 0
pingbot.py Parādīt failu

@@ -0,0 +1,24 @@
from ananas import PineappleBot, html_strip_tags, reply

class PingBot(PineappleBot):
def start(self):
self.notifiees = self.config.notify.split(',')
self.notifiees_str = ", ".join(self.notifiees)
print(f"Now monitoring {self.config.monitor}; pinging {self.notifiees_str}.")

@reply
def post_response(self, mention, user):
petitioner = user["acct"]
if petitioner != self.config.monitor: # Prevent self-replies
msg = mention["uri"]
if self.config.full_message:
msg += f"\n\n{html_strip_tags(mention['content'])}"
visibility = 'direct'
# This is for logging purposes. You may wish to redirect this into a text log.
print(f"Received a reply from {petitioner}. Pinging {self.notifiees_str}.")

notify_list = " ".join(self.notifiees)
status = f"{notify_list} {self.monitor} has received a new message from {petitioner}:\n\n{msg}"
if len(status) > 450: # don't let the post get too long!
status = status[:450] + " ...(message continues)"
self.mastodon.status_post(status, visibility=visibility)

Notiek ielāde…
Atcelt
Saglabāt