mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 05: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()
|
s = '%s.outFilter returned None' % callback.name()
|
||||||
debug.msg(s)
|
debug.msg(s)
|
||||||
return None
|
return None
|
||||||
|
if len(str(msg)) > 512:
|
||||||
|
msg._str = msg._str[:500] + '\r\n'
|
||||||
|
msg._len = len(str(msg))
|
||||||
self.state.addMsg(self, msg)
|
self.state.addMsg(self, msg)
|
||||||
s = '%s %s' % (time.strftime(conf.logTimestampFormat), msg)
|
s = '%s %s' % (time.strftime(conf.logTimestampFormat), msg)
|
||||||
debug.msg(s, 'low')
|
debug.msg(s, 'low')
|
||||||
@ -524,6 +527,11 @@ class Irc(IrcCommandDispatcher):
|
|||||||
if hasattr(self.driver, 'scheduleReconnect'):
|
if hasattr(self.driver, 'scheduleReconnect'):
|
||||||
self.driver.scheduleReconnect()
|
self.driver.scheduleReconnect()
|
||||||
self.driver.die()
|
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):
|
def doNick(self, msg):
|
||||||
"""Handles NICK messages."""
|
"""Handles NICK messages."""
|
||||||
|
@ -301,6 +301,11 @@ class IrcTestCase(unittest.TestCase):
|
|||||||
msg = self.irc.takeMsg()
|
msg = self.irc.takeMsg()
|
||||||
self.failUnless(msg.command == 'NOTICE')
|
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):
|
def testReset(self):
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user