- 此规定中定义的 Bot, 包含任何形式的 Bot, 包括但不限于定时启动或者是基于
Ariadne,Avilla,koishi,nonebot等框架的, 只要在 Graia Community 内提供服务, 那么就受到以下条目约束. - Graia Community 内禁止人机合一式提供服务的机器人;
- 建议在任何指令式的触发行为上附加 MentionMe(AtMe 判定), 以避免发生未定义行为;
- 不建议使用任何关键字触发;
- 禁止滥用戳一戳;
- 机器人账号的群名片需要以
[bot]为后缀; - 一些敏感的服务种类, 像是
Pixiv的插画发送, 搜图等, 也包括转发内地各大官媒的消息等, 这些功能都不能在 Graia Community 内启用. - 受到限制的功能类型详情, 以及备注/理由:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from inspect import stack | |
| def dbgstack(): | |
| print("stack:") | |
| for i in stack(1): | |
| print(f" {i.function}@{i.filename}:{i.frame.f_lineno}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from __future__ import annotations | |
| import asyncio | |
| import inspect | |
| from collections import deque | |
| from typing import Any, Callable, ClassVar, Generic, Literal, TypeVar, overload | |
| from typing_extensions import Self | |
| EllipsisType = type(...) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @asynccontextmanager | |
| async def param_compile( | |
| self, | |
| dispatchers: Optional[List[T_Dispatcher]] = None, | |
| post_exception_event: bool = True, | |
| print_exception: bool = True, | |
| use_global_dispatchers: bool = True, | |
| ): | |
| dispatchers = [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ast | |
| import inspect | |
| from typing import TYPE_CHECKING, Callable | |
| class TypeCheckingRemoveVisitor(ast.NodeTransformer): | |
| def visit_If(self, node: ast.If): | |
| if isinstance(node.test, ast.Name): | |
| if node.test.id == "TYPE_CHECKING": | |
| return None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CoreSupport(_RelationshipMetaWrapper): | |
| # | |
| # Mainline Properties | |
| # | |
| @overload | |
| async def get(self, metakey: Literal["mainline.name"]) -> str: | |
| "mainline.name -> str: Avilla Protocol 中 Mainline 的名称,在其他实现中通常被称为 `群组名称`, `频道名称` 等。" | |
| ... | |
| @overload | |
| async def set(self, metakey: Literal["mainline.name"], value: str) -> None: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, Dict | |
| from pydantic import BaseSettings, BaseConfig, BaseModel | |
| import pyhocon | |
| from pathlib import Path | |
| import stringcase | |
| class HoconModelConfig(BaseConfig): | |
| env_file_encoding = 'utf-8' | |
| env_file = "./config.conf" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from typing import Any, Dict, List | |
| from pydantic import BaseSettings | |
| from pydantic.main import BaseConfig, BaseModel | |
| from pydantic.fields import Field | |
| from pydantic.networks import PostgresDsn, RedisDsn | |
| import pyhocon | |
| from pathlib import Path | |
| from datetime import timedelta | |
| import stringcase |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @commander.command("lp user {0} permission set {1} {2}") | |
| async def user_permission_set( | |
| target: rsctx = Positional(0, selector=rsctx), | |
| permission_node: str = Positional(1, type=str), # 使用 beartype/jsondor 之类的? | |
| permission_value: bool = Positional(2, type=bool, default=True), | |
| param1: bool = AdditionParam(['-p1', '--param1'], type=bool, default=False), | |
| # 如果是 bool, 则不需要设置子匹配规则 | |
| param2: str = AdditionParam(['-p2 {0}', '--param2={0}'], type=str, default='default', | |
| return_pos=0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class NestableIterable(Iterable[T]): | |
| index_stack: list | |
| iterable: Iterable[T] | |
| def __init__(self, iterable: Iterable[T]) -> None: | |
| self.iterable = iterable | |
| self.index_stack = [0] | |
| def __iter__(self): | |
| index = self.index_stack[-1] |
NewerOlder