from random import choice, randint from datetime import date from nonebot.log import logger from nonebot.rule import to_me from nonebot.adapters.cqhttp import Bot, Event from nonebot.plugin import on_command, on_notice, on_keyword from src.utils.utils import counter from src.utils.rules import is_banned from src.utils.yaml_loader import yml_loader CONFIG_PATH = Path("./configs.yml") config = yml_loader(CONFIG_PATH) notice_handler = on_notice(rule=is_banned(), block=True) @notice_handler.handle() async def _(bot: Bot, event: Event, state: dict): if platform.system() == "Windows": event_type = event.detail_type else: event_type = event.notice_type if event_type == "group_increase": if str(event.user_id) == str(event.self_id): await notice_handler.finish("大家好啊") else: await notice_handler.finish("欢迎新人") elif event_type == "group_decrease":
repeat_data = ujson.load(f) # 保存单个记录 @dataclass class Record: last_msg: str last_user_id: str repeat_count: int = 0 # 存储各个群的复读记录 records: Dict[str, Record] = {} # 复读!学大家说话!优先级最低 repeater = on_message(rule=is_banned(), priority=10) @repeater.handle() async def _(bot: Bot, event: Event, state: dict): msg = str(event.message) logger.info(msg) user_id = str(event.user_id) group = str(event.group_id) if group not in records: rec = Record(msg, user_id, 1) records[group] = rec return rec = records.get(group)
# @Time : 2020/12/8 20:03 # @Author : QingWen # @E-mail : [email protected] from random import choice from nonebot.adapters.cqhttp import Bot, Event from nonebot.plugin import on_command from nonebot.log import logger from src.utils.rules import is_banned from .location_parser import location_parse from .report_getter import location_get, report_get from . import expression as e weather = on_command("weather", aliases={"天气"}, rule=is_banned(), block=True) @weather.handle() async def _(bot: Bot, event: Event, state: dict): args = str(event.message).strip() # 首次发送命令时跟随的参数,例:/天气 上海,则args为上海 if args: state["location"] = args @weather.got("location", prompt=choice(e.WHERE)) async def _(bot: Bot, event: Event, state: dict): location = await location_parse(state["location"]) location_found = await location_get(location) if location_found: state["location"] = location_found
from pathlib import Path from datetime import datetime, timedelta from apscheduler.triggers.date import DateTrigger from nonebot.rule import to_me from nonebot.log import logger from nonebot.sched import scheduler from nonebot.typing import Bot, Event from nonebot.plugin import on_command, on_regex from src.utils.utils import counter from src.utils.rules import is_banned, is_enabled from .data_source import result_get, setu_linker, setu_loader sauce_search = on_command("picsearch", aliases={"搜图"}, rule=is_banned()) @sauce_search.handle() async def _(bot: Bot, event: Event, state: dict): user = str(event.user_id) group = str(event.group_id) state["user"] = user state["group"] = group img = str(event.message).strip() if img: state["img"] = img @sauce_search.got("img", prompt="请发一张图哦")
# @Author : QingWen # @E-mail : [email protected] import asyncio from random import randint from nonebot.typing import Bot, Event from nonebot.plugin import on_command from src.utils.rules import is_banned safe_left = 0 current_bullet_num = 0 players = {} spin = on_command("rr", rule=is_banned()) @spin.handle() async def _(bot: Bot, event: Event, state: dict): if event.sub_type == "private": await spin.finish("此功能仅对群聊开放。") else: global current_bullet_num, safe_left if event.sender["card"] != "": user_name = event.sender["card"] else: user_name = event.sender["nickname"] if user_name not in players: players[user_name] = {}
# @Author : QingWen # @E-mail : [email protected] import asyncio from random import randint from nonebot.adapters.cqhttp import Bot, Event from nonebot.plugin import on_command from src.utils.rules import is_banned safe_left = 0 current_bullet_num = 0 players = {} spin = on_command("rr", rule=is_banned(), block=True) @spin.handle() async def _(bot: Bot, event: Event, state: dict): if event.sub_type == "private": await spin.finish("此功能仅对群聊开放。") group_id = event.group_id user_id = event.user_id bot_id = int(event.self_id) bot_info = await bot.get_group_member_info(group_id=group_id, user_id=bot_id) player_info = await bot.get_group_member_info(group_id=group_id, user_id=user_id) bot_role = bot_info["role"]
from apscheduler.triggers.date import DateTrigger from nonebot.rule import to_me from nonebot.log import logger from nonebot.adapters.cqhttp import Bot, Event from nonebot.plugin import on_command, on_regex from nonebot import require from src.utils.utils import counter from src.utils.rules import is_banned, is_enabled from .data_source import result_get, setu_linker, setu_loader sauce_search = on_command("picsearch", aliases={"搜图"}, rule=is_banned(), block=True) @sauce_search.handle() async def _(bot: Bot, event: Event, state: dict): user = str(event.user_id) group = str(event.group_id) state["user"] = user state["group"] = group img = str(event.message).strip() if img: state["img"] = img