3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-01-24 03:04:05 +01:00

plugins/opercmds.py: change over to permissions API

This commit is contained in:
IotaSpencer 2016-12-10 00:48:39 -05:00 committed by James Lu
parent 69083cfcfd
commit 9199186309

View File

@ -3,13 +3,14 @@ opercmds.py: Provides a subset of network management commands.
""" """
from pylinkirc import utils from pylinkirc import utils
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.coremods import permissions
@utils.add_cmd @utils.add_cmd
def checkban(irc, source, args): def checkban(irc, source, args):
"""<banmask (nick!user@host or user@host)> [<nick or hostmask to check>] """<banmask (nick!user@host or user@host)> [<nick or hostmask to check>]
Oper only. If a nick or hostmask is given, return whether the given banmask will match it. Otherwise, returns a list of connected users that would be affected by such a ban, up to 50 results.""" Oper only. If a nick or hostmask is given, return whether the given banmask will match it. Otherwise, returns a list of connected users that would be affected by such a ban, up to 50 results."""
irc.checkAuthenticated(source) permissions.checkPermissions(irc, source, ['opercmds.checkban'])
try: try:
banmask = args[0] banmask = args[0]
@ -55,7 +56,7 @@ def jupe(irc, source, args):
Admin only, jupes the given server.""" Admin only, jupes the given server."""
# Check that the caller is either opered or logged in as admin. # Check that the caller is either opered or logged in as admin.
irc.checkAuthenticated(source, allowOper=False) permissions.checkPermissions(irc, source, ['opercmds.jupe'])
try: try:
servername = args[0] servername = args[0]
@ -82,7 +83,7 @@ def kick(irc, source, args):
"""<source> <channel> <user> [<reason>] """<source> <channel> <user> [<reason>]
Admin only. Kicks <user> from <channel> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server.""" Admin only. Kicks <user> from <channel> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server."""
irc.checkAuthenticated(source, allowOper=False) permissions.checkPermissions(irc, source, ['opercmds.kick'])
try: try:
sourcenick = args[0] sourcenick = args[0]
channel = irc.toLower(args[1]) channel = irc.toLower(args[1])
@ -123,7 +124,7 @@ def kill(irc, source, args):
"""<source> <target> [<reason>] """<source> <target> [<reason>]
Admin only. Kills <target> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server.""" Admin only. Kills <target> via <source>, where <source> is either the nick of a PyLink client or the SID of a PyLink server."""
irc.checkAuthenticated(source, allowOper=False) permissions.checkPermissions(irc, source, ['opercmds.kill'])
try: try:
sourcenick = args[0] sourcenick = args[0]
target = args[1] target = args[1]
@ -166,7 +167,7 @@ def mode(irc, source, args):
Oper-only, sets modes <modes> on the target channel.""" Oper-only, sets modes <modes> on the target channel."""
# Check that the caller is either opered or logged in as admin. # Check that the caller is either opered or logged in as admin.
irc.checkAuthenticated(source) permissions.checkPermissions(irc, source, ['opercmds.mode'])
try: try:
target, modes = args[0], args[1:] target, modes = args[0], args[1:]
@ -204,7 +205,7 @@ def topic(irc, source, args):
"""<channel> <topic> """<channel> <topic>
Admin only. Updates the topic in a channel.""" Admin only. Updates the topic in a channel."""
irc.checkAuthenticated(source, allowOper=False) permissions.checkPermissions(irc, source, ['opercmds.topic'])
try: try:
channel = args[0] channel = args[0]
topic = ' '.join(args[1:]) topic = ' '.join(args[1:])