import platform from pathlib import Path 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("欢迎新人")
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import nonebot from nonebot.adapters.cqhttp import Bot as CQHTTPBot from src.utils.yaml_loader import yml_loader from src.utils.scheduler_job.epd_drawer import shutdown from pathlib import Path CONFIG_FILE = Path("./configs.yml") configs = yml_loader(CONFIG_FILE) bot_config = configs["bot"] nonebot.init(debug=bot_config["DEBUG"], superusers=set(bot_config["SUPERUSERS"]), nickname=set(bot_config["NICKNAME"]), command_start=set(bot_config["COMMAND_START"]), command_sep=set(bot_config["COMMAND_SEP"]), host=bot_config["HOST"], port=bot_config["PORT"], apscheduler_autostart=False) app = nonebot.get_asgi() driver = nonebot.get_driver() driver.register_adapter("cqhttp", CQHTTPBot) driver.on_shutdown(shutdown) nonebot.load_builtin_plugins() nonebot.load_plugin("nonebot_plugin_apscheduler") nonebot.load_plugins("src/plugins")
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- # @File : __init__.py.py # @Time : 2020/12/8 16:47 # @Author : QingWen # @E-mail : [email protected] import httpx from pathlib import Path from src.utils.yaml_loader import yml_loader YML = Path("D:/Dorothy/Dorothy/configs.yml") config = yml_loader(YML) url = "https://api.imjad.cn/cloudmusic/" data = {"type": "search", "limit": 5, "s": "every day is night"} response = httpx.get(url, params=data) print(response.json())
#!/usr/bin/env python3 # -*- encoding: utf-8 -*- # @File : report_getter.py # @Time : 2020/12/8 21:31 # @Author : QingWen # @E-mail : [email protected] import httpx from src.utils.yaml_loader import yml_loader from pathlib import Path YML = Path("D:/Dorothy/Dorothy/configs.yml") api_config = yml_loader(YML)["hefeng"] key = api_config["KEY"] async def location_get(loc: list): """ 由原始名称获取地点 """ if not loc: return False location = {"key": key, "number": "1"} loc.reverse() for i, v in enumerate(loc): if i == 0: location["location"] = v elif i < 3: location[f"adm{i}"] = v