Only pass bytestrings (and not bytearrays) to user code
This commit is contained in:
parent
cdd91bb49e
commit
b2ca8a0599
|
@ -7,6 +7,7 @@ def initialize(*, config):
|
||||||
|
|
||||||
# on_connect(*, irc)
|
# on_connect(*, irc)
|
||||||
# Called after IRC bot has connected and sent the USER/NICk commands but not yet attempted anything else
|
# Called after IRC bot has connected and sent the USER/NICk commands but not yet attempted anything else
|
||||||
|
# Called for every reconnect
|
||||||
# Blocks the bot until it's done, including PING/PONG handling
|
# Blocks the bot until it's done, including PING/PONG handling
|
||||||
# irc is the IRC API object
|
# irc is the IRC API object
|
||||||
def on_connect(*, irc):
|
def on_connect(*, irc):
|
||||||
|
@ -26,7 +27,7 @@ def on_quit(*, irc):
|
||||||
# nick is who sent the message
|
# nick is who sent the message
|
||||||
# channel is where you should send the response (note: in queries nick == channel)
|
# channel is where you should send the response (note: in queries nick == channel)
|
||||||
# irc is the IRC API object
|
# irc is the IRC API object
|
||||||
# All strings are bytestrings or bytearrays
|
# All strings are bytestrings
|
||||||
def handle_message(*, prefix, message, nick, channel, irc):
|
def handle_message(*, prefix, message, nick, channel, irc):
|
||||||
...
|
...
|
||||||
|
|
||||||
|
@ -36,6 +37,6 @@ def handle_message(*, prefix, message, nick, channel, irc):
|
||||||
# command is the command or number code
|
# command is the command or number code
|
||||||
# arguments is rest of the arguments of the command, represented as a list. ':'-arguments are handled automatically
|
# arguments is rest of the arguments of the command, represented as a list. ':'-arguments are handled automatically
|
||||||
# irc is the IRC API object
|
# irc is the IRC API object
|
||||||
# All strings are bytestrings or bytearrays
|
# All strings are bytestrings
|
||||||
def handle_nonmessage(*, prefix, command, arguments, irc):
|
def handle_nonmessage(*, prefix, command, arguments, irc):
|
||||||
...
|
...
|
||||||
|
|
|
@ -194,6 +194,8 @@ class ServerThread(threading.Thread):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.logging_channel.send((logmessage_types.received, line.decode(encoding = 'utf-8', errors = 'replace')))
|
self.logging_channel.send((logmessage_types.received, line.decode(encoding = 'utf-8', errors = 'replace')))
|
||||||
|
# Ensure we have a bytestring, because bytearray can be annoying to deal with
|
||||||
|
line = bytes(line)
|
||||||
line_handling.handle_line(line, irc = self.api)
|
line_handling.handle_line(line, irc = self.api)
|
||||||
|
|
||||||
def mainloop(self):
|
def mainloop(self):
|
||||||
|
|
|
@ -114,7 +114,7 @@ class LineHandlerThread(threading.Thread):
|
||||||
try:
|
try:
|
||||||
prefix, command, arguments = parse_line(self.line)
|
prefix, command, arguments = parse_line(self.line)
|
||||||
except LineParsingError:
|
except LineParsingError:
|
||||||
irc.error("Cannot parse line" + self.line.decode(encoding = 'utf-8', errors = 'replace'))
|
irc.error("Cannot parse line: " + self.line.decode(encoding = 'utf-8', errors = 'replace'))
|
||||||
|
|
||||||
if command.upper() == b'PRIVMSG':
|
if command.upper() == b'PRIVMSG':
|
||||||
# PRIVMSG should have two parameters: recipient and the message
|
# PRIVMSG should have two parameters: recipient and the message
|
||||||
|
|
Loading…
Reference in New Issue