mirror of
https://github.com/jlu5/PyLink.git
synced 2025-01-26 04:04:22 +01:00
protocols/: Fix args parsing when the sender UID == the last argument
args.index() would return 0 instead of the index of the current argument.
This commit is contained in:
parent
da0101e750
commit
977b69b8e9
@ -563,21 +563,20 @@ def handle_events(irc, data):
|
|||||||
irc.connected.set()
|
irc.connected.set()
|
||||||
try:
|
try:
|
||||||
real_args = []
|
real_args = []
|
||||||
for arg in args:
|
for idx, arg in enumerate(args):
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
# If the argument starts with ':' and ISN'T the first argument.
|
# If the argument starts with ':' and ISN'T the first argument.
|
||||||
# The first argument is used for denoting the source UID/SID.
|
# The first argument is used for denoting the source UID/SID.
|
||||||
if arg.startswith(':') and args.index(arg) != 0:
|
if arg.startswith(':') and idx != 0:
|
||||||
# : is used for multi-word arguments that last until the end
|
# : is used for multi-word arguments that last until the end
|
||||||
# of the message. We can use list splicing here to turn them all
|
# of the message. We can use list splicing here to turn them all
|
||||||
# into one argument.
|
# into one argument.
|
||||||
index = args.index(arg) # Get the array index of the multi-word arg
|
|
||||||
# Set the last arg to a joined version of the remaining args
|
# Set the last arg to a joined version of the remaining args
|
||||||
arg = args[index:]
|
arg = args[idx:]
|
||||||
arg = ' '.join(arg)[1:]
|
arg = ' '.join(arg)[1:]
|
||||||
# Cut the original argument list right before the multi-word arg,
|
# Cut the original argument list right before the multi-word arg,
|
||||||
# and then append the multi-word arg.
|
# and then append the multi-word arg.
|
||||||
real_args = args[:index]
|
real_args = args[:idx]
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
break
|
break
|
||||||
real_args[0] = real_args[0].split(':', 1)[1]
|
real_args[0] = real_args[0].split(':', 1)[1]
|
||||||
|
@ -564,21 +564,20 @@ def handle_events(irc, data):
|
|||||||
endburst_timer.start()
|
endburst_timer.start()
|
||||||
try:
|
try:
|
||||||
real_args = []
|
real_args = []
|
||||||
for arg in args:
|
for idx, arg in enumerate(args):
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
# If the argument starts with ':' and ISN'T the first argument.
|
# If the argument starts with ':' and ISN'T the first argument.
|
||||||
# The first argument is used for denoting the source UID/SID.
|
# The first argument is used for denoting the source UID/SID.
|
||||||
if arg.startswith(':') and args.index(arg) != 0:
|
if arg.startswith(':') and idx != 0:
|
||||||
# : is used for multi-word arguments that last until the end
|
# : is used for multi-word arguments that last until the end
|
||||||
# of the message. We can use list splicing here to turn them all
|
# of the message. We can use list splicing here to turn them all
|
||||||
# into one argument.
|
# into one argument.
|
||||||
index = args.index(arg) # Get the array index of the multi-word arg
|
|
||||||
# Set the last arg to a joined version of the remaining args
|
# Set the last arg to a joined version of the remaining args
|
||||||
arg = args[index:]
|
arg = args[idx:]
|
||||||
arg = ' '.join(arg)[1:]
|
arg = ' '.join(arg)[1:]
|
||||||
# Cut the original argument list right before the multi-word arg,
|
# Cut the original argument list right before the multi-word arg,
|
||||||
# and then append the multi-word arg.
|
# and then append the multi-word arg.
|
||||||
real_args = args[:index]
|
real_args = args[:idx]
|
||||||
real_args.append(arg)
|
real_args.append(arg)
|
||||||
break
|
break
|
||||||
real_args[0] = real_args[0].split(':', 1)[1]
|
real_args[0] = real_args[0].split(':', 1)[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user