-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from Ailitonia/dev
Upgrade: New version for nonebot2 v2.0.0-beta.5
- Loading branch information
Showing
65 changed files
with
1,417 additions
and
694 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" | ||
@Author : Ailitonia | ||
@Date : 2022/06/27 20:48 | ||
@FileName : auto_group_sign.py | ||
@Project : nonebot2_miya | ||
@Description : 自动群打卡 (go-cqhttp v1.0.0-rc3 以上版本可用) | ||
@GitHub : https://github.com/Ailitonia | ||
@Software : PyCharm | ||
""" | ||
|
||
from nonebot import get_driver | ||
from nonebot.log import logger | ||
from nonebot.plugin import PluginMetadata | ||
from nonebot.adapters import Bot | ||
from pydantic import BaseModel | ||
|
||
from omega_miya.onebot_api import GoCqhttpBot | ||
from omega_miya.utils.apscheduler import scheduler | ||
from omega_miya.utils.process_utils import semaphore_gather | ||
|
||
|
||
__plugin_meta__ = PluginMetadata( | ||
name="自动群打卡", | ||
description="【自动群打卡插件】\n" | ||
"让机器人参与抢群打卡每日第一", | ||
usage="由管理员配置, 无命令用法", | ||
extra={"author": "Ailitonia"}, | ||
) | ||
|
||
|
||
class AutoGroupSignConfig(BaseModel): | ||
"""自动群打卡插件配置""" | ||
# 启用自动群打卡 | ||
enable_auto_group_sign: bool = False | ||
|
||
class Config: | ||
extra = "ignore" | ||
|
||
|
||
_plugin_config = AutoGroupSignConfig.parse_obj(get_driver().config) | ||
|
||
|
||
async def _bot_group_sign(bot: Bot): | ||
gocq_bot = GoCqhttpBot(bot=bot) | ||
tasks = [gocq_bot.send_group_sign(group_id=group_result.group_id) for group_result in await gocq_bot.get_group_list()] | ||
await semaphore_gather(tasks=tasks, semaphore_num=16) | ||
|
||
|
||
async def _sign_main() -> None: | ||
logger.debug('AutoGroupSign | Starting sign all groups') | ||
tasks = [_bot_group_sign(bot=bot) for _, bot in get_driver().bots.items()] | ||
await semaphore_gather(tasks=tasks, semaphore_num=8) | ||
logger.debug('AutoGroupSign | Sign tasks completed') | ||
|
||
|
||
if _plugin_config.enable_auto_group_sign: | ||
scheduler.add_job( | ||
_sign_main, | ||
'cron', | ||
# year=None, | ||
# month=None, | ||
# day='*/1', | ||
# week=None, | ||
# day_of_week=None, | ||
hour='0', | ||
minute='0', | ||
second='0', | ||
# start_date=None, | ||
# end_date=None, | ||
# timezone=None, | ||
id='auto_group_sign', | ||
coalesce=True, | ||
misfire_grace_time=30 | ||
) | ||
logger.opt(colors=True).success('<lc>AutoGroupSign</lc> | <lg>自动群打卡已启用</lg>') |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
""" | ||
@Author : Ailitonia | ||
@Date : 2022/07/30 21:31 | ||
@FileName : config.py | ||
@Project : nonebot2_miya | ||
@Description : Bilibili 直播间订阅插件配置 | ||
@GitHub : https://github.com/Ailitonia | ||
@Software : PyCharm | ||
""" | ||
|
||
from nonebot import get_driver, logger | ||
from pydantic import BaseModel, ValidationError | ||
|
||
|
||
class BilibiliLiveMonitorPluginConfig(BaseModel): | ||
"""BilibiliLiveMonitor 插件配置""" | ||
|
||
# 发送消息通知时尝试@全体 | ||
bilibili_live_monitor_enable_group_at_all_notice: bool = False | ||
|
||
class Config: | ||
extra = "ignore" | ||
|
||
|
||
try: | ||
bilibili_live_monitor_plugin_config = BilibiliLiveMonitorPluginConfig.parse_obj(get_driver().config) | ||
except ValidationError as e: | ||
import sys | ||
logger.opt(colors=True).critical(f'<r>Bilibili 直播间订阅插件配置格式验证失败</r>, 错误信息:\n{e}') | ||
sys.exit(f'Bilibili 直播间订阅插件配置格式验证失败, {e}') | ||
|
||
|
||
__all__ = [ | ||
'bilibili_live_monitor_plugin_config' | ||
] |
This file contains 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
Oops, something went wrong.