mirror of
https://github.com/jlu5/PyLink.git
synced 2024-11-01 09:19:23 +01:00
plugins/admin.py: remove -client suffixes from commands, and fix argument checking
This commit is contained in:
parent
35f8a0e25f
commit
edfcacfdd1
@ -35,7 +35,7 @@ def quitclient(irc, source, args):
|
|||||||
try:
|
try:
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
except IndexError:
|
except IndexError:
|
||||||
utils.msg(irc, source, "Error: not enough arguments. Needs 1: nick.")
|
utils.msg(irc, source, "Error: not enough arguments. Needs 1-2: nick, reason (optional).")
|
||||||
return
|
return
|
||||||
if irc.pseudoclient.uid == utils.nickToUid(irc, nick):
|
if irc.pseudoclient.uid == utils.nickToUid(irc, nick):
|
||||||
utils.msg(irc, source, "Error: cannot quit the main PyLink PseudoClient!")
|
utils.msg(irc, source, "Error: cannot quit the main PyLink PseudoClient!")
|
||||||
@ -44,7 +44,6 @@ def quitclient(irc, source, args):
|
|||||||
quitmsg = ' '.join(args[1:]) or 'Client quit'
|
quitmsg = ' '.join(args[1:]) or 'Client quit'
|
||||||
irc.proto.quitClient(irc, u, quitmsg)
|
irc.proto.quitClient(irc, u, quitmsg)
|
||||||
|
|
||||||
@utils.add_cmd
|
|
||||||
def joinclient(irc, source, args):
|
def joinclient(irc, source, args):
|
||||||
checkauthenticated(irc, source)
|
checkauthenticated(irc, source)
|
||||||
try:
|
try:
|
||||||
@ -57,13 +56,14 @@ def joinclient(irc, source, args):
|
|||||||
return
|
return
|
||||||
u = utils.nickToUid(irc, nick)
|
u = utils.nickToUid(irc, nick)
|
||||||
for channel in clist:
|
for channel in clist:
|
||||||
if not channel.startswith('#'):
|
if not utils.isChannel(channel):
|
||||||
utils.msg(irc, source, "Error: channel names must start with #.")
|
utils.msg(irc, source, "Error: Invalid channel name %r." % channel)
|
||||||
return
|
return
|
||||||
irc.proto.joinClient(irc, u, channel)
|
irc.proto.joinClient(irc, u, channel)
|
||||||
|
utils.add_cmd(joinclient, name='join')
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def nickclient(irc, source, args):
|
def nick(irc, source, args):
|
||||||
checkauthenticated(irc, source)
|
checkauthenticated(irc, source)
|
||||||
try:
|
try:
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
@ -72,10 +72,15 @@ def nickclient(irc, source, args):
|
|||||||
utils.msg(irc, source, "Error: not enough arguments. Needs 2: nick, newnick.")
|
utils.msg(irc, source, "Error: not enough arguments. Needs 2: nick, newnick.")
|
||||||
return
|
return
|
||||||
u = utils.nickToUid(irc, nick)
|
u = utils.nickToUid(irc, nick)
|
||||||
|
if newnick in ('0', u):
|
||||||
|
newnick = u
|
||||||
|
elif not utils.isNick(newnick):
|
||||||
|
utils.msg(irc, source, 'Error: Invalid nickname %r.' % newnick)
|
||||||
|
return
|
||||||
irc.proto.nickClient(irc, u, newnick)
|
irc.proto.nickClient(irc, u, newnick)
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def partclient(irc, source, args):
|
def part(irc, source, args):
|
||||||
checkauthenticated(irc, source)
|
checkauthenticated(irc, source)
|
||||||
try:
|
try:
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
@ -86,13 +91,13 @@ def partclient(irc, source, args):
|
|||||||
return
|
return
|
||||||
u = utils.nickToUid(irc, nick)
|
u = utils.nickToUid(irc, nick)
|
||||||
for channel in clist:
|
for channel in clist:
|
||||||
if not channel.startswith('#'):
|
if not utils.isChannel(channel):
|
||||||
utils.msg(irc, source, "Error: channel names must start with #.")
|
utils.msg(irc, source, "Error: Invalid channel name %r." % channel)
|
||||||
return
|
return
|
||||||
irc.proto.partClient(irc, u, channel, reason)
|
irc.proto.partClient(irc, u, channel, reason)
|
||||||
|
|
||||||
@utils.add_cmd
|
@utils.add_cmd
|
||||||
def kickclient(irc, source, args):
|
def kick(irc, source, args):
|
||||||
checkauthenticated(irc, source)
|
checkauthenticated(irc, source)
|
||||||
try:
|
try:
|
||||||
nick = args[0]
|
nick = args[0]
|
||||||
@ -100,12 +105,12 @@ def kickclient(irc, source, args):
|
|||||||
target = args[2]
|
target = args[2]
|
||||||
reason = ' '.join(args[3:])
|
reason = ' '.join(args[3:])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
utils.msg(irc, source, "Error: not enough arguments. Needs 3-4: nick, channel, target, reason (optional).")
|
utils.msg(irc, source, "Error: not enough arguments. Needs 3-4: source nick, channel, target, reason (optional).")
|
||||||
return
|
return
|
||||||
u = utils.nickToUid(irc, nick)
|
u = utils.nickToUid(irc, nick)
|
||||||
targetu = utils.nickToUid(irc, target)
|
targetu = utils.nickToUid(irc, target)
|
||||||
if not channel.startswith('#'):
|
if not utils.isChannel(channel):
|
||||||
utils.msg(irc, source, "Error: channel names must start with #.")
|
utils.msg(irc, source, "Error: Invalid channel name %r." % channel)
|
||||||
return
|
return
|
||||||
irc.proto.kickClient(irc, u, channel, targetu, reason)
|
irc.proto.kickClient(irc, u, channel, targetu, reason)
|
||||||
|
|
||||||
@ -129,9 +134,9 @@ def showuser(irc, source, args):
|
|||||||
def tell(irc, source, args):
|
def tell(irc, source, args):
|
||||||
checkauthenticated(irc, source)
|
checkauthenticated(irc, source)
|
||||||
try:
|
try:
|
||||||
source, target, text = args[0], args[1], ' '.join(args[2:])
|
target, text = args[0], ' '.join(args[1:])
|
||||||
except IndexError:
|
except IndexError:
|
||||||
utils.msg(irc, source, 'Error: not enough arguments.')
|
utils.msg(irc, source, 'Error: not enough arguments. Needs 2: target, text.')
|
||||||
return
|
return
|
||||||
targetuid = utils.nickToUid(irc, target)
|
targetuid = utils.nickToUid(irc, target)
|
||||||
if targetuid is None:
|
if targetuid is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user