mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-10 21:50:59 -05:00
BotPrivs
This commit is contained in:
parent
e3f75d733c
commit
ef250cf636
29
sopel_modules/SpiceBot_BotPrivs/BotPrivs.py
Normal file
29
sopel_modules/SpiceBot_BotPrivs/BotPrivs.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
|
||||||
|
import sopel.module
|
||||||
|
|
||||||
|
import sopel_modules.osd
|
||||||
|
import spicemanip
|
||||||
|
|
||||||
|
from sopel_modules.SpiceBot_SBTools import sopel_triggerargs, bot_privs
|
||||||
|
|
||||||
|
|
||||||
|
def configure(config):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.nickname_commands('admins', 'owners', 'owner')
|
||||||
|
def bot_command_hub(bot, trigger):
|
||||||
|
triggerargs, triggercommand = sopel_triggerargs(bot, trigger, 'nickname_command')
|
||||||
|
|
||||||
|
if triggercommand == 'owner':
|
||||||
|
triggercommand = 'owners'
|
||||||
|
|
||||||
|
privlist = spicemanip.main(bot_privs(bot, triggercommand), 'andlist')
|
||||||
|
bot.osd(str(bot.nick) + " " + triggercommand + ": " + privlist)
|
||||||
8
sopel_modules/SpiceBot_BotPrivs/__init__.py
Normal file
8
sopel_modules/SpiceBot_BotPrivs/__init__.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# coding=utf8
|
||||||
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
||||||
|
|
||||||
|
from .BotPrivs import *
|
||||||
|
|
||||||
|
__author__ = 'Sam Zick'
|
||||||
|
__email__ = 'sam@deathbybandaid.net'
|
||||||
|
__version__ = '0.1.0'
|
||||||
@ -38,7 +38,7 @@ def bot_command_hub(bot, trigger):
|
|||||||
bot.osd("Channel/nick name {} not valid.".format(target))
|
bot.osd("Channel/nick name {} not valid.".format(target))
|
||||||
return
|
return
|
||||||
|
|
||||||
triggerargs = spicemanip.main(triggerargs, '2+')
|
triggerargs = spicemanip.main(triggerargs, '2+', 'list')
|
||||||
|
|
||||||
if target == 'allchans':
|
if target == 'allchans':
|
||||||
targetsendlist = bot.channels.keys()
|
targetsendlist = bot.channels.keys()
|
||||||
|
|||||||
@ -36,15 +36,20 @@ def sopel_triggerargs(bot, trigger, command_type='module_command'):
|
|||||||
return triggerargs, command
|
return triggerargs, command
|
||||||
|
|
||||||
|
|
||||||
|
def bot_privs(bot, privtype):
|
||||||
|
botpriveval = eval("bot.config.core." + privtype)
|
||||||
|
if not isinstance(botpriveval, list):
|
||||||
|
botpriveval = [botpriveval]
|
||||||
|
return botpriveval
|
||||||
|
|
||||||
|
|
||||||
def command_permissions_check(bot, trigger, privslist):
|
def command_permissions_check(bot, trigger, privslist):
|
||||||
|
|
||||||
commandrunconsensus = []
|
commandrunconsensus = []
|
||||||
|
|
||||||
for botpriv in ["admins", "owner"]:
|
for botpriv in ["admins", "owner"]:
|
||||||
if botpriv in privslist:
|
if botpriv in privslist:
|
||||||
botpriveval = eval("bot.config.core." + botpriv)
|
botpriveval = bot_privs(bot, botpriv)
|
||||||
if not isinstance(botpriveval, list):
|
|
||||||
botpriveval = [botpriv]
|
|
||||||
if not inlist(bot, trigger.nick, botpriveval):
|
if not inlist(bot, trigger.nick, botpriveval):
|
||||||
commandrunconsensus.append('False')
|
commandrunconsensus.append('False')
|
||||||
else:
|
else:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user