Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/core/elements/module/meta.py

56 lines
1.6 KiB
Python
Raw Normal View History

2021-10-24 10:55:45 +00:00
import re
from typing import Callable, Union
class Meta:
def __init__(self, **kwargs):
...
class CommandMeta:
def __init__(self,
function: Callable = None,
help_doc: Union[str, list, tuple] = None,
required_admin: bool = False,
2021-11-19 16:33:53 +00:00
required_superuser: bool = False,
available_for: Union[str, list, tuple] = '*',
2021-10-24 10:55:45 +00:00
):
self.function = function
if isinstance(help_doc, str):
help_doc = [help_doc]
elif isinstance(help_doc, tuple):
help_doc = list(help_doc)
self.help_doc: list = help_doc
self.required_admin = required_admin
self.required_superuser = required_superuser
2021-11-19 16:33:53 +00:00
if isinstance(available_for, str):
available_for = [available_for]
elif isinstance(available_for, tuple):
available_for = list(available_for)
self.available_for = available_for
2021-10-24 10:55:45 +00:00
class RegexMeta:
def __init__(self,
function: Callable = None,
pattern: str = None,
mode: str = None,
flags: re.RegexFlag = 0,
show_typing: bool = True,
2021-10-24 10:55:45 +00:00
):
self.function = function
self.pattern = pattern
self.mode = mode
self.flags = flags
self.show_typing = show_typing
2021-10-24 10:55:45 +00:00
class ScheduleMeta:
def __init__(self,
function: Callable = None
):
self.function = function
__all__ = ["Meta", "CommandMeta", "RegexMeta", "ScheduleMeta"]