Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IRC: Error sending messages bigger than 512 bytes. #989

Open
1 of 5 tasks
qlixed opened this issue Apr 12, 2017 · 1 comment · May be fixed by #1063
Open
1 of 5 tasks

IRC: Error sending messages bigger than 512 bytes. #989

qlixed opened this issue Apr 12, 2017 · 1 comment · May be fixed by #1063

Comments

@qlixed
Copy link
Contributor

qlixed commented Apr 12, 2017

In order to let us help you better, please fill out the following fields as best you can:

I am...

  • Reporting a bug
  • Suggesting a new feature
  • Requesting help with running my bot
  • Requesting help writing plugins
  • Here about something else

I am running...

  • Errbot version: 4.3.7
  • OS version: Fedora 25
  • Python version: 3.5
  • Using a virtual environment: yes

Issue description

If the response of the bot has more than 512 bytes there is some complain from the backend:

Computer says nooo. See logs for details:
Messages limited to 512 bytes including CR/LF

Full backtrace from the log:

2017-04-11 21:01:27,355 ERROR errbot.core An error happened while processing a message ("gary test"): Traceback (most recent call last):
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 453, in _execute_and_send
self.send_simple_reply(mess, self.process_template(template_name, reply), private)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 198, in send_simple_reply
self.split_and_send_message(reply)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 163, in split_and_send_message
self.send_message(partial_message)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/backends/irc.py", line 672, in send_message
msg_func(msg_to, line)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/utils.py", line 235, in rate_limited_function
ret = func(*args, **kargs)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/backends/irc.py", line 426, in send_private_message
self.connection.privmsg(to, line)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 885, in privmsg
self.send_raw("PRIVMSG %s :%s" % (target, text))
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 921, in send_raw
sender(self._prep_message(string))
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 909, in _prep_message
raise MessageTooLong(msg)
irc.client.MessageTooLong: Messages limited to 512 bytes including CR/LF
"
Traceback (most recent call last):
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 453, in _execute_and_send
self.send_simple_reply(mess, self.process_template(template_name, reply), private)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 198, in send_simple_reply
self.split_and_send_message(reply)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/core.py", line 163, in split_and_send_message
self.send_message(partial_message)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/backends/irc.py", line 672, in send_message
msg_func(msg_to, line)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/utils.py", line 235, in rate_limited_function
ret = func(*args, **kargs)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/errbot/backends/irc.py", line 426, in send_private_message
self.connection.privmsg(to, line)
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 885, in privmsg
self.send_raw("PRIVMSG %s :%s" % (target, text))
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 921, in send_raw
sender(self._prep_message(string))
File "/home/qlixed/src/gary/lib/python3.5/site-packages/irc/client.py", line 909, in _prep_message
raise MessageTooLong(msg)
irc.client.MessageTooLong: Messages limited to 512 bytes including CR/LF

Steps to reproduce

Make any response from the bot with a string with len()>512

Additional info

It suppose to cut the message in 510 bytes chunks when call self.split_and_send_message, but apparently is not working.

mrshu added a commit to mrshu/err that referenced this issue Jul 9, 2017
* The maximal message length has previously been set to 510 (probably in
  order to accomodate the b'\r\n' that are necessary for each IRC
  message). This turns out not to be enough, as the message starts with
  the obligatory `PRIVMSG <to> :` and ends with the EXT (b'\x03) mark.

* The size limit was therefore set to `499` in order to accomodate all
  these obligatory parts.

* Furthermore, a new configuration option has been added
  (`MESSAGE_SIZE_LIMIT_INCLUDES_ADDRESEE`), which takes care of the fact
  that `<to>` -- the addressee of the message -- comes directly after
  `PRIVMSG` and is thus part of the message. Note that this is currently
  only applied in the case of IRC.

* Fixes errbotio#989

Signed-off-by: mr.Shu <mr@shu.io>
@mrshu mrshu linked a pull request Jul 9, 2017 that will close this issue
@mrshu
Copy link
Member

mrshu commented Jul 9, 2017

@qlixed While the split_and_sent_message was working as intended, the maximum length of the actual message that can be sent via IRC is also limited by the length of the nick/channel which it is addressed to, and so the previous implementation was not working as one may have expected it to.

If you have some time, it would be very helpful if you could check whether the fix I put together in #1063 works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants