diff options
| -rw-r--r-- | geldschieberbot.py | 11 | ||||
| -rwxr-xr-x | test.py | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/geldschieberbot.py b/geldschieberbot.py index 9c622bd..3ad9960 100644 --- a/geldschieberbot.py +++ b/geldschieberbot.py @@ -847,6 +847,17 @@ def cancel(sender, args, msg): cmds["cancel"] = cancel +def thanks(sender, args, msg): + sender_name = num2name.get(sender, sender) + msg = f'You are welcome. It is a pleasure to work with you, {sender_name}.' + nick = None if len(args) == 1 else args[1] + if nick: + msg = f"{msg}\nBut don't call me {nick}." + + return msg, None + +cmds["thanks"] = thanks + def main(): if len(sys.argv) > 1 and sys.argv[1] in ["-d", "--dry-run"]: @@ -1120,6 +1120,18 @@ fiat: \tBalance: -3.00""" self.assertEqual(res.stdout, msg) +class TestThanks(unittest.TestCase): + def test_thanks(self): + res = run_bot(self, num[alice], "!thanks") + self.assertEqual( + res.stdout, + f"You are welcome. It is a pleasure to work with you, {alice}.") + + def test_thanks_nick(self): + res = run_bot(self, num[alice], "!thanks pussy") + self.assertEqual( + res.stdout, + f"You are welcome. It is a pleasure to work with you, {alice}.\nBut don't call me pussy.") if __name__ == '__main__': unittest.main() |
