From d1b321310e8d882429f4b5c1173cbf8f52a7a5b4 Mon Sep 17 00:00:00 2001 From: Mitchell Cooper Date: Fri, 14 Jul 2017 19:41:16 -0400 Subject: [PATCH] opercmds: add chghost, chgident, chgname commands (#488) Closes #481. --- docs/permissions-reference.md | 3 +++ plugins/opercmds.py | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/docs/permissions-reference.md b/docs/permissions-reference.md index 5ad9b23a..cbebbc26 100644 --- a/docs/permissions-reference.md +++ b/docs/permissions-reference.md @@ -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. diff --git a/plugins/opercmds.py b/plugins/opercmds.py index 3ec3cf84..5fe7f715 100644 --- a/plugins/opercmds.py +++ b/plugins/opercmds.py @@ -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): + """ + + Admin only. Changes the visible host of the target user.""" + chgfield(irc, source, args, 'host') + +@utils.add_cmd +def chgident(irc, source, args): + """ + + Admin only. Changes the ident of the target user.""" + chgfield(irc, source, args, 'ident') + +@utils.add_cmd +def chgname(irc, source, args): + """ + + 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.")