Legobot / legos.xkcd

GNU General Public License v3.0
1 stars 1 forks source link

Carriage returns in response break in IRC #7

Open bbriggs opened 7 years ago

bbriggs commented 7 years ago
2017-02-17 03:11:35,069 - legos.xkcd - INFO - Retrieving URL: http://xkcd.com/info.0.json
2017-02-17 03:11:35,205 - Legobot.Connectors.IRC - INFO - {'should_log': False, 'text': '*xkcd #1799* \n This is probably the first projection in cartographic history that can be criticized for its disproportionate focus on Finland, Mongolia, and the Democratic Republic of the Congo. \n https://imgs.xkcd.com/comics/bad_map_projection_time_zones.png', 'metadata': {'dest': <IRCBot(Thread-2, started 140703120221952)>, 'source': <legos.xkcd.XKCD object at 0x7ff804da7908>, 'opts': {'target': '#social'}}}
Exception in thread Thread-11:
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/threading.py", line 914, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.5/site-packages/Legobot/Lego.py", line 31, in run
    self.handler(self.message)
  File "/usr/local/lib/python3.5/site-packages/Legobot/Connectors/IRC.py", line 158, in handle
    'target'], message['text'])
  File "/usr/local/lib/python3.5/site-packages/irc/client.py", line 885, in privmsg
    self.send_raw("PRIVMSG %s :%s" % (target, text))
  File "/usr/local/lib/python3.5/site-packages/irc/client.py", line 921, in send_raw
    sender(self._prep_message(string))
  File "/usr/local/lib/python3.5/site-packages/irc/client.py", line 903, in _prep_message
    raise InvalidCharacters(msg)
irc.client.InvalidCharacters: Carriage returns not allowed in privmsg(text)

Solution: Send two responses or remove carriage return.

bbriggs commented 7 years ago

This is fixed in https://github.com/Legobot/Legobot/pull/140 and friends