pydle
pydle copied to clipboard
Possible misformatting for set_mode messages
Attempts to set modelines on channels fail; pydle merely gets a banlist in return, probably indicating the message is misformatted.
Code:
await bot.set_mode("#test", "+b *!*@99.99.99.99")
Debug output:
DEBUG:XX:yy:>> MODE #test :+b *!*@99.99.99.99
DEBUG:XX:yy:<< :irc.fuelrats.dev 368 XX #test :End of Channel Ban List
WARNING:FIDO:fuelrats:Unknown command: [irc.local] 368 ['XX', '#test', 'End of Channel Ban List']
I do not think MODE messages can take a : before the modeline being set.
Edit:
await bot.set_mode("#test", "+b", "*!*@99.99.99.99")
does work. This is poorly documented, and not really a sane way to handle modelines, IMO.
The code
await bot.set_mode("#test", "+b *!*@99.99.99.99")
results in the ill-formed message MODE #test :+b *!*@99.99.99.99
because of the way that set_mode
calls rawmsg
:
https://github.com/Shizmob/pydle/blob/e583c9b57526604f87b01b8eacfdbee26dc31c2b/pydle/features/rfc1459/client.py#L370
The call chain ultimately lands in RFC1459Message.construct
:
https://github.com/Shizmob/pydle/blob/e583c9b57526604f87b01b8eacfdbee26dc31c2b/pydle/features/rfc1459/parsing.py#L97-L131
Due to the logic in the for
loop, it interprets the argument "+b *!*@99.99.99.99"
as a trailing parameter, which prepends a :
and produces an erroneous message.
I feel that the signature that @kenneaal attempted to use is more intuitive than the current one. At the very least, the documentation could be a bit clearer on usage.