Skip to content

Commit

Permalink
✨ add module control and marry
Browse files Browse the repository at this point in the history
  • Loading branch information
RF-Tar-Railt committed Jan 8, 2024
1 parent 552bd6b commit bac6318
Show file tree
Hide file tree
Showing 14 changed files with 430 additions and 26 deletions.
3 changes: 0 additions & 3 deletions app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,6 @@ class BotConfig(BaseConfig, Generic[TA]):
admins: list[str] = Field(default_factory=list)
"""bot 的管理者(除开控制者)的账号"""

disabled: list[str] = Field(default_factory=list)
"""bot 初始禁用的模块名称"""

def export(self):
raise NotImplementedError

Expand Down
4 changes: 2 additions & 2 deletions app/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ async def __wrapper__(ctx: Context):


def check_disabled(path: str):
def __wrapper__(serv: RaianBotService, bot: BotConfig):
if path in bot.disabled or path in serv.config.plugin.disabled:
def __wrapper__(serv: RaianBotService):
if path in serv.config.plugin.disabled:
raise ExecutionStop
return True

Expand Down
4 changes: 4 additions & 0 deletions app/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ def __wrapper__(func):
def functions(self):
return self.cache.get("function::record", {})

@property
def disabled(self):
return self.cache.get("function::disables", set())

def func_description(self, name: str):
return func.__doc__ if (func := self.cache.get("function::record", {}).get(name)) else "Unknown"

Expand Down
4 changes: 0 additions & 4 deletions config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ bots:
port: 8080
## mirai-api-http 的验证码
access_token: "INITKEYWylsVdbr"
## bot 初始禁用的模块名称
disabled: []
## bot 的控制者的账号
master_id: "UNDEFINED"
## bot 的管理者(除开控制者)的账号
Expand Down Expand Up @@ -120,8 +118,6 @@ bots:
direct_message: true
## 是否为沙箱环境
is_sandbox: true
## bot 初始禁用的模块名称
disabled: []
## bot 的控制者的账号
master_id: "UNDEFINED"
## bot 的管理者(除开控制者)的账号
Expand Down
4 changes: 2 additions & 2 deletions library/ak_closure_talk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ def end(self, field: str):
self.avatars.pop(field, None)
return self.session.pop(field, None)

def add_char(self, field: str, uid: str, name: str):
def add_char(self, field: str, uid: str, name: str, url: str | None = None):
if field not in self.session:
raise SessionNotExist("[ClosureTalk] 会话未存在")
split = name.split("#")
split = [split[0], split[1] if len(split) >= 2 else "1"]
if not (characters := self.filter_character(split[0])):
self.avatars[field][uid] = f"https://q2.qlogo.cn/headimg_dl?dst_uin={uid}&spec=640"
self.avatars[field][uid] = url or f"https://q2.qlogo.cn/headimg_dl?dst_uin={uid}&spec=640"
else:
character = characters[0]
index = 0
Expand Down
16 changes: 8 additions & 8 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit bac6318

Please sign in to comment.