mirror of
https://github.com/jlu5/PyLink.git
synced 2024-12-24 19:52:53 +01:00
Move ts6_common.parseTS6Args to ts6_common.parsePrefixedArgs
This commit is contained in:
parent
0a0e19d4c2
commit
1770058e1b
@ -1256,6 +1256,13 @@ class Protocol():
|
|||||||
target = self.irc.nickToUid(target) or target
|
target = self.irc.nickToUid(target) or target
|
||||||
return target
|
return target
|
||||||
|
|
||||||
|
def parsePrefixedArgs(self, args):
|
||||||
|
"""Similar to parseArgs(), but stripping leading colons from the first argument
|
||||||
|
of a line (usually the sender field)."""
|
||||||
|
args = self.parseArgs(args)
|
||||||
|
args[0] = args[0].split(':', 1)[1]
|
||||||
|
return args
|
||||||
|
|
||||||
### FakeIRC classes, used for test cases
|
### FakeIRC classes, used for test cases
|
||||||
|
|
||||||
class FakeIRC(Irc):
|
class FakeIRC(Irc):
|
||||||
|
@ -113,13 +113,6 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
|||||||
"""Sends a TS6-style raw command from a source numeric to the self.irc connection given."""
|
"""Sends a TS6-style raw command from a source numeric to the self.irc connection given."""
|
||||||
self.irc.send(':%s %s' % (source, msg))
|
self.irc.send(':%s %s' % (source, msg))
|
||||||
|
|
||||||
def parseTS6Args(self, args):
|
|
||||||
"""Similar to parseArgs(), but stripping leading colons from the first argument
|
|
||||||
of a line (usually the sender field)."""
|
|
||||||
args = self.parseArgs(args)
|
|
||||||
args[0] = args[0].split(':', 1)[1]
|
|
||||||
return args
|
|
||||||
|
|
||||||
def _getOutgoingNick(self, uid):
|
def _getOutgoingNick(self, uid):
|
||||||
"""
|
"""
|
||||||
Returns the outgoing nick for the given UID. In the base ts6_common implementation,
|
Returns the outgoing nick for the given UID. In the base ts6_common implementation,
|
||||||
@ -314,7 +307,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
|||||||
"""
|
"""
|
||||||
data = data.split(" ")
|
data = data.split(" ")
|
||||||
try: # Message starts with a SID/UID prefix.
|
try: # Message starts with a SID/UID prefix.
|
||||||
args = self.parseTS6Args(data)
|
args = self.parsePrefixedArgs(data)
|
||||||
sender = args[0]
|
sender = args[0]
|
||||||
command = args[1]
|
command = args[1]
|
||||||
args = args[2:]
|
args = args[2:]
|
||||||
@ -328,7 +321,7 @@ class TS6BaseProtocol(IRCS2SProtocol):
|
|||||||
# Sender is a user.
|
# Sender is a user.
|
||||||
numeric = self._getUid(sender)
|
numeric = self._getUid(sender)
|
||||||
|
|
||||||
# parseTS6Args() will raise IndexError if the TS6 sender prefix is missing.
|
# parsePrefixedArgs() will raise IndexError if the TS6 sender prefix is missing.
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# Raw command without an explicit sender; assume it's being sent by our uplink.
|
# Raw command without an explicit sender; assume it's being sent by our uplink.
|
||||||
args = self.parseArgs(data)
|
args = self.parseArgs(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user