diff --git a/.env b/.env index 0b055648..915ec10a 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ -ENVIRONMENT=dev +ENVIRONMENT=prod APSCHEDULER_AUTOSTART=true APSCHEDULER_CONFIG={"apscheduler.timezone": "Asia/Shanghai"} \ No newline at end of file diff --git a/.env.dev b/.env.dev index bcd4ebad..ea748886 100644 --- a/.env.dev +++ b/.env.dev @@ -1,4 +1,4 @@ HOST=127.0.0.1 PORT=8080 -DEBUG=true -COMMAND_START=["/", ""] \ No newline at end of file +LOG_LEVEL=DEBUG +FASTAPI_RELOAD=true diff --git a/.env.prod b/.env.prod index e0716b8b..db9db1c1 100644 --- a/.env.prod +++ b/.env.prod @@ -1,4 +1,2 @@ -HOST=127.0.0.1 +HOST=0.0.0.0 PORT=8080 -SECRET= -ACCESS_TOKEN= diff --git a/.gitignore b/.gitignore index 3ce86938..6fc6560d 100644 --- a/.gitignore +++ b/.gitignore @@ -138,21 +138,6 @@ dmypy.json # pytype static type analyzer .pytype/ -*.db - # End of https://www.toptal.com/developers/gitignore/api/python -resource/voices/1.wav -resource/voices/帕拉斯/帕拉斯_交谈1.wav -resource/voices/帕拉斯/帕拉斯_交谈2.wav -resource/voices/帕拉斯/帕拉斯_交谈3.wav -resource/voices/帕拉斯/帕拉斯_任命助理.wav -resource/voices/帕拉斯/帕拉斯_信赖提升后交谈1.wav -resource/voices/帕拉斯/帕拉斯_信赖提升后交谈2.wav -resource/voices/帕拉斯/帕拉斯_信赖提升后交谈3.wav -resource/voices/帕拉斯/帕拉斯_信赖触摸.wav -resource/voices/帕拉斯/帕拉斯_戳一下.wav -resource/voices/帕拉斯/帕拉斯_晋升后交谈1.wav -resource/voices/帕拉斯/帕拉斯_晋升后交谈2.wav -resource/voices/帕拉斯/帕拉斯_问候.wav -resource/voices/帕拉斯/帕拉斯_闲置.wav -.vscode/db.json + +resource/voices/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index bfbf2e0f..40b64e56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,25 @@ -FROM namiya233/go-cqhttp +FROM python:3.9 as requirements-stage -FROM python:3.8 +WORKDIR /tmp + +COPY ./pyproject.toml ./poetry.lock* /tmp/ + +RUN curl -sSL https://install.python-poetry.org -o install-poetry.py + +RUN python install-poetry.py --yes + +ENV PATH="${PATH}:/root/.local/bin" + +RUN poetry export -f requirements.txt --output requirements.txt --without-hashes + +FROM tiangolo/uvicorn-gunicorn-fastapi:python3.9 -COPY / /app/ -RUN pip install --no-cache-dir -r /app/requirements.txt WORKDIR /app -CMD ["python","bot.py"] + +COPY --from=requirements-stage /tmp/requirements.txt /app/requirements.txt + +RUN pip install --no-cache-dir --upgrade -r requirements.txt + +RUN rm requirements.txt + +COPY ./ /app/ diff --git a/bot.py b/bot.py index 0936b145..fb8730b1 100644 --- a/bot.py +++ b/bot.py @@ -2,7 +2,8 @@ # -*- coding: utf-8 -*- import nonebot -from nonebot.adapters.cqhttp import Bot as CQHTTPBot +from nonebot.adapters.onebot.v11 import Adapter as ONEBOT_V11Adapter + # Custom your logger # # from nonebot.log import logger, default_format @@ -17,16 +18,12 @@ app = nonebot.get_asgi() driver = nonebot.get_driver() -driver.register_adapter("cqhttp", CQHTTPBot) +driver.register_adapter(ONEBOT_V11Adapter) + # Please DO NOT modify this file unless you know what you are doing! # As an alternative, you should use command `nb` or modify `pyproject.toml` to load plugins nonebot.load_from_toml("pyproject.toml") -nonebot.load_plugins("bot/plugins") -nonebot.init(apscheduler_autostart=True) -nonebot.init(apscheduler_config={ - "apscheduler.timezone": "Asia/Shanghai" -}) # Modify some config / config depends on loaded configs # diff --git a/config.yml b/config.yml index fd1d8e71..d64c8b5a 100644 --- a/config.yml +++ b/config.yml @@ -3,8 +3,8 @@ account: password: "机器人密码" message: - post-format: array + post-format: string servers: - ws-reverse: - universal: ws://127.0.0.1:8080/cqhttp/ws \ No newline at end of file + universal: ws://127.0.0.1:8080/onebot/v11/ws \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 05503498..bd3b7eb4 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,11 +1,9 @@ -version: "2" +version: "3" services: # 其他配置参考 https://hub.docker.com/r/tiangolo/uvicorn-gunicorn-fastapi/ nonebot: - build: bot - volumes: - - "/etc/localtime:/etc/localtime" - - "./:/app/" + build: . + container_name: nonebot ports: - "8080:8080" # 映射端口到宿主机 宿主机端口:容器端口 env_file: @@ -13,7 +11,5 @@ services: environment: - ENVIRONMENT=prod # 配置 nonebot 运行环境,此项会被 .env 文件覆盖 - APP_MODULE=bot:app # 配置 asgi 入口 - - SECRET # 通过 SECRET=xxx nb up -d 传递密钥 - - ACCESS_TOKEN # 通过 ACCESS_TOKEN=xxx nb up -d 传递密钥 - MAX_WORKERS=1 # 如果你有多个QQ,且存在 self_id 指定,多个 worker 会导致无法找到其他 websocket 连接 network_mode: bridge diff --git a/pyproject.toml b/pyproject.toml index c987d214..d8dcfdfa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,21 +1,20 @@ [tool.poetry] -name = "bot" +name = "Pallas-Bot" version = "0.1.0" -description = "bot" +description = "Pallas-Bot" authors = [] readme = "README.md" [tool.poetry.dependencies] python = "^3.7.3" -nonebot2 = "^2.0.0.a1" +nonebot2 = "^2.0.0-beta.1" [tool.poetry.dev-dependencies] -nb-cli = "^0.5.0" -nonebot-plugin-test = "^0.3.0" +nb-cli = "^0.6.0" -[nonebot.plugins] +[tool.nonebot] plugins = ["nonebot_plugin_apscheduler"] -plugin_dirs = ["bot/plugins"] +plugin_dirs = ["src/plugins"] [build-system] requires = ["poetry_core>=1.0.0"] diff --git a/bot/plugins/backup/anti-setu/README.md b/src/plugins/backup/anti-setu/README.md similarity index 100% rename from bot/plugins/backup/anti-setu/README.md rename to src/plugins/backup/anti-setu/README.md diff --git a/bot/plugins/backup/anti-setu/__init__.py b/src/plugins/backup/anti-setu/__init__.py similarity index 84% rename from bot/plugins/backup/anti-setu/__init__.py rename to src/plugins/backup/anti-setu/__init__.py index 2627f4d0..f4da560d 100644 --- a/bot/plugins/backup/anti-setu/__init__.py +++ b/src/plugins/backup/anti-setu/__init__.py @@ -4,7 +4,7 @@ import json from nonebot import on_command from nonebot import on_message -from nonebot.adapters.cqhttp import MessageSegment, Message +from nonebot.adapters.onebot.v11 import MessageSegment, Message from nonebot.rule import to_me from nonebot.rule import startswith from nonebot.rule import regex @@ -18,6 +18,8 @@ door = False hello = on_message(block=False, priority=10) + + @hello.handle() async def handle_first_receive(bot: Bot, event: Event, state: T_State): # print(event.dict()) @@ -29,14 +31,16 @@ async def handle_first_receive(bot: Bot, event: Event, state: T_State): if(msg['type'] == 'image') & door: # print(msg['data']['url']) reply = doImgCheck(str(msg['data']['url'])) - if (reply != "")&(reply != None) & door: + if (reply != "") & (reply != None) & door: if float(reply['probability']) > plugin_config.recall_nsfw_pic_probability: - await doRecall(bot,event,state) - await hello.send(reply['conclusion']) + await doRecall(bot, event, state) + await hello.send(reply['conclusion']) # await hello.send(msgStr) return False switch = on_command("色图检测", rule=to_me(), priority=5) + + @switch.handle() async def handle_first_receive(bot: Bot, event: Event, state: T_State): # print("in setu check") @@ -44,6 +48,7 @@ async def handle_first_receive(bot: Bot, event: Event, state: T_State): if args: state["param"] = args + @switch.got("param", prompt="开启或关闭") async def handle_param(bot: Bot, event: Event, state: T_State): global door @@ -52,14 +57,15 @@ async def handle_param(bot: Bot, event: Event, state: T_State): await switch.reject("参数错误!") if param in "开启": door = True - if param in "关闭": + if param in "关闭": door = False await switch.finish("已"+str(param)) + def doImgCheck(picUrl: str): # print("in img check function") request_url = "https://aip.baidubce.com/rest/2.0/solution/v1/img_censor/v2/user_defined" - params = {"imgUrl":picUrl} + params = {"imgUrl": picUrl} access_token = plugin_config.baidu_api_ak request_url = request_url + "?access_token=" + access_token headers = {'content-type': 'application/x-www-form-urlencoded'} @@ -71,12 +77,13 @@ def doImgCheck(picUrl: str): if response.json()['conclusion'] != "合规": conclusion = response.json()['data'][0]['msg'] deep = response.json()['data'][0]['probability'] - reply = {'conclusion':str(conclusion),'probability':str(deep)} + reply = {'conclusion': str( + conclusion), 'probability': str(deep)} return reply except KeyError: print('KeyError') return - else: + else: return return @@ -86,4 +93,4 @@ async def doRecall(bot: Bot, event: Event, state: T_State): # print(event.dict()) msgId = event.dict()['message_id'] # print(msgId) - await bot.call_api('delete_msg',message_id=msgId) + await bot.call_api('delete_msg', message_id=msgId) diff --git a/bot/plugins/backup/anti-setu/config.py b/src/plugins/backup/anti-setu/config.py similarity index 100% rename from bot/plugins/backup/anti-setu/config.py rename to src/plugins/backup/anti-setu/config.py diff --git a/bot/plugins/backup/anti-setu/data_source.py b/src/plugins/backup/anti-setu/data_source.py similarity index 100% rename from bot/plugins/backup/anti-setu/data_source.py rename to src/plugins/backup/anti-setu/data_source.py diff --git a/bot/plugins/backup/anti-setu/model.py b/src/plugins/backup/anti-setu/model.py similarity index 100% rename from bot/plugins/backup/anti-setu/model.py rename to src/plugins/backup/anti-setu/model.py diff --git a/bot/plugins/backup/drift/__init__.py b/src/plugins/backup/drift/__init__.py similarity index 97% rename from bot/plugins/backup/drift/__init__.py rename to src/plugins/backup/drift/__init__.py index 2c69bf13..481fbc3c 100644 --- a/bot/plugins/backup/drift/__init__.py +++ b/src/plugins/backup/drift/__init__.py @@ -1,7 +1,7 @@ import re from nonebot import on_message -from nonebot.adapters.cqhttp import MessageSegment, Message, permission, GroupMessageEvent +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission, GroupMessageEvent from nonebot.rule import keyword, startswith, endswith, Rule from nonebot.typing import T_State from nonebot.adapters import Bot, Event diff --git a/bot/plugins/backup/drift/database.py b/src/plugins/backup/drift/database.py similarity index 100% rename from bot/plugins/backup/drift/database.py rename to src/plugins/backup/drift/database.py diff --git a/bot/plugins/backup/help/__init__.py b/src/plugins/backup/help/__init__.py similarity index 87% rename from bot/plugins/backup/help/__init__.py rename to src/plugins/backup/help/__init__.py index 3710c548..403ef9d8 100644 --- a/bot/plugins/backup/help/__init__.py +++ b/src/plugins/backup/help/__init__.py @@ -1,6 +1,6 @@ from nonebot import on_command -from nonebot.adapters.cqhttp import Bot, GroupMessageEvent, PrivateMessageEvent -from nonebot.adapters.cqhttp.permission import GROUP_ADMIN, GROUP_OWNER +from nonebot.adapters.onebot.v11 import Bot, GroupMessageEvent, PrivateMessageEvent +from nonebot.adapters.onebot.v11.permission import GROUP_ADMIN, GROUP_OWNER status = {} help_text = r'''“战争女神”的故事经历,就交给前赴后继渴望解放的人们好好使用吧! @@ -14,11 +14,13 @@ help = on_command("牛牛帮助", aliases={'牛牛功能', '帕拉斯帮助', '帕拉斯功能'}) + @help.handle() async def _(bot: Bot, event: GroupMessageEvent): if status.get(event.group_id, True): await help.finish(help_text) + @help.handle() async def _(bot: Bot, event: PrivateMessageEvent): await help.finish(help_text) @@ -26,9 +28,10 @@ async def _(bot: Bot, event: PrivateMessageEvent): help_mode_switch = on_command( "牛牛开启帮助", aliases={"牛牛关闭帮助"}, - permission=GROUP_ADMIN|GROUP_OWNER + permission=GROUP_ADMIN | GROUP_OWNER ) + @help_mode_switch.handle() async def _(bot: Bot, event: GroupMessageEvent): msg = event.dict()['raw_message'] diff --git a/bot/plugins/backup/pixiv/__init__.py b/src/plugins/backup/pixiv/__init__.py similarity index 81% rename from bot/plugins/backup/pixiv/__init__.py rename to src/plugins/backup/pixiv/__init__.py index ff4b0a0d..697f2ed5 100644 --- a/bot/plugins/backup/pixiv/__init__.py +++ b/src/plugins/backup/pixiv/__init__.py @@ -1,7 +1,7 @@ import re -from nonebot import on_command , on_message -from nonebot.adapters.cqhttp import MessageSegment, Message, permission, GroupMessageEvent +from nonebot import on_command, on_message +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission, GroupMessageEvent from nonebot.rule import keyword, startswith from nonebot.typing import T_State from nonebot.adapters import Bot, Event @@ -11,8 +11,9 @@ status = {} can = on_message(rule=startswith('牛牛涩涩'), - priority=10, - permission=permission.GROUP) + priority=10, + permission=permission.GROUP) + @can.handle() async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_State): @@ -23,15 +24,16 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat return False can.block = True url = f'https://www.pixiv.net/artworks/{p.id}' - msg: Message = MessageSegment.text(url) + MessageSegment.image(file=p.pic) + msg: Message = MessageSegment.text( + url) + MessageSegment.image(file=p.pic) await can.finish(msg) else: can.block = False tags = on_message(rule=startswith('牛牛我要看'), - priority=10, - permission=permission.GROUP) + priority=10, + permission=permission.GROUP) @tags.handle() @@ -49,7 +51,8 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat await tags.finish("呃......咳嗯,下次不能喝、喝这么多了......呀,博士。你今天走起路来,怎么看着摇摇晃晃的?") return url = f'https://www.pixiv.net/artworks/{p.id}' - msg: Message = MessageSegment.text(url) + MessageSegment.image(file=p.pic) + msg: Message = MessageSegment.text( + url) + MessageSegment.image(file=p.pic) await tags.finish(msg) else: await tags.finish("听啊,悲鸣停止了。这是幸福的和平到来前的宁静。") @@ -58,8 +61,8 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat cannot = on_message(rule=startswith('牛牛涩涩'), - priority=17, - permission=permission.GROUP) + priority=17, + permission=permission.GROUP) @cannot.handle() @@ -73,11 +76,12 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat status = {} switch = on_message( - rule=keyword("牛牛可以涩涩", "牛牛不可以涩涩"), + rule=keyword("牛牛可以涩涩", "牛牛不可以涩涩"), block=True, priority=5, permission=permission.GROUP_ADMIN | permission.GROUP_OWNER) + @switch.handle() async def sw(bot: Bot, event: GroupMessageEvent, state: T_State): s = event.get_plaintext() diff --git a/bot/plugins/backup/pixiv/pixiv.py b/src/plugins/backup/pixiv/pixiv.py similarity index 100% rename from bot/plugins/backup/pixiv/pixiv.py rename to src/plugins/backup/pixiv/pixiv.py diff --git a/bot/plugins/backup/recruit/AdobeHeitiStd-Regular.otf b/src/plugins/backup/recruit/AdobeHeitiStd-Regular.otf similarity index 100% rename from bot/plugins/backup/recruit/AdobeHeitiStd-Regular.otf rename to src/plugins/backup/recruit/AdobeHeitiStd-Regular.otf diff --git a/bot/plugins/backup/recruit/README.md b/src/plugins/backup/recruit/README.md similarity index 100% rename from bot/plugins/backup/recruit/README.md rename to src/plugins/backup/recruit/README.md diff --git a/bot/plugins/backup/recruit/__init__.py b/src/plugins/backup/recruit/__init__.py similarity index 94% rename from bot/plugins/backup/recruit/__init__.py rename to src/plugins/backup/recruit/__init__.py index 2f33fc96..25de4774 100644 --- a/bot/plugins/backup/recruit/__init__.py +++ b/src/plugins/backup/recruit/__init__.py @@ -4,7 +4,7 @@ from io import BytesIO from nonebot import on_message, logger -from nonebot.adapters.cqhttp import MessageSegment, Message, permission, GroupMessageEvent +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission, GroupMessageEvent from nonebot.typing import T_State from nonebot.adapters import Bot, Event @@ -31,7 +31,7 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat hash_value = dhash.dhash_int(image) diff = dhash.get_num_bits_different(hash_value, hash_templ) logger.info(f'dHash diff: {diff}') - + if diff <= hash_diff_thres: ocr = OCR(response.content) ocr_result = ocr.ocr() @@ -46,6 +46,5 @@ async def handle_first_receive(bot: Bot, event: GroupMessageEvent, state: T_Stat await hello.finish(msg) else: await hello.finish('转身吧,勇士们。我们已经获得了完美的胜利,现在是该回去享受庆祝的盛典了。') - + hello.block = False - \ No newline at end of file diff --git a/bot/plugins/backup/recruit/calc.py b/src/plugins/backup/recruit/calc.py similarity index 100% rename from bot/plugins/backup/recruit/calc.py rename to src/plugins/backup/recruit/calc.py diff --git a/bot/plugins/backup/recruit/config.py b/src/plugins/backup/recruit/config.py similarity index 100% rename from bot/plugins/backup/recruit/config.py rename to src/plugins/backup/recruit/config.py diff --git a/bot/plugins/backup/recruit/data.py b/src/plugins/backup/recruit/data.py similarity index 100% rename from bot/plugins/backup/recruit/data.py rename to src/plugins/backup/recruit/data.py diff --git a/bot/plugins/backup/recruit/image_creator.py b/src/plugins/backup/recruit/image_creator.py similarity index 100% rename from bot/plugins/backup/recruit/image_creator.py rename to src/plugins/backup/recruit/image_creator.py diff --git a/bot/plugins/backup/recruit/ocr.py b/src/plugins/backup/recruit/ocr.py similarity index 100% rename from bot/plugins/backup/recruit/ocr.py rename to src/plugins/backup/recruit/ocr.py diff --git a/bot/plugins/backup/text-analyse/README.md b/src/plugins/backup/text-analyse/README.md similarity index 100% rename from bot/plugins/backup/text-analyse/README.md rename to src/plugins/backup/text-analyse/README.md diff --git a/bot/plugins/backup/text-analyse/__init__.py b/src/plugins/backup/text-analyse/__init__.py similarity index 76% rename from bot/plugins/backup/text-analyse/__init__.py rename to src/plugins/backup/text-analyse/__init__.py index bac77dcc..2c3e895c 100644 --- a/bot/plugins/backup/text-analyse/__init__.py +++ b/src/plugins/backup/text-analyse/__init__.py @@ -5,7 +5,7 @@ from nonebot import permission as perm from nonebot import on_command from nonebot import on_message -from nonebot.adapters.cqhttp import MessageSegment, Message, permission +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission from nonebot.rule import to_me from nonebot.rule import startswith from nonebot.rule import regex @@ -24,14 +24,16 @@ block=False, priority=20, permission=permission.GROUP) + + @textAnalyse.handle() -async def handle_first_receive(bot: Bot, event: Event, state: T_State): - door = plugin_config.textAnalyseSwitch +async def handle_first_receive(bot: Bot, event: Event, state: T_State): + door = plugin_config.textAnalyseSwitch if not door: return False nicknameList = plugin_config.nicknameList keyWordsList = ["涩涩"] - #print(event.dict()) + # print(event.dict()) nl = nicknameList.split(',') if event.dict()['message_type'] == 'group': if len(event.dict()['message']) == 1: @@ -45,20 +47,20 @@ async def handle_first_receive(bot: Bot, event: Event, state: T_State): for nickname in nl: if nickname in msgContent: isCallBot = True - msgContent = msgContent.replace(nickname,'') + msgContent = msgContent.replace(nickname, '') for keyWords in keyWordsList: if keyWords in msgContent: - isNotOtherKeyWords = False + isNotOtherKeyWords = False if isCallBot != True: receiveTime = event.dict()['time'] t = int(time.time()) # 防止发言频率过高 冻结 封号 if t - receiveTime < 1: - time.sleep(1) + time.sleep(1) isCallBot = event.dict()['to_me'] - + # print(isCallBot) - if isCallBot and isNotOtherKeyWords : + if isCallBot and isNotOtherKeyWords: r = doTextAnalyse(msgContent) await textAnalyse.send(r) except Exception as e: @@ -70,6 +72,8 @@ async def handle_first_receive(bot: Bot, event: Event, state: T_State): return False switch = on_command('对话情绪识别', rule=to_me(), priority=5) + + @switch.handle() async def handle__first_receive(bot: Bot, event: Event, state: T_State): # print("in setu check") @@ -77,6 +81,7 @@ async def handle__first_receive(bot: Bot, event: Event, state: T_State): if args: state['param'] = args + @switch.got('param', prompt='开启或关闭') async def handle_param(bot: Bot, event: Event, state: T_State): global door @@ -85,24 +90,25 @@ async def handle_param(bot: Bot, event: Event, state: T_State): await switch.reject('参数错误!') if param in '开启': door = True - if param in '关闭': + if param in '关闭': door = False await switch.finish('已'+str(param)) -def doTextAnalyse(msg:str()): - # print(msg) - """ 你的 APPID AK SK """ - APP_ID = plugin_config.APP_ID - API_KEY = plugin_config.API_KEY - SECRET_KEY = plugin_config.SECRET_KEY - client = AipNlp(APP_ID, API_KEY, SECRET_KEY) - text = msg - """ 调用对话情绪识别接口 """ + +def doTextAnalyse(msg: str()): + # print(msg) + """ 你的 APPID AK SK """ + APP_ID = plugin_config.APP_ID + API_KEY = plugin_config.API_KEY + SECRET_KEY = plugin_config.SECRET_KEY + client = AipNlp(APP_ID, API_KEY, SECRET_KEY) + text = msg + """ 调用对话情绪识别接口 """ # client.emotion(text) - """ 如果有可选参数 """ - options = {} - # options["scene"] = "talk" - """ 带参数调用对话情绪识别接口 """ - reply = client.emotion(text, options) - # print(str(reply)) - return reply['items'][0]['replies'][0] + """ 如果有可选参数 """ + options = {} + # options["scene"] = "talk" + """ 带参数调用对话情绪识别接口 """ + reply = client.emotion(text, options) + # print(str(reply)) + return reply['items'][0]['replies'][0] diff --git a/bot/plugins/backup/text-analyse/config.py b/src/plugins/backup/text-analyse/config.py similarity index 100% rename from bot/plugins/backup/text-analyse/config.py rename to src/plugins/backup/text-analyse/config.py diff --git a/bot/plugins/greeting/README.md b/src/plugins/greeting/README.md similarity index 100% rename from bot/plugins/greeting/README.md rename to src/plugins/greeting/README.md diff --git a/bot/plugins/greeting/__init__.py b/src/plugins/greeting/__init__.py similarity index 97% rename from bot/plugins/greeting/__init__.py rename to src/plugins/greeting/__init__.py index 74e4f701..1d8e76e7 100644 --- a/bot/plugins/greeting/__init__.py +++ b/src/plugins/greeting/__init__.py @@ -4,7 +4,7 @@ from pathlib import Path from nonebot import on_command, on_message, on_notice, get_driver -from nonebot.adapters.cqhttp import MessageSegment, Message, permission, GroupMessageEvent +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission, GroupMessageEvent from nonebot.rule import keyword, startswith, to_me from nonebot.typing import T_State from nonebot.adapters import Bot, Event diff --git a/bot/plugins/greeting/config.py b/src/plugins/greeting/config.py similarity index 100% rename from bot/plugins/greeting/config.py rename to src/plugins/greeting/config.py diff --git a/bot/plugins/greeting/wiki.py b/src/plugins/greeting/wiki.py similarity index 100% rename from bot/plugins/greeting/wiki.py rename to src/plugins/greeting/wiki.py diff --git a/bot/plugins/music/README.md b/src/plugins/music/README.md similarity index 100% rename from bot/plugins/music/README.md rename to src/plugins/music/README.md diff --git a/bot/plugins/music/__init__.py b/src/plugins/music/__init__.py similarity index 70% rename from bot/plugins/music/__init__.py rename to src/plugins/music/__init__.py index d1006f6e..209a30a6 100644 --- a/bot/plugins/music/__init__.py +++ b/src/plugins/music/__init__.py @@ -3,11 +3,12 @@ from pathlib import Path from nonebot import on_command, on_message, on_notice, get_driver -from nonebot.adapters.cqhttp import MessageSegment, Message, permission, GroupMessageEvent +from nonebot.adapters.onebot.v11 import MessageSegment, Message, permission, GroupMessageEvent from nonebot.rule import keyword, startswith, to_me from nonebot.typing import T_State from nonebot.adapters import Bot, Event + def get_music_name(): resource_path = "resource/music/" all_music = os.listdir(resource_path) @@ -15,9 +16,9 @@ def get_music_name(): return resource_path + music -music_cmd = on_command("牛牛唱歌", - aliases={'牛牛唱首歌', '帕拉斯唱歌', '帕拉斯唱首歌'} - ) +music_cmd = on_command("牛牛唱歌", + aliases={'牛牛唱首歌', '帕拉斯唱歌', '帕拉斯唱首歌'} + ) @music_cmd.handle() diff --git a/bot/plugins/music/readme.jpg b/src/plugins/music/readme.jpg similarity index 100% rename from bot/plugins/music/readme.jpg rename to src/plugins/music/readme.jpg diff --git a/bot/plugins/push/README.md b/src/plugins/push/README.md similarity index 100% rename from bot/plugins/push/README.md rename to src/plugins/push/README.md diff --git a/bot/plugins/push/__init__.py b/src/plugins/push/__init__.py similarity index 98% rename from bot/plugins/push/__init__.py rename to src/plugins/push/__init__.py index 4d7db50a..1b8416d0 100644 --- a/bot/plugins/push/__init__.py +++ b/src/plugins/push/__init__.py @@ -2,7 +2,7 @@ from .weibo import Weibo from datetime import datetime from nonebot import require, get_bot, get_driver -from nonebot.adapters.cqhttp import MessageSegment, Message +from nonebot.adapters.onebot.v11 import MessageSegment, Message import asyncio from dateutil import parser diff --git a/bot/plugins/push/bili_api.py b/src/plugins/push/bili_api.py similarity index 100% rename from bot/plugins/push/bili_api.py rename to src/plugins/push/bili_api.py diff --git a/bot/plugins/push/config.py b/src/plugins/push/config.py similarity index 100% rename from bot/plugins/push/config.py rename to src/plugins/push/config.py diff --git a/bot/plugins/push/github.py b/src/plugins/push/github.py similarity index 100% rename from bot/plugins/push/github.py rename to src/plugins/push/github.py diff --git a/bot/plugins/push/weibo.py b/src/plugins/push/weibo.py similarity index 100% rename from bot/plugins/push/weibo.py rename to src/plugins/push/weibo.py diff --git a/bot/plugins/repeater/README.md b/src/plugins/repeater/README.md similarity index 100% rename from bot/plugins/repeater/README.md rename to src/plugins/repeater/README.md diff --git a/bot/plugins/repeater/__init__.py b/src/plugins/repeater/__init__.py similarity index 95% rename from bot/plugins/repeater/__init__.py rename to src/plugins/repeater/__init__.py index 9f367298..3f25a218 100644 --- a/bot/plugins/repeater/__init__.py +++ b/src/plugins/repeater/__init__.py @@ -6,9 +6,9 @@ from nonebot.typing import T_State from nonebot.rule import keyword, to_me from nonebot.adapters import Bot, Event -from nonebot.adapters.cqhttp import GroupMessageEvent, PrivateMessageEvent +from nonebot.adapters.onebot.v11 import GroupMessageEvent, PrivateMessageEvent -from nonebot.adapters.cqhttp import permission +from nonebot.adapters.onebot.v11 import permission from .model import Chat, ChatData diff --git a/bot/plugins/repeater/config.py b/src/plugins/repeater/config.py similarity index 100% rename from bot/plugins/repeater/config.py rename to src/plugins/repeater/config.py diff --git a/bot/plugins/repeater/model.py b/src/plugins/repeater/model.py similarity index 99% rename from bot/plugins/repeater/model.py rename to src/plugins/repeater/model.py index 9926c89e..e4ae1533 100644 --- a/bot/plugins/repeater/model.py +++ b/src/plugins/repeater/model.py @@ -15,8 +15,8 @@ import re import atexit -from nonebot.adapters.cqhttp import GroupMessageEvent, PrivateMessageEvent -from nonebot.adapters.cqhttp import Message, MessageSegment +from nonebot.adapters.onebot.v11 import GroupMessageEvent, PrivateMessageEvent +from nonebot.adapters.onebot.v11 import Message, MessageSegment mongo_client = pymongo.MongoClient('127.0.0.1', 27017, w=0) diff --git a/bot/plugins/request/__init__.py b/src/plugins/request/__init__.py similarity index 89% rename from bot/plugins/request/__init__.py rename to src/plugins/request/__init__.py index 923a689f..b777a3c9 100644 --- a/bot/plugins/request/__init__.py +++ b/src/plugins/request/__init__.py @@ -1,6 +1,6 @@ import nonebot from nonebot import on_command, on_request, on_notice, get_driver -from nonebot.adapters.cqhttp import MessageSegment, Message, FriendRequestEvent, GroupRequestEvent, Bot +from nonebot.adapters.onebot.v11 import MessageSegment, Message, FriendRequestEvent, GroupRequestEvent, Bot from nonebot.rule import keyword, startswith, to_me from nonebot.typing import T_State from typing import Union