AliceBotProject / alicebot

简单的 Python 异步多后端机器人框架
https://docs.alicebot.dev/
MIT License
145 stars 13 forks source link

配置定时任务的时候会自动配置多一个重复的 #123

Closed Admsec closed 6 months ago

Admsec commented 7 months ago

配置定时任务的时候会自动配置多一个重复的 这是插件源代码(部分)

`from alicebot import Plugin, MessageEvent from .service import get_today_courses, get_tomorrow_courses from alicebot.adapter.apscheduler import scheduler_decorator

@scheduler_decorator( trigger="cron", trigger_args={"day_of_week": "sun,mon,wed,thu", "hour": 22, "minute": 0}, override_rule=False ) class CourseSchedule(Plugin): async def handle(self) -> None: data = get_tomorrow_courses() await self.bot.get_adapter("cqhttp").send(data, "private", self.bot.config.superuser)

async def rule(self) -> bool:
    return (
            self.event.adapter.name == "apscheduler"
            and type(self) == self.event.plugin_class
    )

class CourseRemindPlugin(Plugin): async def handle(self) -> None: data = "" if self.event.get_plain_text()[0] == '今': data = get_today_courses() elif self.event.get_plain_text()[0] == '明': data = get_tomorrow_courses() await self.event.reply(data)

async def rule(self) -> bool:
    return (
            isinstance(self.event, MessageEvent)
            and self.event.user_id == self.bot.config.superuser
            and (self.event.get_plain_text() == "今日课表"
                 or self.event.get_plain_text() == "明日课表")
    )

`

image image

st1020 commented 6 months ago

我这里无法复现这个错误,请提供 config.toml 和最小复现示例