Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fixes:
- chore: bump jinja2 to 3.1.5 and requests to 2.32.0 (#1714)
- Fix: situationally broken apropos command (#1711)
- chore: bump requests to 2.32.3 (#1715)
- Fix: Newlines replaced with spaces in botcmd args (#1716)
- chore: bump jinja2 to 3.1.6 (#1723)
- chore: update errbot-backend-slackv3 version to 0.3.1 (#1725)

Expand Down
10 changes: 7 additions & 3 deletions errbot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,21 +325,25 @@ def process_message(self, msg: Message) -> bool:
prefixed = True

text = text.strip()
text_split = text.split()
cmd = None
command = None
args = ""
if not only_check_re_command:
i = len(text_split)
first = True
i = len(text.split())
while cmd is None:
# maxsplit so we can preserve linebreaks and other whitespace in args
text_split = text.split(maxsplit=i)
command = "_".join(text_split[:i])

with self._gbl:
if command in self.commands:
cmd = command
args = " ".join(text_split[i:])
if not first:
args = text_split[-1]
else:
i -= 1
first = False
if i <= 0:
break

Expand Down
10 changes: 10 additions & 0 deletions tests/commands_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ def test_echo(testbot):
assert "foo" in testbot.exec_command("!echo foo")


def test_echo_newline_args(testbot):
# https://github.com/errbotio/errbot/issues/1307
assert testbot.exec_command("!echo\nfoo\nbar").startswith("foo")


def test_echo_newline_preserved(testbot):
# https://github.com/errbotio/errbot/issues/1716
assert "\n" in testbot.exec_command("!echo foo\nbar")


def test_status_gc(testbot):
assert "GC 0->" in testbot.exec_command("!status gc")

Expand Down