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,
|
2021-11-02 14:58:42 +00:00
|
|
|
show_typing: bool = True,
|
2021-10-24 10:55:45 +00:00
|
|
|
):
|
|
|
|
self.function = function
|
|
|
|
self.pattern = pattern
|
|
|
|
self.mode = mode
|
|
|
|
self.flags = flags
|
2021-11-02 14:58:42 +00:00
|
|
|
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"]
|