Added error messages for redundant commands

master
Thor 3 years ago
parent 181282258c
commit a465b796dd
  1. 9
      cringebot.py

@ -137,8 +137,9 @@ class CringeBotClient(BotClient):
if token == "cringe":
if event not in ["categorise", "learn"]:
self.respond(status, "Status is not learnable", {"event": "error", "type": "learnable", "target": target_id})
return True
break
elif self.is_cringe(target_id):
self.respond(status, "Status was already learned as cringe", {"event": "error", "type": "redundant", "target": target_id})
break
elif self.is_based(target_id):
bogofilter.run(target_mail_text, actions = [bogofilter.UNLEARN_HAM, bogofilter.LEARN_SPAM], db_dir = self.db_dir)
@ -154,8 +155,9 @@ class CringeBotClient(BotClient):
elif token == "based":
if event not in ["categorise", "learn"]:
self.respond(status, "Status is not learnable", {"event": "error", "type": "learnable", "target": target_id})
return True
break
elif self.is_based(target_id):
self.respond(status, "Status was already learned as based", {"event": "error", "type": "redundant", "target": target_id})
break
elif self.is_cringe(target_id):
bogofilter.run(target_mail_text, actions = [bogofilter.UNLEARN_SPAM, bogofilter.LEARN_HAM], db_dir = self.db_dir)
@ -171,8 +173,9 @@ class CringeBotClient(BotClient):
elif token == "unlearn":
if event not in ["categorise", "learn"]:
self.respond(status, "Status is not learnable", {"event": "error", "type": "learnable", "target": target_id})
return True
break
elif self.is_unsure(target_id):
self.respond(status, "Status was already unsure", {"event": "error", "type": "redundant", "target": target_id})
break
elif self.is_cringe(target_id):
bogofilter.run(target_mail_text, actions = [bogofilter.UNLEARN_SPAM], db_dir = self.db_dir)

Loading…
Cancel
Save