Upload Script & Update README.md

This commit is contained in:
N1ngYu 2025-03-02 11:28:59 +08:00
parent cc05274445
commit 11145122b6
2 changed files with 19 additions and 16 deletions

View File

@ -11,11 +11,12 @@ A QQbot Based on Nonebot.
1. Install [Python3.12](https://www.python.org/downloads/release/python-3129/)
2. Install [Nonebot](https://nonebot.dev/docs/quick-start)
3. Download this repo.
4. Create a nonebot project at another place and copy .venv/pyvenv.cfg to the bot folder.
5. Change the configuration on .env.prod.
6. Change the script path on /.venv/Lib/site-packages/nonebot_plugin_maimai_helper/__init__.py, line 87, 93, 201, 204 and line 205. (Please ignore my sh!t code, thanks:()
7. Also, the script need change resouse path, too. The defult res path is `F:/res/` ; generate path is `F:/img/`
8. Run `nb run` in the SaltBot folder.
4. Download the resource file for [maicard](https://alist.error063.work/Games/res.zip) and put it into .env.prod. *The resource file and script code are from [Error063](https://github.com/Error063/maicard?tab=readme-ov-file)
5. Create a nonebot project at another place and copy .venv/pyvenv.cfg to the bot folder.
6. Change the configuration on .env.prod.
7. Change the script path on /.venv/Lib/site-packages/nonebot_plugin_maimai_helper/__init__.py, line 87, 93, 201, 204 and line 205. (Please ignore my sh!t code, thanks:()
8. Also, the script need change resouse path, too. The defult res path is `F:/res/` ; generate path is `F:/img/`
9. Run `nb run` in the SaltBot folder.
> [!NOTE]
> This bot will use MySQL to storge your & others Userid & Token.
@ -32,11 +33,12 @@ A QQbot Based on Nonebot.
1. 安装 [Python3.12](https://www.python.org/downloads/release/python-3129/)
2. 安装 [Nonebot](https://nonebot.dev/docs/quick-start)
3. 下载此仓库到你的本地设备。
4. 在别的地方创建一个新的nonebot项目并将 .venv/pyvenv.cfg 复制到你的Bot目录下并覆盖。
5. 按照.env.prod中的提示更改配置。
6. 更改在/.venv/Lib/site-packages/nonebot_plugin_maimai_helper/\__init__.py下的第 87, 93, 201, 204, 205行的脚本路径。(不要在意我的狗史代码,谢谢你¯\_(ツ)_/¯)
7. 你还需要更改脚本的资源路径,默认资源为 `F:/res/` 生成为 `F:/img/`
8. 在Bot运行目录下运行 `nb run` 指令以启动。
4. 下载用于生成[maicard](https://alist.error063.work/Games/res.zip)的资源文件并将此文件目录填入至.env.prod。*资源文件及脚本代码来源[Error063](https://github.com/Error063/maicard?tab=readme-ov-file)
5. 在别的地方创建一个新的nonebot项目并将 .venv/pyvenv.cfg 复制到你的Bot目录下并覆盖。
6. 按照.env.prod中的提示更改配置。
7. 更改在/.venv/Lib/site-packages/nonebot_plugin_maimai_helper/\__init__.py下的第 87, 93, 201, 204, 205行的脚本路径。(不要在意我的狗史代码,谢谢你¯\_(ツ)_/¯)
8. 你还需要更改脚本*generate_img.py*的资源路径,默认资源路径为 `F:/res/` 生成路径为 `F:/img/`
9. 在Bot运行目录下运行 `nb run` 指令以启动。
> [!NOTE]
> 此Bot依赖于MySQL数据库以存储你和别人的*userid*和*token*。

View File

@ -3,14 +3,15 @@ import logging
import os
import math
from datetime import datetime
import random
import colorsys
from PIL import Image, ImageDraw, ImageFont, ImageFilter
logger = logging.getLogger(__name__)
maimaiImgPath = str(os.path.join(os.getcwd(), "res", "images")) + '/'
materialPath = str(os.path.join(os.getcwd(), "res", "material")) + '/'
maimaiImgPath = ('E:/res/images') + '/'
materialPath = ('E:/res/material') + '/'
@ -364,7 +365,7 @@ def call_user_img(user_data, no_chara=False):
UserImg: Image = drawUserImg(user_data["title"], user_data["rating"], user_data['courseRank'], user_data['nickname'], icon, plate,user_data["titleRare"],user_data["classRank"])
img.paste(UserImg, (25, 25), UserImg)
network_status_img = Image.open(rf"{maimaiImgPath}/network/on.png")
network_status_img = random.choice([Image.open(rf"{maimaiImgPath}/network/on.png"), Image.open(rf"{maimaiImgPath}/network/off.png"), Image.open(rf"{maimaiImgPath}/network/warning.png")])
img.paste(network_status_img, (1014, 25), network_status_img)
if not no_chara:
@ -380,7 +381,7 @@ def call_user_img(user_data, no_chara=False):
designDraw = ImageDraw.Draw(img)
# 保留这些可以喵?
designDraw.text((20, 457),
f"Generated by SaltBot at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} Code by Error063 - 图片仅供参考",
f"Generated by SaltBot at {datetime.now().strftime('%Y-%m-%d %H:%M:%S')} Code by Error063 Plugin Edit by NingYu - 图片仅供参考",
font=ImageFont.truetype(rf'{materialPath}/GenSenMaruGothicTW-Bold.ttf', 12), fill=text_color)
return img
@ -441,7 +442,7 @@ def main():
parser.add_argument("--titleRare", type=str, default="Sliver", help="玩家称号稀有度")
parser.add_argument("--chara", nargs='+', type=int, default=[101, 104, 355610, 355611, 355612], help="玩家设置的旅行伙伴ID列表")
parser.add_argument("--charaLevel", nargs='+', type=int, default=[1000, 9999, 1000, 9999, 9999], help="玩家设置的旅行伙伴等级列表")
parser.add_argument("--output", type=str, default="E:/img/output.png", help="图片输出路径")
parser.add_argument("--output", type=str, default="./output.png", help="图片输出路径")
args = parser.parse_args()
@ -462,7 +463,7 @@ def main():
print(f"{k}: {v}")
a = call_user_img(user_data, False)
a.save('E:/img/output.png')
a.save(args.output)
print("\nDone")
print(f"File path: {args.output}")
# a.show()