From 0abab7461ce76248a176ae5996e436224a4fcc02 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Thu, 9 Sep 2021 10:02:23 +0200 Subject: add thanks command easteregg --- geldschieberbot.py | 11 +++++++++++ test.py | 12 ++++++++++++ 2 files changed, 23 insertions(+) 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"]: diff --git a/test.py b/test.py index 0120c89..79098f2 100755 --- a/test.py +++ b/test.py @@ -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() -- cgit v1.2.3