~admin: Move admin cmds to their their own module

This commit moves tilde commands for administrative purposes, which are
only usable by administrators, to their own module called tildeadmin.
master
Julian Marcos 2023-09-02 22:41:45 +02:00
parent 0123d4d4dd
commit 9cbe6b4d1d
No known key found for this signature in database
GPG Key ID: 33A8988F3B9067A0
2 changed files with 42 additions and 43 deletions

View File

@ -12,49 +12,6 @@ def tildescore_plugin(msg):
def jackpot_plugin(msg):
return pinhook.plugin.message(util.tilde.show_jackpot())
# ADMIN PLUGIN
@pinhook.plugin.command('&tao', help_text='[Admin] Set the admin only mode', ops=True)
def debug_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.ADMIN_ONLY = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("ADMIN_ONLY set to '{}'".format(util.tilde.ADMIN_ONLY))
# ADMIN PLUGIN
@pinhook.plugin.command('&dbg', help_text='[Admin] Set the debug mode', ops=True)
def debug_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.DEBUG = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("DEBUG set to '{}'".format(util.tilde.DEBUG))
# ADMIN PLUGIN
@pinhook.plugin.command('&tsk', help_text='[Admin] Set the timeskip mode', ops=True)
def timeskip_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.TIMESKIP = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("TIMESKIP set to '{}'".format(util.tilde.TIMESKIP))
# ADMIN PLUGIN
@pinhook.plugin.command('&tilde_requests', help_text='[Admin] See the current requests for the jugame', ops=True)
def tilde_requests_plugin(msg):
if msg.nick not in msg.ops and not util.tilde.DEBUG:
return
return pinhook.plugin.message("Outstanding requests: {}".format(str(util.tilde.challenges)) if util.tilde.challenges else "(none)")
# ADMIN PLUGIN
@pinhook.plugin.command('&delete_request', help_text='[Admin] Delete your jugame request', ops=True)
def delete_tilde_request_plugin(msg):
if (msg.nick not in msg.ops and not util.tilde.DEBUG) and (not msg.nick in util.tilde.challenges):
return
del util.tilde.challenges[msg.nick]
return pinhook.plugin.message("Deleted")
@pinhook.plugin.command('!tilde', help_text='Alias -- &tilde')
@pinhook.plugin.command('&tilde', help_text='Play the tildegame!')
def tilde_plugin(msg):

View File

@ -0,0 +1,42 @@
#!/usr/bin/python3
import pinhook.plugin
import util.tilde
@pinhook.plugin.command('&tao', help_text='[Admin] Set the admin only mode', ops=True)
def debug_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.ADMIN_ONLY = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("ADMIN_ONLY set to '{}'".format(util.tilde.ADMIN_ONLY))
@pinhook.plugin.command('&dbg', help_text='[Admin] Set the debug mode', ops=True)
def debug_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.DEBUG = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("DEBUG set to '{}'".format(util.tilde.DEBUG))
@pinhook.plugin.command('&tsk', help_text='[Admin] Set the timeskip mode', ops=True)
def timeskip_plugin(msg):
if msg.nick not in msg.ops:
return
if msg.arg:
util.tilde.TIMESKIP = (msg.arg.lower() == 'true' or msg.arg.lower() == 't')
return pinhook.plugin.message("TIMESKIP set to '{}'".format(util.tilde.TIMESKIP))
@pinhook.plugin.command('&tilde_requests', help_text='[Admin] See the current requests for the jugame', ops=True)
def tilde_requests_plugin(msg):
if msg.nick not in msg.ops and not util.tilde.DEBUG:
return
return pinhook.plugin.message("Outstanding requests: {}".format(str(util.tilde.challenges)) if util.tilde.challenges else "(none)")
@pinhook.plugin.command('&delete_request', help_text='[Admin] Delete your jugame request', ops=True)
def delete_tilde_request_plugin(msg):
if (msg.nick not in msg.ops and not util.tilde.DEBUG) and (not msg.nick in util.tilde.challenges):
return
del util.tilde.challenges[msg.nick]
return pinhook.plugin.message("Deleted")