test
This commit is contained in:
parent
6de64a260b
commit
2d85874c0e
@ -48,7 +48,7 @@ class SpiceBotCore_OBJ():
|
||||
self.logger.info("SpiceBot Commands Interface Setup Complete.")
|
||||
|
||||
# SpiceBots access to Sopel Command listing
|
||||
self.users = Users(self.config, self.bot)
|
||||
self.users = Users(self.bot)
|
||||
self.logger.info("SpiceBot Users Interface Setup Complete.")
|
||||
|
||||
def setup(self, bot):
|
||||
@ -56,8 +56,6 @@ class SpiceBotCore_OBJ():
|
||||
|
||||
# store an access interface to sopel.bot
|
||||
self.bot = bot
|
||||
self.commands.bot = bot
|
||||
self.users.bot = bot
|
||||
|
||||
# Re-initialize the bot config properly during plugin setup routine
|
||||
self.config.config = bot.config
|
||||
|
||||
@ -6,7 +6,7 @@ import os
|
||||
|
||||
from sopel.cli.run import build_parser, get_configuration
|
||||
|
||||
from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
# from sopel.config.types import StaticSection, ValidatedAttribute
|
||||
|
||||
|
||||
class Config():
|
||||
@ -47,8 +47,8 @@ class Config():
|
||||
return None
|
||||
|
||||
|
||||
class SpiceBot_Conf(StaticSection):
|
||||
# class SpiceBot_Conf(StaticSection):
|
||||
|
||||
multi_split_key = ValidatedAttribute('multi_split_key', default="&&")
|
||||
pipe_split_key = ValidatedAttribute('pipe_split_key', default="|")
|
||||
query_command_key = ValidatedAttribute('query_command_key', default="?")
|
||||
# multi_split_key = ValidatedAttribute('multi_split_key', default="&&")
|
||||
# pipe_split_key = ValidatedAttribute('pipe_split_key', default="|")
|
||||
# query_command_key = ValidatedAttribute('query_command_key', default="?")
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
|
||||
from sopel.privileges import VOICE, HALFOP, OP, ADMIN, OWNER, OPER
|
||||
|
||||
from sopel import plugin
|
||||
|
||||
|
||||
class Users():
|
||||
|
||||
def __init__(self, config, bot):
|
||||
def __init__(self, bot):
|
||||
self.bot = None
|
||||
self.config = config
|
||||
|
||||
self.bot_priv_dict = {
|
||||
"OWNER": 10,
|
||||
@ -14,12 +14,12 @@ class Users():
|
||||
}
|
||||
|
||||
self.channel_privilege_dict = {
|
||||
"OPER": OPER,
|
||||
"OWNER": OWNER,
|
||||
"ADMIN": ADMIN,
|
||||
"OP": OP,
|
||||
"HALFOP": HALFOP,
|
||||
"VOICE": VOICE,
|
||||
"OPER": plugin.OPER,
|
||||
"OWNER": plugin.OWNER,
|
||||
"ADMIN": plugin.ADMIN,
|
||||
"OP": plugin.OP,
|
||||
"HALFOP": plugin.HALFOP,
|
||||
"VOICE": plugin.VOICE,
|
||||
}
|
||||
|
||||
"""Bot Priviledges"""
|
||||
@ -51,7 +51,7 @@ class Users():
|
||||
"""Bot Owner"""
|
||||
|
||||
def list_bot_owner(self):
|
||||
list_owner = self.config.owner
|
||||
list_owner = self.bot.config.owner
|
||||
if not isinstance(list_owner, list):
|
||||
list_owner = [list_owner]
|
||||
return list_owner
|
||||
@ -64,7 +64,7 @@ class Users():
|
||||
"""Bot Admins"""
|
||||
|
||||
def list_bot_admin(self):
|
||||
list_admins = self.config.admins
|
||||
list_admins = self.bot.config.admins
|
||||
if not isinstance(list_admins, list):
|
||||
list_admins = [list_admins]
|
||||
return list_admins
|
||||
@ -98,23 +98,23 @@ class Users():
|
||||
|
||||
if not isinstance(privilege, int):
|
||||
if privilege.upper() == "OPER":
|
||||
privilege = self.channel_privilege_dict["OPER"]
|
||||
privilege = plugin.OPER
|
||||
elif privilege.upper() == "OWNER":
|
||||
privilege = self.channel_privilege_dict["OWNER"]
|
||||
privilege = plugin.OWNER
|
||||
elif privilege == "ADMIN":
|
||||
privilege = self.channel_privilege_dict["ADMIN"]
|
||||
privilege = plugin.ADMIN
|
||||
elif privilege.upper() == "OP":
|
||||
privilege = self.channel_privilege_dict["OP"]
|
||||
privilege = plugin.OP
|
||||
elif privilege.upper() in ["HALFOP", "HOP"]:
|
||||
privilege = self.channel_privilege_dict["HALFOP"]
|
||||
privilege = plugin.HALFOP
|
||||
elif privilege.upper() == "VOICE":
|
||||
privilege = self.channel_privilege_dict["VOICE"]
|
||||
privilege = plugin.VOICE
|
||||
else:
|
||||
return False
|
||||
|
||||
channel = self.bot.channels[channelstr]
|
||||
|
||||
if nick in [nick for nick in list(channel.users.items()) if channel.has_privileges(nick, privilege)]:
|
||||
if nick in [user for nick, user in channel.users if channel.has_privileges(nick, privilege)]:
|
||||
return True
|
||||
return False
|
||||
|
||||
@ -122,7 +122,7 @@ class Users():
|
||||
|
||||
def list_channel_users_oper(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_oper(nick, self.channel_privilege_dict["OPER"])]
|
||||
return [user for nick, user in channel.users if channel.is_oper(nick, plugin.OPER)]
|
||||
|
||||
def is_channel_oper(self, channelstr, user):
|
||||
if user in self.list_channel_users_oper(channelstr):
|
||||
@ -133,7 +133,7 @@ class Users():
|
||||
|
||||
def list_channel_users_owner(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_owner(nick, self.channel_privilege_dict["OWNER"])]
|
||||
return [user for nick, user in channel.users if channel.is_owner(nick, plugin.OWNER)]
|
||||
|
||||
def is_channel_owner(self, channelstr, user):
|
||||
if user in self.list_channel_users_owner(channelstr):
|
||||
@ -144,7 +144,7 @@ class Users():
|
||||
|
||||
def list_channel_users_admin(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_admin(nick, self.channel_privilege_dict["ADMIN"])]
|
||||
return [user for nick, user in channel.users if channel.is_admin(nick, plugin.ADMIN)]
|
||||
|
||||
def is_channel_admin(self, channelstr, user):
|
||||
if user in self.list_channel_users_admin(channelstr):
|
||||
@ -155,7 +155,7 @@ class Users():
|
||||
|
||||
def list_channel_users_op(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_op(nick, self.channel_privilege_dict["OP"])]
|
||||
return [user for nick, user in channel.users if channel.is_op(nick, plugin.OP)]
|
||||
|
||||
def is_channel_op(self, channelstr, user):
|
||||
if user in self.list_channel_users_op(channelstr):
|
||||
@ -166,7 +166,7 @@ class Users():
|
||||
|
||||
def list_channel_users_halfop(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_halfop(nick, self.channel_privilege_dict["HALFOP"])]
|
||||
return [user for nick, user in channel.users if channel.is_halfop(nick, plugin.HALFOP)]
|
||||
|
||||
def is_channel_halfop(self, channelstr, user):
|
||||
if user in self.list_channel_users_halfop(channelstr):
|
||||
@ -177,7 +177,7 @@ class Users():
|
||||
|
||||
def list_channel_users_voice(self, channelstr):
|
||||
channel = self.bot.channels[channelstr]
|
||||
return [user for nick, user in channel.users if channel.is_voice(nick, self.channel_privilege_dict["VOICE"])]
|
||||
return [user for nick, user in channel.users if channel.is_voice(nick, plugin.VOICE)]
|
||||
|
||||
def is_channel_voice(self, channelstr, user):
|
||||
if user in self.list_channel_users_voice(channelstr):
|
||||
|
||||
@ -8,18 +8,18 @@ import os
|
||||
import pathlib
|
||||
|
||||
from .SBCore import SpiceBotCore_OBJ
|
||||
from .SBCore.config import SpiceBot_Conf
|
||||
#from .SBCore.config import SpiceBot_Conf
|
||||
|
||||
SCRIPT_DIR = pathlib.Path(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
sb = SpiceBotCore_OBJ(SCRIPT_DIR)
|
||||
|
||||
|
||||
def configure(config):
|
||||
config.define_section("spiceBot", SpiceBot_Conf, validate=False)
|
||||
config.SpiceBot_Conf.configure_setting('multi_split_key', 'key to split multi-commands')
|
||||
config.SpiceBot_Conf.configure_setting('pipe_split_key', 'key to split multi-commands')
|
||||
config.SpiceBot_Conf.configure_setting('query_command_key', 'key to split multi-commands')
|
||||
# def configure(config):
|
||||
# config.define_section("spiceBot", SpiceBot_Conf, validate=False)
|
||||
# config.SpiceBot_Conf.configure_setting('multi_split_key', 'key to split multi-commands')
|
||||
# config.SpiceBot_Conf.configure_setting('pipe_split_key', 'key to split multi-commands')
|
||||
# config.SpiceBot_Conf.configure_setting('query_command_key', 'key to split multi-commands')
|
||||
|
||||
|
||||
def setup(bot):
|
||||
|
||||
@ -176,7 +176,7 @@ class ComRun():
|
||||
recipients = self.trigger.sender
|
||||
sb.osd(messages, recipients, text_method, max_messages=-1)
|
||||
|
||||
# @property
|
||||
@property
|
||||
def required_privileges(self):
|
||||
bot_level = 0
|
||||
channel_level = 0
|
||||
@ -192,7 +192,7 @@ class ComRun():
|
||||
"channel": channel_level
|
||||
}
|
||||
|
||||
# @property()
|
||||
@property()
|
||||
def required_privileges_text(self):
|
||||
ret_text = "This command requries privileges of/above the following"
|
||||
if self.required_privileges["bot"]:
|
||||
@ -203,7 +203,7 @@ class ComRun():
|
||||
ret_text += "."
|
||||
return ret_text
|
||||
|
||||
# @property
|
||||
@property
|
||||
def is_nick_privileged(self):
|
||||
has_bot_priv = True
|
||||
has_channel_priv = True
|
||||
|
||||
Loading…
Reference in New Issue
Block a user