3
0
mirror of https://github.com/jlu5/PyLink.git synced 2024-11-30 14:49:28 +01:00

opercmds: add chghost, chgident, chgname commands (#488)

Closes #481.
This commit is contained in:
Mitchell Cooper 2017-07-14 19:41:16 -04:00 committed by James Lu
parent 5a5a98c4ef
commit d1b321310e
2 changed files with 43 additions and 0 deletions

View File

@ -77,6 +77,9 @@ Remote versions of the `manage`, `list`, `sync`, and `clear` commands also exist
- `opercmds.kill` - Allows access to the `kill` command.
- `opercmds.mode` - Allows access to the `mode` command.
- `opercmds.topic` - Allows access to the `topic` command.
- `opercmds.chghost` - Allows access to the `chghost` command.
- `opercmds.chgident` - Allows access to the `chgident` command.
- `opercmds.chgname` - Allows access to the `chgname` command.
## Relay
- `relay.claim` - Allows access to the `claim` command.

View File

@ -204,3 +204,43 @@ def topic(irc, source, args):
irc.call_hooks([irc.pseudoclient.uid, 'CHANCMDS_TOPIC',
{'channel': channel, 'text': topic, 'setter': source,
'parse_as': 'TOPIC'}])
@utils.add_cmd
def chghost(irc, source, args):
"""<user> <new host>
Admin only. Changes the visible host of the target user."""
chgfield(irc, source, args, 'host')
@utils.add_cmd
def chgident(irc, source, args):
"""<user> <new ident>
Admin only. Changes the ident of the target user."""
chgfield(irc, source, args, 'ident')
@utils.add_cmd
def chgname(irc, source, args):
"""<user> <new name>
Admin only. Changes the GECOS (realname) of the target user."""
chgfield(irc, source, args, 'name', 'GECOS')
def chgfield(irc, source, args, human_field, internal_field=None):
permissions.checkPermissions(irc, source, ['opercmds.chg' + human_field])
try:
target = args[0]
new = args[1]
except IndexError:
irc.error("Not enough arguments. Needs 2: target, new %s." % human_field)
return
# Find the user
targetu = irc.nick_to_uid(target)
if targetu not in irc.users:
irc.error("No such nick %r." % target)
return
internal_field = internal_field or human_field.upper()
irc.update_client(targetu, internal_field, new)
irc.reply("Done.")