mirror of
https://github.com/jlu5/PyLink.git
synced 2025-02-26 02:10:39 +01:00
ts6: rewrite MODE wrapping to check message length and argument count (#253)
This commit is contained in:
parent
e2c0877e9b
commit
70deb5a285
@ -10,6 +10,8 @@ from pylinkirc.classes import *
|
|||||||
from pylinkirc.log import log
|
from pylinkirc.log import log
|
||||||
from pylinkirc.protocols.ts6_common import *
|
from pylinkirc.protocols.ts6_common import *
|
||||||
|
|
||||||
|
S2S_BUFSIZE = 510
|
||||||
|
|
||||||
class TS6Protocol(TS6BaseProtocol):
|
class TS6Protocol(TS6BaseProtocol):
|
||||||
def __init__(self, irc):
|
def __init__(self, irc):
|
||||||
super().__init__(irc)
|
super().__init__(irc)
|
||||||
@ -183,12 +185,11 @@ class TS6Protocol(TS6BaseProtocol):
|
|||||||
|
|
||||||
# On output, at most ten cmode parameters should be sent; if there are more,
|
# On output, at most ten cmode parameters should be sent; if there are more,
|
||||||
# multiple TMODE messages should be sent.
|
# multiple TMODE messages should be sent.
|
||||||
while modes[:10]:
|
msgprefix = ':%s TMODE %s %s ' % (numeric, ts, target)
|
||||||
# Seriously, though. If you send more than 10 mode parameters in
|
bufsize = S2S_BUFSIZE - len(msgprefix)
|
||||||
# a line, charybdis will silently REJECT the entire command!
|
|
||||||
joinedmodes = self.irc.joinModes([m for m in modes[:10]])
|
for modestr in self.irc.wrapModes(modes, bufsize, max_modes_per_msg=10):
|
||||||
modes = modes[10:]
|
self.irc.send(msgprefix + modestr)
|
||||||
self._send(numeric, 'TMODE %s %s %s' % (ts, target, joinedmodes))
|
|
||||||
else:
|
else:
|
||||||
joinedmodes = self.irc.joinModes(modes)
|
joinedmodes = self.irc.joinModes(modes)
|
||||||
self._send(numeric, 'MODE %s %s' % (target, joinedmodes))
|
self._send(numeric, 'MODE %s %s' % (target, joinedmodes))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user