From ec13bae7e62710c623088f68c05cd0fd612d6380 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 24 Dec 2016 10:57:26 -0800 Subject: [PATCH] opercmds: remove pointless source argument from 'kick' and 'kill' --- plugins/opercmds.py | 51 +++++++++++++-------------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/plugins/opercmds.py b/plugins/opercmds.py index 23033a0..4a5bf56 100644 --- a/plugins/opercmds.py +++ b/plugins/opercmds.py @@ -80,74 +80,53 @@ def jupe(irc, source, args): @utils.add_cmd def kick(irc, source, args): - """ [] + """ [] - Admin only. Kicks from via , where is either the nick of a PyLink client or the SID of a PyLink server.""" + Admin only. Kicks 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): - """ [] + """ [] - Admin only. Kills via , where 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