jaraco / irc

Full-featured Python IRC library for Python.
MIT License
392 stars 87 forks source link

USERHOST reply truncated #118

Closed vikingsloth closed 7 years ago

vikingsloth commented 7 years ago

The USERHOST command reply from the server gets truncated by the client.

DEBUG:irc.client:TO SERVER: USERHOST t,c,l,i,e,n,t
DEBUG:irc.client:FROM SERVER: :irc.mzima.net 302 gbot102 :
DEBUG:irc.client:command: userhost, source: irc.mzima.net, target: gbot102, arguments: [u''], tags: None

A normal server response looks like this:

:irc.mzima.net 302 gbot102 :gbot102=+gbot@1.2.3.4
jaraco commented 7 years ago

The way the buffer class works, it yields full lines, as terminated by a LF (or maybe CRLF)... so if the FROM SERVER says that's what it's received, I'm inclined to trust it.

You can troubleshoot by overriding the default buffer behavior and asserting what the incoming bytes are:

import sys
from jaraco.stream import buffer
class DebuggingBuffer(buffer.DecodingLineBuffer):
    def feed(self, bytes):
        print("fed ", bytes, file=sys.stderr)
        super(DebuggingBuffer, self).feed(bytes)

irc.client.ServerConnection.buffer_class = DebuggingBuffer

Run that somewhere before initiating your connection - then report back the fed prefixed lines.

vikingsloth commented 7 years ago

This was user error. I called self.userhost("tclient") but it should be self.userhost(["tclient"])

DEBUG:irc.client:TO SERVER: USERHOST t,c,l,i,e,n,t