#๐ IRC client library either does not actually send messages, or doesn't receive responses
22 messages ยท Page 1 of 1 (latest)
@clever swan
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Worth noting that I have an IRC client monitoring the IRCd and the channel #test, nothing appears on that client's end when the test client is ran
is it possible you're missing the \r\n after each line?
Do I actually have to send a CRLF after each line?
Well I'll be damned, that did something
TCP is a stream.
with TCP you have to always assume, that you might not receive the complete data, or sometimes multiple pieces of data are merged
(hough you're using readline(), so that's doing it for you automatcally.)
Hm, the servers sending :localhost.com 451 TestNyte_ :You have not registered
not sure what thath means. are you using one of those NickServ services? Or maybe the USER command did not work?
Perhaps it's because the PASS being sent is nonsensical with an anonymous user
Ah lovely it works now
Had to fix the PONG response and actually set up the client password to comply with how I set up the IRCd
async def _loop(self):
buf = b''
while True:
data = await self._reader.readline()
if not data:
print('Connection closed') # no data = EOF
break
# collect all data in a buffer
buf += data.replace(b'\r', b'\n') # now we only need to deal with \n
while b'\n' in buf:
# split out a line and keep the rest in buf (maxsplits+loop condition ensures there will be exactly two elements)
line, buf = buf.split(b'\n', maxsplits=1)
if line.startswith(b'PING '): # respond with the exact same message, but as PONG
await self.send(line.replace(b'PING', b'PONG', 1) + b'\r\n')
continue
plaintext = line.decode('utf-8') # this might still fail, as IRC doesn't define any encoding
logging.debug(f"Received: {plaintext}")
yield line
async def mainloop(self):
async for line in self._loop():
print(line)
``` here a sample of how to do it if you can't use .readline() ๐
(plus an example how to yield your lines in an async for loop)
you might eant to add a "sendline" method, and use that one for everything instead instead.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.