Compare commits
4 Commits
6a27b002ff
...
pkg/dev/ri
Author | SHA1 | Date | |
---|---|---|---|
4fc3e74bbd | |||
5663b2768b | |||
83d74c2b06 | |||
01834c6ba7 |
@ -48,6 +48,31 @@ class Controller:
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
async def check_role(self,
|
||||
uri: str,
|
||||
username: str,
|
||||
**kwargs: dict,
|
||||
) -> None:
|
||||
# create a new config
|
||||
async with await Config(dispatcher.option) as config:
|
||||
await config.property.read_write()
|
||||
await config.option('message').value.set(uri)
|
||||
subconfig = config.option(uri)
|
||||
for key, value in kwargs.items():
|
||||
try:
|
||||
await subconfig.option(key).value.set(value)
|
||||
except AttributeError:
|
||||
if get_config()['global']['debug']:
|
||||
print_exc()
|
||||
raise ValueError(_(f'unknown parameter in "{uri}": "{key}"'))
|
||||
except ValueOptionError as err:
|
||||
raise ValueError(_(f'invalid parameter in "{uri}": {err}'))
|
||||
await dispatcher.check_role(subconfig,
|
||||
username,
|
||||
uri,
|
||||
)
|
||||
|
||||
async def on_join(self,
|
||||
risotto_context,
|
||||
):
|
||||
|
@ -342,7 +342,8 @@ class Dispatcher(register.RegisterDispatcher,
|
||||
async def check_role(self,
|
||||
config: Config,
|
||||
user_login: str,
|
||||
uri: str) -> None:
|
||||
uri: str,
|
||||
) -> None:
|
||||
async with self.pool.acquire() as connection:
|
||||
async with connection.transaction():
|
||||
# Verify if user exists and get ID
|
||||
|
@ -277,7 +277,7 @@ class RegisterDispatcher:
|
||||
try:
|
||||
self.injected_self[submodule_name] = module.Risotto(test)
|
||||
except AttributeError as err:
|
||||
raise RegistrationError(_(f'unable to register the module {submodule_name}, this module must have Risotto class'))
|
||||
print(_(f'unable to register the module {submodule_name}, this module must have Risotto class'))
|
||||
|
||||
def validate(self):
|
||||
""" check if all messages have a function
|
||||
|
Reference in New Issue
Block a user