Python 3.8 fix; Bogofilter report in DMs

master
Thor 3 years ago
parent 3eb003833c
commit 1bd46482aa
  1. 4
      bogofilter.py
  2. 7
      cringefilter.py

@ -17,9 +17,9 @@ class BogofilterResult:
class Mail:
def __init__(self, headers = {}, body = None):
self.headers = {
self.headers = {**{
"Date": datetime.now(),
"Content-Type": "text/html; charset=\"UTF-8\""} | headers
"Content-Type": "text/html; charset=\"UTF-8\""}, **headers}
self.body = body
def format(self):

@ -158,16 +158,17 @@ class Instance:
self.save_state()
else:
result = bogofilter.run(mail_text, learn = True)
bogo_report = "Bogofilter: Category={}, Score={}".format(result.category, result.score)
if result.category == "S":
log_print(self.name, "SPAM: Tracking status with ID {} as spam".format(status["id"]))
self.api.status_reply(status, "@{} Tracked as spam\n#cringefilter".format(self.api.me()["username"]), visibility = "direct", untag = True)
self.api.status_reply(status, "@{me} Tracked as spam\n{bogo}\n#cringefilter".format(me = self.api.me()["username"], bogo = bogo_report), visibility = "direct", untag = True)
time.sleep(1)
else:
log_print(self.name, "HAM: Not tracking status with ID {} as spam".format(status["id"]))
self.api.status_reply(status, "@{} Tracked as ham\n#cringefilter".format(self.api.me()["username"]), visibility = "direct", untag = True)
self.api.status_reply(status, "@{me} Tracked as ham\n{bogo}\n#cringefilter".format(me = self.api.me()["username"], bogo = bogo_report), visibility = "direct", untag = True)
time.sleep(1)
log_print(self.name, "Bogofilter: Category={}, Score={}".format(result.category, result.score))
log_print(self.name, bogo_report)
print()
print(mail_text)

Loading…
Cancel
Save