diff options
| author | 2023-04-19 16:58:55 +0800 | |
|---|---|---|
| committer | 2023-04-19 16:58:55 +0800 | |
| commit | bfac2edccf0f83caab5321587de3d7876fd52871 (patch) | |
| tree | e71d59e0ef7d642a712ba963b7b5096c454b96c1 /ChienDice | |
| parent | 23b32b900423ae8fe36a50224f0308cb3d97d4d0 (diff) | |
| download | HydroRoll-bfac2edccf0f83caab5321587de3d7876fd52871.tar.gz HydroRoll-bfac2edccf0f83caab5321587de3d7876fd52871.zip | |
🐛修复指令前缀bug失效问题
Diffstat (limited to 'ChienDice')
| -rw-r--r-- | ChienDice/config.toml | 18 | ||||
| -rw-r--r-- | ChienDice/data/bot_info.json | 3 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_base/__init__.py | 2 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_base/config.py | 4 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_bot_info/__init__.py | 20 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_bot_info/config.py | 11 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_dice/__init__.py | 6 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_reply/__init__.py | 2 | ||||
| -rw-r--r-- | ChienDice/plugins/iamai_plugin_send/config.py | 4 |
9 files changed, 59 insertions, 11 deletions
diff --git a/ChienDice/config.toml b/ChienDice/config.toml index 0c4aa7b..25ce660 100644 --- a/ChienDice/config.toml +++ b/ChienDice/config.toml @@ -1,7 +1,17 @@ +[Chien] +version = "v0.1.0" +svn = "1" +author = "简律纯" + +[Chien.self] +header = "Hydro系[1]号" +info = "一只水系骰子..." + + [bot] plugins = [] plugin_dirs = ["plugins"] -adapters = ["iamai.adapter.cqhttp"] +adapters = ["iamai.adapter.cqhttp","iamai.adapter.apscheduler"] [bot.log] level = "INFO" @@ -11,4 +21,8 @@ verbose_exception = true adapter_type = "reverse-ws" host = "127.0.0.1" port = 8080 -url = "/cqhttp/ws"
\ No newline at end of file +url = "/cqhttp/ws" +show_raw = false + +[adapter.apscheduler] +scheduler_config = { "apscheduler.timezone" = "Asia/Shanghai" }
\ No newline at end of file diff --git a/ChienDice/data/bot_info.json b/ChienDice/data/bot_info.json new file mode 100644 index 0000000..5ff30dc --- /dev/null +++ b/ChienDice/data/bot_info.json @@ -0,0 +1,3 @@ +{
+ nick : "本大魔王"
+}
\ No newline at end of file diff --git a/ChienDice/plugins/iamai_plugin_base/__init__.py b/ChienDice/plugins/iamai_plugin_base/__init__.py index e99ce15..fe0cd32 100644 --- a/ChienDice/plugins/iamai_plugin_base/__init__.py +++ b/ChienDice/plugins/iamai_plugin_base/__init__.py @@ -70,7 +70,7 @@ class CommandPluginBase(RegexPluginBase[T_State, T_CommandPluginConfig], ABC): def str_match(self, msg_str: str) -> bool: if not hasattr(self, "command_re_pattern"): self.command_re_pattern = re.compile( - f'({"|".join(self.config.command_prefix)})' + f'[{"".join(self.config.command_prefix)}]' f'({"|".join(self.config.command)})' r"\s*(?P<command_args>.*)", flags=re.I if self.config.ignore_case else 0, diff --git a/ChienDice/plugins/iamai_plugin_base/config.py b/ChienDice/plugins/iamai_plugin_base/config.py index b410888..c36d03e 100644 --- a/ChienDice/plugins/iamai_plugin_base/config.py +++ b/ChienDice/plugins/iamai_plugin_base/config.py @@ -5,7 +5,7 @@ from iamai import ConfigModel class BasePluginConfig(ConfigModel): __config_name__ = "" - handle_all_message: bool = False + handle_all_message: bool = True """是否处理所有类型的消息,此配置为 True 时会覆盖 handle_friend_message 和 handle_group_message。""" handle_friend_message: bool = True """是否处理好友消息。""" @@ -22,7 +22,7 @@ class RegexPluginConfig(BasePluginConfig): class CommandPluginConfig(RegexPluginConfig): - command_prefix: Set[str] = {".", "。"} + command_prefix: Set[str] = {".", "。","!"} """命令前缀。""" command: Set[str] = {} """命令文本。""" diff --git a/ChienDice/plugins/iamai_plugin_bot_info/__init__.py b/ChienDice/plugins/iamai_plugin_bot_info/__init__.py new file mode 100644 index 0000000..3cc869e --- /dev/null +++ b/ChienDice/plugins/iamai_plugin_bot_info/__init__.py @@ -0,0 +1,20 @@ +import re +import sys +import platform +from importlib.metadata import version +from plugins.iamai_plugin_base import CommandPluginBase + +from .config import Config + + +class BotInfo(CommandPluginBase[None, Config]): + Config = Config + + def __post_init__(self): + self.re_pattern = re.compile(r"(?P<bot_info_str>.*)", flags=re.I) + + async def handle(self) -> None: + await self.event.reply( + self.format_str(self.config.message_str, + f"{self.bot.config.Chien['self']['header']} HydroRoll!{self.bot.config.Chien['version']}({self.bot.config.Chien['svn']}) by {self.bot.config.Chien['author']} on Python {'.'.join(map(str, platform.python_version_tuple()[:3]))} with {' & '.join([adapter + '('+version('iamai-adapter-'+adapter)+')' for adapter in dict(self.bot.config.adapter)])} for iamai({version('iamai')})\n{self.bot.config.Chien['self']['info']}") + ) diff --git a/ChienDice/plugins/iamai_plugin_bot_info/config.py b/ChienDice/plugins/iamai_plugin_bot_info/config.py new file mode 100644 index 0000000..cf92e81 --- /dev/null +++ b/ChienDice/plugins/iamai_plugin_bot_info/config.py @@ -0,0 +1,11 @@ +from typing import Set + +from plugins.iamai_plugin_base import CommandPluginConfig + + +class Config(CommandPluginConfig): + __config_name__ = "plugin_bot_info" + command: Set[str] = {"bot"} + """命令文本。""" + message_str: str = "{message}" + """最终发送消息的格式。""" diff --git a/ChienDice/plugins/iamai_plugin_dice/__init__.py b/ChienDice/plugins/iamai_plugin_dice/__init__.py index ef2ca79..6005406 100644 --- a/ChienDice/plugins/iamai_plugin_dice/__init__.py +++ b/ChienDice/plugins/iamai_plugin_dice/__init__.py @@ -39,12 +39,12 @@ class Dice(CommandPluginBase[None, Config]): result_str += f"{'+'.join(map(lambda x: str(x), dice))}=" result_str += str(dice_sum) else: - result_str = f"{dice_times}D{dice_faces}X{dice_multiply}=" + result_str = f"{dice_times}D{dice_faces}x{dice_multiply}=" if dice_times != 1: result_str += ( - f"({'+'.join(map(lambda x: str(x), dice))})X{dice_multiply}=" + f"({'+'.join(map(lambda x: str(x), dice))})x{dice_multiply}=" ) - result_str += f"{dice_sum}X{dice_multiply}={dice_sum * dice_multiply}" + result_str += f"{dice_sum}x{dice_multiply}={dice_sum * dice_multiply}" logger.info(f"Dice Plugin: {result_str}") await self.event.reply(self.format_str(self.config.message_str, result_str)) diff --git a/ChienDice/plugins/iamai_plugin_reply/__init__.py b/ChienDice/plugins/iamai_plugin_reply/__init__.py index 3be8abd..6835ca8 100644 --- a/ChienDice/plugins/iamai_plugin_reply/__init__.py +++ b/ChienDice/plugins/iamai_plugin_reply/__init__.py @@ -11,7 +11,7 @@ class Reply(BasePlugin[None, Config]): Config = Config def __post_init__(self): - with open(self.config.data_file, "r") as fp: + with open(self.config.data_file, "r",encoding="utf-8") as fp: if self.config.data_type == "json": json_data = json.load(fp) else: diff --git a/ChienDice/plugins/iamai_plugin_send/config.py b/ChienDice/plugins/iamai_plugin_send/config.py index b60c276..959822c 100644 --- a/ChienDice/plugins/iamai_plugin_send/config.py +++ b/ChienDice/plugins/iamai_plugin_send/config.py @@ -7,9 +7,9 @@ class Config(CommandPluginConfig): __config_name__ = "plugin_send" command: Set[str] = {"send"} """命令文本。""" - send_user_id: int = 0 + send_user_id: int = 2753364619 """发送消息的对象的 QQ 号码。""" - send_success_msg: Optional[str] = None + send_success_msg: Optional[str] = "本大魔王已将消息送出√" """发送成功时回复的消息,设置为 None 表示不发送任何消息。""" send_filed_msg: Optional[str] = "发送失败:{message}" """发送失败时回复的消息。""" |
