Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
opercmds: add chghost, chgident, chgname commands (#488)
Browse files Browse the repository at this point in the history
Closes #481.
  • Loading branch information
cooper authored and jlu5 committed Jul 14, 2017
1 parent 5a5a98c commit d1b3213
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/permissions-reference.md
Expand Up @@ -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.
Expand Down
40 changes: 40 additions & 0 deletions plugins/opercmds.py
Expand Up @@ -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.