use LenientDecodingLineBuffer in bot guts
should make the bot more resilient to clients that send non-unicode text
This commit is contained in:
parent
0c7b880517
commit
e2d4e29750
|
@ -16,6 +16,7 @@ import time
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
|
import irc.buffer
|
||||||
import irc.client
|
import irc.client
|
||||||
from irc.connection import Factory
|
from irc.connection import Factory
|
||||||
from irc.dict import IRCDict
|
from irc.dict import IRCDict
|
||||||
|
@ -43,6 +44,17 @@ class PrioritizedRegexHandler(collections.namedtuple('Base', ('priority', 'regex
|
||||||
return self.priority < other.priority
|
return self.priority < other.priority
|
||||||
|
|
||||||
|
|
||||||
|
class LenientServerConnection(irc.client.ServerConnection):
|
||||||
|
"""
|
||||||
|
An IRC server connection.
|
||||||
|
|
||||||
|
ServerConnection objects are instantiated by calling the server
|
||||||
|
method on a Reactor object.
|
||||||
|
"""
|
||||||
|
|
||||||
|
buffer_class = irc.buffer.LenientDecodingLineBuffer
|
||||||
|
|
||||||
|
|
||||||
class DrReactor(irc.client.Reactor):
|
class DrReactor(irc.client.Reactor):
|
||||||
"""Customize the basic IRC library's Reactor with more features."""
|
"""Customize the basic IRC library's Reactor with more features."""
|
||||||
|
|
||||||
|
@ -56,6 +68,14 @@ class DrReactor(irc.client.Reactor):
|
||||||
on_schedule=on_schedule)
|
on_schedule=on_schedule)
|
||||||
self.regex_handlers = {}
|
self.regex_handlers = {}
|
||||||
|
|
||||||
|
def server(self):
|
||||||
|
"""Creates and returns a ServerConnection object."""
|
||||||
|
|
||||||
|
c = LenientServerConnection(self)
|
||||||
|
with self.mutex:
|
||||||
|
self.connections.append(c)
|
||||||
|
return c
|
||||||
|
|
||||||
def add_global_regex_handler(self, events, regex, handler, priority=0):
|
def add_global_regex_handler(self, events, regex, handler, priority=0):
|
||||||
"""Adds a global handler function for a specific event type and regex.
|
"""Adds a global handler function for a specific event type and regex.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue