From 9d6612a9d790a33d434006a6b259f6a15188938b Mon Sep 17 00:00:00 2001 From: Mindiell Date: Sat, 12 Oct 2024 11:23:47 +0200 Subject: [PATCH] fix: striping all received messages --- hebdobot.py | 2 +- tests/test_bot.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hebdobot.py b/hebdobot.py index 14e692e..13721d0 100644 --- a/hebdobot.py +++ b/hebdobot.py @@ -65,7 +65,7 @@ class HebdoBot(IrcBot): """ channel = event.target sender = event.source.nick - message = event.arguments[0] + message = event.arguments[0].strip() if self.review.is_started: self.review.add_message(sender, message) diff --git a/tests/test_bot.py b/tests/test_bot.py index 4cb718c..5578e20 100644 --- a/tests/test_bot.py +++ b/tests/test_bot.py @@ -10,3 +10,11 @@ def test_private_command(bot): bot.test_private_message(bot.channel, SENDER, "!hello") assert len(bot.answers) == 1 assert bot.answers[0].message == "Vos commandes dans le salon public" + + +def test_public_message(bot): + # Cheating here to save message sent + bot.review.started = True + bot.test_public_message(bot.channel, SENDER, " hello ") + assert len(bot.answers) == 0 + assert bot.review.messages[0].text == "hello"