3
0
mirror of https://github.com/jlu5/PyLink.git synced 2025-02-17 14:01:03 +01:00

networks: port to the permissions API (#367)

This commit is contained in:
James Lu 2016-12-09 21:55:34 -08:00
parent fb463e3b26
commit 60ca5af813

View File

@ -3,7 +3,7 @@ import importlib
from pylinkirc import utils, world, conf, classes from pylinkirc import utils, world, conf, classes
from pylinkirc.log import log from pylinkirc.log import log
from pylinkirc.coremods import control from pylinkirc.coremods import control, permissions
@utils.add_cmd @utils.add_cmd
def disconnect(irc, source, args): def disconnect(irc, source, args):
@ -12,6 +12,7 @@ def disconnect(irc, source, args):
Disconnects the network <network>. When all networks are disconnected, PyLink will automatically exit. Disconnects the network <network>. When all networks are disconnected, PyLink will automatically exit.
To reconnect a network disconnected using this command, use REHASH to reload the networks list.""" To reconnect a network disconnected using this command, use REHASH to reload the networks list."""
permissions.checkPermissions(irc, source, ['networks.disconnect'])
try: try:
netname = args[0] netname = args[0]
network = world.networkobjects[netname] network = world.networkobjects[netname]
@ -31,7 +32,7 @@ def autoconnect(irc, source, args):
Sets the autoconnect time for <network> to <seconds>. Sets the autoconnect time for <network> to <seconds>.
You can disable autoconnect for a network by setting <seconds> to a negative value.""" You can disable autoconnect for a network by setting <seconds> to a negative value."""
irc.checkAuthenticated(source) permissions.checkPermissions(irc, source, ['networks.autoconnect'])
try: try:
netname = args[0] netname = args[0]
seconds = float(args[1]) seconds = float(args[1])
@ -53,7 +54,7 @@ def remote(irc, source, args):
"""<network> <command> """<network> <command>
Runs <command> on the remote network <network>. No replies are sent back due to protocol limitations.""" Runs <command> on the remote network <network>. No replies are sent back due to protocol limitations."""
irc.checkAuthenticated(source, allowOper=False) permissions.checkPermissions(irc, source, ['networks.remote'])
try: try:
netname = args[0] netname = args[0]
@ -89,7 +90,7 @@ def reloadproto(irc, source, args):
"""<protocol module name> """<protocol module name>
Reloads the given protocol module without restart. You will have to manually disconnect and reconnect any network using the module for changes to apply.""" Reloads the given protocol module without restart. You will have to manually disconnect and reconnect any network using the module for changes to apply."""
irc.checkAuthenticated(source) permissions.checkPermissions(irc, source, ['networks.reloadproto'])
try: try:
name = args[0] name = args[0]
except IndexError: except IndexError: