Skip to content

Newlines are removed from botcmd args #1716

@zaughon

Description

@zaughon

Describe the bug
The fix to #1307 means that all newlines are split and eventually replaced with spaces:
https://github.com/errbotio/errbot/blob/master/errbot/core.py#L340

In general, i think it's best if the args stay as unmodified as possible, and then you can manipulate it with args.replace("\n", " ") yourself if you want something specific in certain situations.
Currently i'm looking into making something that may take large blobs of text and store that in a DB, and need to pull it out later and display it. It gets very messy when all newlines are removed though.

To Reproduce

    @botcmd
    def hello(self, msg, args):
        return 'Hello! You said: ' + args

    @botcmd
    def repr(self, msg, args):
        return 'Hello! You said: ' + repr(args)
$ pip3 install errbot
$ errbot --init
$ errbot
...
# Enable multiline mode with !ml if it isn't already
>>> !ml
>>> !hello
[.] Line 1
[.] Line 2
[.]
Hello! You said: Line 1 Line 2

>>> !repr
[.] Line 1
[.] Line 2
[.]
Hello! You said: 'Line 1 Line 2'

Expected behavior
Linebreaks between "Line 1" and "Line 2" are preserved: Line 1\nLine 2

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • Errbot version: 6.2.0
  • OS version: Arch
  • Python version: 3.13.2
  • Using a virtual environment: yes
  • Using Docker: no

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions