mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-30 14:49:28 +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
|
@utils.add_cmd
|
||||||
def kick(irc, source, args):
|
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'])
|
permissions.checkPermissions(irc, source, ['opercmds.kick'])
|
||||||
try:
|
try:
|
||||||
sourcenick = args[0]
|
channel = irc.toLower(args[0])
|
||||||
channel = irc.toLower(args[1])
|
target = args[1]
|
||||||
target = args[2]
|
reason = ' '.join(args[2:])
|
||||||
reason = ' '.join(args[3:])
|
|
||||||
except IndexError:
|
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
|
return
|
||||||
|
|
||||||
# Convert the source and target nicks to UIDs.
|
|
||||||
sender = irc.nickToUid(sourcenick) or sourcenick
|
|
||||||
targetu = irc.nickToUid(target)
|
targetu = irc.nickToUid(target)
|
||||||
|
|
||||||
if channel not in irc.channels: # KICK only works on channels that exist.
|
if channel not in irc.channels: # KICK only works on channels that exist.
|
||||||
irc.error("Unknown channel %r." % channel)
|
irc.error("Unknown channel %r." % channel)
|
||||||
return
|
return
|
||||||
|
|
||||||
if (not irc.isInternalClient(sender)) and \
|
if not targetu:
|
||||||
(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:
|
|
||||||
# Whatever we were told to kick doesn't exist!
|
# Whatever we were told to kick doesn't exist!
|
||||||
irc.error("No such target nick '%s'." % target)
|
irc.error("No such target nick '%s'." % target)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
sender = irc.pseudoclient.uid
|
||||||
irc.proto.kick(sender, channel, targetu, reason)
|
irc.proto.kick(sender, channel, targetu, reason)
|
||||||
irc.callHooks([sender, 'CHANCMDS_KICK', {'channel': channel, 'target': targetu,
|
irc.callHooks([sender, 'CHANCMDS_KICK', {'channel': channel, 'target': targetu,
|
||||||
'text': reason, 'parse_as': 'KICK'}])
|
'text': reason, 'parse_as': 'KICK'}])
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def kill(irc, source, args):
|
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'])
|
permissions.checkPermissions(irc, source, ['opercmds.kill'])
|
||||||
try:
|
try:
|
||||||
sourcenick = args[0]
|
target = args[0]
|
||||||
target = args[1]
|
reason = ' '.join(args[1:])
|
||||||
reason = ' '.join(args[2:])
|
|
||||||
except IndexError:
|
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
|
return
|
||||||
|
|
||||||
# Convert the source and target nicks to UIDs.
|
# Convert the source and target nicks to UIDs.
|
||||||
sender = irc.nickToUid(sourcenick) or sourcenick
|
sender = irc.pseudoclient.uid
|
||||||
targetu = irc.nickToUid(target)
|
targetu = irc.nickToUid(target)
|
||||||
userdata = irc.users.get(targetu)
|
userdata = irc.users.get(targetu)
|
||||||
|
|
||||||
if (not irc.isInternalClient(sender)) and \
|
if targetu not in irc.users:
|
||||||
(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:
|
|
||||||
# Whatever we were told to kick doesn't exist!
|
# Whatever we were told to kick doesn't exist!
|
||||||
irc.error("No such nick '%s'." % target)
|
irc.error("No such nick '%s'." % target)
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user