Only pass bytestrings (and not bytearrays) to user code
This commit is contained in:
parent
cdd91bb49e
commit
b2ca8a0599
3 changed files with 6 additions and 3 deletions
|
@ -7,6 +7,7 @@ def initialize(*, config):
|
|||
|
||||
# on_connect(*, irc)
|
||||
# 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
|
||||
# irc is the IRC API object
|
||||
def on_connect(*, irc):
|
||||
|
@ -26,7 +27,7 @@ def on_quit(*, irc):
|
|||
# nick is who sent the message
|
||||
# channel is where you should send the response (note: in queries nick == channel)
|
||||
# irc is the IRC API object
|
||||
# All strings are bytestrings or bytearrays
|
||||
# All strings are bytestrings
|
||||
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
|
||||
# arguments is rest of the arguments of the command, represented as a list. ':'-arguments are handled automatically
|
||||
# irc is the IRC API object
|
||||
# All strings are bytestrings or bytearrays
|
||||
# All strings are bytestrings
|
||||
def handle_nonmessage(*, prefix, command, arguments, irc):
|
||||
...
|
||||
|
|
|
@ -194,6 +194,8 @@ class ServerThread(threading.Thread):
|
|||
pass
|
||||
else:
|
||||
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)
|
||||
|
||||
def mainloop(self):
|
||||
|
|
|
@ -114,7 +114,7 @@ class LineHandlerThread(threading.Thread):
|
|||
try:
|
||||
prefix, command, arguments = parse_line(self.line)
|
||||
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':
|
||||
# PRIVMSG should have two parameters: recipient and the message
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue