mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Made sure no messages longer than 512 bytes every leave the bot.
This commit is contained in:
parent
7bf41499cb
commit
10c7b7c0c0
@ -488,6 +488,9 @@ class Irc(IrcCommandDispatcher):
|
||||
s = '%s.outFilter returned None' % callback.name()
|
||||
debug.msg(s)
|
||||
return None
|
||||
if len(str(msg)) > 512:
|
||||
msg._str = msg._str[:500] + '\r\n'
|
||||
msg._len = len(str(msg))
|
||||
self.state.addMsg(self, msg)
|
||||
s = '%s %s' % (time.strftime(conf.logTimestampFormat), msg)
|
||||
debug.msg(s, 'low')
|
||||
@ -524,6 +527,11 @@ class Irc(IrcCommandDispatcher):
|
||||
if hasattr(self.driver, 'scheduleReconnect'):
|
||||
self.driver.scheduleReconnect()
|
||||
self.driver.die()
|
||||
elif 'too fast' in msg.args[0]:
|
||||
if hasattr(self.driver, 'reconnectWaitsIndex'):
|
||||
newIndex = len(self.driver.reconnectWaits)-1
|
||||
self.driver.reconnectWaitsIndex = newIndex
|
||||
self.driver.die()
|
||||
|
||||
def doNick(self, msg):
|
||||
"""Handles NICK messages."""
|
||||
|
@ -301,6 +301,11 @@ class IrcTestCase(unittest.TestCase):
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(msg.command == 'NOTICE')
|
||||
|
||||
def testNoMsgLongerThan512(self):
|
||||
self.irc.queueMsg(ircmsgs.privmsg('whocares', 'x'*1000))
|
||||
msg = self.irc.takeMsg()
|
||||
self.failUnless(len(msg) <= 512, 'len(msg) was %s' % len(msg))
|
||||
|
||||
def testReset(self):
|
||||
for msg in msgs:
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user