From 5c2ef740e612dd6142682d0afca808aa96c0704f Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 11 Aug 2022 21:47:27 +0100 Subject: [PATCH] Fix email command --- commands/email.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/commands/email.py b/commands/email.py index c388a56..fa99fa0 100644 --- a/commands/email.py +++ b/commands/email.py @@ -11,8 +11,21 @@ class EmailCommand: if authed: if length == 4: if spl[1] == "add": - if not spl[2].isdigit(): - # failure("Must be a number, not %s" % spl[2]) + if spl[2].isdigit(): + num = int(spl[2]) + if num not in main.alias.keys(): + failure("No such alias: %i" % num) + return + if not spl[3] in main.alias[num]["emails"]: + main.alias[num]["emails"].append(spl[3]) + main.saveConf("alias") + success("Successfully added email %s to alias %i" % (spl[3], num)) + return + else: + failure("Email already exists in alias %i: %s" % (num, spl[3])) + return + else: + failure("Must be a number, not %s" % spl[2]) if spl[2] == "domain": domain = spl[3] if "@" in domain: @@ -25,6 +38,7 @@ class EmailCommand: else: failure("Domain already exists in default config: %s" % domain) return + elif spl[1] == "del": if not spl[2].isdigit(): # failure("Must be a number, not %s" % spl[2]) @@ -39,20 +53,6 @@ class EmailCommand: failure("Domain does not exist in default config: %s" % domain) return - else: - num = int(spl[2]) - if spl[1] == "add": - if num not in main.alias.keys(): - failure("No such alias: %i" % num) - return - if not spl[3] in main.alias[num]["emails"]: - main.alias[num]["emails"].append(spl[3]) - main.saveConf("alias") - success("Successfully added email %s to alias %i" % (spl[3], num)) - return - else: - failure("Email already exists in alias %i: %s" % (num, spl[3])) - return elif spl[1] == "del": if num not in main.alias.keys(): failure("No such alias: %i" % num)