mirror of
				https://github.com/jlu5/PyLink.git
				synced 2025-11-04 08:57:25 +01:00 
			
		
		
		
	opercmds: remove pointless source argument from 'kick' and 'kill'
This commit is contained in:
		
							parent
							
								
									3e6550b8ad
								
							
						
					
					
						commit
						ec13bae7e6
					
				@ -80,74 +80,53 @@ def jupe(irc, source, args):
 | 
			
		||||
 | 
			
		||||
@utils.add_cmd
 | 
			
		||||
def kick(irc, source, args):
 | 
			
		||||
    """<source> <channel> <user> [<reason>]
 | 
			
		||||
    """<channel> <user> [<reason>]
 | 
			
		||||
 | 
			
		||||
    Admin only. Kicks <user> from <channel> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server."""
 | 
			
		||||
    Admin only. Kicks <user> from the specified channel."""
 | 
			
		||||
    permissions.checkPermissions(irc, source, ['opercmds.kick'])
 | 
			
		||||
    try:
 | 
			
		||||
        sourcenick = args[0]
 | 
			
		||||
        channel = irc.toLower(args[1])
 | 
			
		||||
        target = args[2]
 | 
			
		||||
        reason = ' '.join(args[3:])
 | 
			
		||||
        channel = irc.toLower(args[0])
 | 
			
		||||
        target = args[1]
 | 
			
		||||
        reason = ' '.join(args[2:])
 | 
			
		||||
    except IndexError:
 | 
			
		||||
        irc.error("Not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).")
 | 
			
		||||
        irc.error("Not enough arguments. Needs 2-3: channel, target, reason (optional).")
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    # Convert the source and target nicks to UIDs.
 | 
			
		||||
    sender = irc.nickToUid(sourcenick) or sourcenick
 | 
			
		||||
    targetu = irc.nickToUid(target)
 | 
			
		||||
 | 
			
		||||
    if channel not in irc.channels:  # KICK only works on channels that exist.
 | 
			
		||||
        irc.error("Unknown channel %r." % channel)
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    if (not irc.isInternalClient(sender)) and \
 | 
			
		||||
            (not irc.isInternalServer(sender)):
 | 
			
		||||
        # Whatever we were told to send the kick from wasn't valid; try to be
 | 
			
		||||
        # somewhat user friendly in the error message
 | 
			
		||||
        irc.error("No such PyLink client '%s'. The first argument to "
 | 
			
		||||
                  "KICK should be the name of a PyLink client (e.g. '%s'; see "
 | 
			
		||||
                  "'help kick' for details." % (sourcenick,
 | 
			
		||||
                  irc.pseudoclient.nick))
 | 
			
		||||
        return
 | 
			
		||||
    elif not targetu:
 | 
			
		||||
    if not targetu:
 | 
			
		||||
        # Whatever we were told to kick doesn't exist!
 | 
			
		||||
        irc.error("No such target nick '%s'." % target)
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    sender = irc.pseudoclient.uid
 | 
			
		||||
    irc.proto.kick(sender, channel, targetu, reason)
 | 
			
		||||
    irc.callHooks([sender, 'CHANCMDS_KICK', {'channel': channel, 'target': targetu,
 | 
			
		||||
                                        'text': reason, 'parse_as': 'KICK'}])
 | 
			
		||||
 | 
			
		||||
@utils.add_cmd
 | 
			
		||||
def kill(irc, source, args):
 | 
			
		||||
    """<source> <target> [<reason>]
 | 
			
		||||
    """<target> [<reason>]
 | 
			
		||||
 | 
			
		||||
    Admin only. Kills <target> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server."""
 | 
			
		||||
    Admin only. Kills the given target."""
 | 
			
		||||
    permissions.checkPermissions(irc, source, ['opercmds.kill'])
 | 
			
		||||
    try:
 | 
			
		||||
        sourcenick = args[0]
 | 
			
		||||
        target = args[1]
 | 
			
		||||
        reason = ' '.join(args[2:])
 | 
			
		||||
        target = args[0]
 | 
			
		||||
        reason = ' '.join(args[1:])
 | 
			
		||||
    except IndexError:
 | 
			
		||||
        irc.error("Not enough arguments. Needs 3-4: source nick, target, reason (optional).")
 | 
			
		||||
        irc.error("Not enough arguments. Needs 1-2: target, reason (optional).")
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
    # Convert the source and target nicks to UIDs.
 | 
			
		||||
    sender = irc.nickToUid(sourcenick) or sourcenick
 | 
			
		||||
    sender = irc.pseudoclient.uid
 | 
			
		||||
    targetu = irc.nickToUid(target)
 | 
			
		||||
    userdata = irc.users.get(targetu)
 | 
			
		||||
 | 
			
		||||
    if (not irc.isInternalClient(sender)) and \
 | 
			
		||||
            (not irc.isInternalServer(sender)):
 | 
			
		||||
        # Whatever we were told to send the kick from wasn't valid; try to be
 | 
			
		||||
        # somewhat user friendly in the error message
 | 
			
		||||
        irc.error("No such PyLink client '%s'. The first argument to "
 | 
			
		||||
                  "KILL should be the name of a PyLink client (e.g. '%s'; see "
 | 
			
		||||
                  "'help kill' for details." % (sourcenick,
 | 
			
		||||
                  irc.pseudoclient.nick))
 | 
			
		||||
        return
 | 
			
		||||
    elif targetu not in irc.users:
 | 
			
		||||
    if targetu not in irc.users:
 | 
			
		||||
        # Whatever we were told to kick doesn't exist!
 | 
			
		||||
        irc.error("No such nick '%s'." % target)
 | 
			
		||||
        return
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user