|
|
|
@ -12,15 +12,6 @@ from mastodon import Mastodon, MastodonNotFoundError |
|
|
|
|
|
|
|
|
|
from bot import Bot, BotClient |
|
|
|
|
|
|
|
|
|
def encode_time(dt): |
|
|
|
|
return int(dt.strftime("%Y%m%d%H%M")) |
|
|
|
|
|
|
|
|
|
def decode_time(value): |
|
|
|
|
if len(value) == 12: |
|
|
|
|
return dt.strptime(str(value), "%Y%m%d%H%M") |
|
|
|
|
else: |
|
|
|
|
return dt.strptime(str(value), "%Y%m%d%H") |
|
|
|
|
|
|
|
|
|
class CringeBotClient(BotClient): |
|
|
|
|
def __init__(self, bot, config): |
|
|
|
|
self.h2t = html2text.HTML2Text() |
|
|
|
@ -29,17 +20,17 @@ class CringeBotClient(BotClient): |
|
|
|
|
self.deletion_scheduler = sched.scheduler(time.time, time.sleep) |
|
|
|
|
|
|
|
|
|
super().__init__(bot, config) |
|
|
|
|
|
|
|
|
|
def on_start(self): |
|
|
|
|
self.deletion_report() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def respond(self, status, message): |
|
|
|
|
self.log("Responded with:") |
|
|
|
|
self.log("Responding with:") |
|
|
|
|
self.log(message) |
|
|
|
|
reply = self.api.status_reply(status, "{}\n{}".format(message, self.config["tag"]), visibility = "direct", untag = True) |
|
|
|
|
self.enqueue_deletion(reply["id"]) |
|
|
|
|
time.sleep(1) |
|
|
|
|
|
|
|
|
|
def on_start(self): |
|
|
|
|
self.deletion_report() |
|
|
|
|
|
|
|
|
|
def on_poll(self): |
|
|
|
|
self.deletion_scheduler.run(blocking = False) |
|
|
|
|
|
|
|
|
|