Permalink
Browse files

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

Closes #481.
  • Loading branch information...
cooper authored and jlu5 committed Jul 14, 2017
1 parent 5a5a98c commit d1b321310e8d882429f4b5c1173cbf8f52a7a5b4
Showing with 43 additions and 0 deletions.
  1. +3 −0 docs/permissions-reference.md
  2. +40 −0 plugins/opercmds.py
@@ -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.
@@ -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.")

0 comments on commit d1b3213

Please sign in to comment.