1111
53
.env
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
|
||||||
|
DEBUG=true
|
||||||
|
HOST=127.0.0.1 # 配置 NoneBot 监听的 IP / 主机名
|
||||||
|
PORT=11011 # 配置 NoneBot 监听的端口
|
||||||
|
COMMAND_START=["","/"] # 配置命令起始字符
|
||||||
|
COMMAND_SEP=["."] # 配置命令分割字符
|
||||||
|
DRIVER=~fastapi+~websockets+~httpx
|
||||||
|
LOG_LEVEL=INFO
|
||||||
|
|
||||||
|
|
||||||
|
SUPERUSERS=[]
|
||||||
|
|
||||||
|
NICKNAME=[]
|
||||||
|
|
||||||
|
# OneBot 配置
|
||||||
|
# https://onebot.adapters.nonebot.dev/docs/guide/configuration
|
||||||
|
ONEBOT_ACCESS_TOKEN
|
||||||
|
ONEBOT_V12_ACCESS_TOKEN
|
||||||
|
ONEBOT_V12_USE_MSGPACK=true
|
||||||
|
|
||||||
|
# NoneBot-Plugin-BAWiki BA插件相关配置
|
||||||
|
# https://github.com/lgc-NB2Dev/nonebot-plugin-bawiki
|
||||||
|
BA_PROXY
|
||||||
|
BA_SCHALE_URL=https://schale.gg/
|
||||||
|
BA_SCHALE_MIRROR_URL=https://schale.lgc2333.top/
|
||||||
|
BA_BAWIKI_DB_URL=https://bawiki.lgc2333.top/
|
||||||
|
|
||||||
|
# 数据存储
|
||||||
|
# https://github.com/he0119/nonebot-plugin-datastore
|
||||||
|
DATASTORE_DATA_DIR=./hexi/data
|
||||||
|
DATASTORE_CONFIG_DIR=./hexi/data/config
|
||||||
|
DATASTORE_CACHE_DIR=./hexi/data/cache
|
||||||
|
DATASTORE_DATABASE_ECHO=false
|
||||||
|
DATASTORE_DATABASE_URL
|
||||||
|
|
||||||
|
|
||||||
|
# Nonebot-bison
|
||||||
|
# https://nonebot-bison.vercel.app/usage/#%E9%85%8D%E7%BD%AE
|
||||||
|
# https://github.com/felinae98/nonebot-bison/blob/main/src/plugins/nonebot_bison/plugin_config.py
|
||||||
|
BISON_SKIP_BROWSER_CHECK=true
|
||||||
|
BISON_CONFIG_PATH=./hexi/data/bison
|
||||||
|
BISON_USE_PIC=true
|
||||||
|
BISON_OUTER_URL=http://localhost:11011/bison
|
||||||
|
BISON_USE_PIC_MERGE=0
|
||||||
|
bison_to_me=false
|
||||||
|
|
||||||
|
# Sentry 日志配置
|
||||||
|
SENTRY_ENVIRONMENT=prod
|
||||||
|
SENTRY_DSN
|
||||||
|
|
||||||
|
|
||||||
|
# 是否开启禁言等操作的成功提示【不开启的话踢人/禁言等成功没有QQ消息提示】
|
||||||
|
callback_notice=true # 如果不想开启设置成 false 或者不添加此配置项【默认关闭】
|
43
.env.dev
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
DEBUG=true # 调试模式
|
||||||
|
HOST=127.0.0.1 # 配置 NoneBot 监听的 IP / 主机名
|
||||||
|
PORT=11011 # 配置 NoneBot 监听的端口
|
||||||
|
COMMAND_START=["","/","."] # 配置命令起始字符
|
||||||
|
COMMAND_SEP=["."] # 配置命令分割字符
|
||||||
|
DRIVER=~fastapi+~websockets+~httpx # 驱动器
|
||||||
|
LOG_LEVEL=INFO # 日志等级
|
||||||
|
|
||||||
|
SUPERUSERS=["2931589710"] # 超管
|
||||||
|
|
||||||
|
NICKNAME=["Elika"] # 机器人昵称
|
||||||
|
|
||||||
|
# OneBot 配置
|
||||||
|
ONEBOT_ACCESS_TOKEN
|
||||||
|
ONEBOT_V12_ACCESS_TOKEN
|
||||||
|
ONEBOT_V12_USE_MSGPACK=true
|
||||||
|
|
||||||
|
# BA插件相关配置
|
||||||
|
BA_PROXY
|
||||||
|
BA_SCHALE_URL=https://schale.gg/
|
||||||
|
BA_SCHALE_MIRROR_URL=https://schale.lgc2333.top/
|
||||||
|
BA_BAWIKI_DB_URL=https://bawiki.lgc2333.top/
|
||||||
|
|
||||||
|
# 数据存储
|
||||||
|
DATASTORE_DATA_DIR=./hexi/data
|
||||||
|
DATASTORE_CONFIG_DIR=./hexi/data/config
|
||||||
|
DATASTORE_CACHE_DIR=./hexi/data/cache
|
||||||
|
DATASTORE_DATABASE_ECHO=false
|
||||||
|
DATASTORE_DATABASE_URL
|
||||||
|
|
||||||
|
|
||||||
|
# Nonebot-bison 订阅管理
|
||||||
|
BISON_SKIP_BROWSER_CHECK=true
|
||||||
|
BISON_CONFIG_PATH=
|
||||||
|
BISON_USE_PIC=true
|
||||||
|
BISON_OUTER_URL=http://localhost:11011/bison
|
||||||
|
BISON_USE_PIC_MERGE=2
|
||||||
|
bison_to_me=false
|
||||||
|
|
||||||
|
# Sentry 日志配置
|
||||||
|
SENTRY_ENVIRONMENT=prod
|
||||||
|
SENTRY_DSN
|
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
HEXI bot
|
||||||
|
========
|
||||||
|
个人娱乐bot,集成了BF战绩查询功能,以及一些娱乐功能,也可以自行去nb商店安装插件
|
26
bot.py
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
import nonebot
|
||||||
|
from nonebot.adapters.onebot.v11 import Adapter as ONEBOTV11Adapter # onebot v11
|
||||||
|
from nonebot.adapters.onebot.v12 import Adapter as OneBotV12Adapter # onebot v12
|
||||||
|
from nonebot.adapters.minecraft import Adapter as minecraftAdapter # minecraft
|
||||||
|
from nonebot.log import logger
|
||||||
|
from sqlalchemy import StaticPool
|
||||||
|
|
||||||
|
# 初始化 NoneBot 以及 数据库
|
||||||
|
nonebot.init(datastore_engine_options={"poolclass": StaticPool})
|
||||||
|
|
||||||
|
# 注册适配器
|
||||||
|
app = nonebot.get_asgi()
|
||||||
|
driver = nonebot.get_driver()
|
||||||
|
driver.register_adapter(ONEBOTV11Adapter)
|
||||||
|
driver.register_adapter(OneBotV12Adapter)
|
||||||
|
driver.register_adapter(minecraftAdapter)
|
||||||
|
|
||||||
|
# 加载自定义插件
|
||||||
|
nonebot.load_plugins("hexi") # 加载bot自定义插件
|
||||||
|
|
||||||
|
# 加载配置文件中的插件
|
||||||
|
nonebot.load_from_toml("pyproject.toml")
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
logger.warning("xx?启动!")
|
||||||
|
nonebot.run(app="__mp_main__:app")
|
0
hexi/__init__.py
Normal file
0
hexi/plugins/__init__.py
Normal file
47
hexi/plugins/battlefield2042status/__init__.py
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
from nonebot import on_command
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageEvent, MessageSegment
|
||||||
|
from nonebot.plugin import PluginMetadata
|
||||||
|
from nonebot.typing import T_State
|
||||||
|
|
||||||
|
from .bf2042 import bf_2042_gen_pic
|
||||||
|
from .data import query_data
|
||||||
|
from ..core.message_handle import MessageState
|
||||||
|
|
||||||
|
__plugin_meta__ = PluginMetadata(
|
||||||
|
name="2042战绩查询",
|
||||||
|
description="根据对应指令查询对应数据",
|
||||||
|
usage="发送 [.盒/.数据/.武器/.配备/.专家/.载具] 游戏ID",
|
||||||
|
type="application",
|
||||||
|
)
|
||||||
|
|
||||||
|
status_aliases = {".盒", ".数据", ".武器", ".配备", ".专家", ".载具"}
|
||||||
|
|
||||||
|
status = on_command("2042战绩", aliases=status_aliases)
|
||||||
|
|
||||||
|
|
||||||
|
@status.handle()
|
||||||
|
async def handle_status(event: MessageEvent, state: T_State):
|
||||||
|
m_state = MessageState(state)
|
||||||
|
cmd = m_state.get_command()
|
||||||
|
msg = m_state.get_command_arg()
|
||||||
|
a = {".盒": 0,
|
||||||
|
".武器": 1,
|
||||||
|
".配备": 3,
|
||||||
|
".专家": 4,
|
||||||
|
".载具": 5
|
||||||
|
}
|
||||||
|
if msg is None:
|
||||||
|
await status.send("消息是空的喵")
|
||||||
|
else:
|
||||||
|
msg_info = (MessageSegment.text(f"消息是{msg.text}"))
|
||||||
|
await status.send(msg_info)
|
||||||
|
print(state)
|
||||||
|
print(m_state)
|
||||||
|
message_id = event.message_id
|
||||||
|
|
||||||
|
# img_mes = await query_data(player, "pc", query_type)
|
||||||
|
# if img_mes[0]:
|
||||||
|
# res = MessageSegment.image(img_mes[1])
|
||||||
|
# else:
|
||||||
|
# res = MessageSegment.text(img_mes[1])
|
||||||
|
# msg_gen = (MessageSegment.reply(message_id), res)
|
521
hexi/plugins/battlefield2042status/bf2042.py
Normal file
@ -0,0 +1,521 @@
|
|||||||
|
import base64
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
from decimal import Decimal
|
||||||
|
from io import BytesIO
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
from .data_tools import hacker_check, get_bf_ban_check
|
||||||
|
from .picture_tools import draw_rect, circle_corner, png_resize, \
|
||||||
|
get_top_object_img, \
|
||||||
|
image_paste, paste_ic_logo, get_avatar, get_special_icon, draw_point_line
|
||||||
|
|
||||||
|
classesList = {
|
||||||
|
"Mackay": " 麦凯",
|
||||||
|
"Angel": " 天使",
|
||||||
|
"Falck": " 法尔克",
|
||||||
|
"Paik": " 白智秀",
|
||||||
|
"Sundance": " 日舞",
|
||||||
|
"Dozer": " 推土机",
|
||||||
|
"Rao": " 拉奥",
|
||||||
|
"Lis": " 莉丝",
|
||||||
|
"Irish": "爱尔兰佬",
|
||||||
|
"Crawford": "克劳福德",
|
||||||
|
"Boris": " 鲍里斯",
|
||||||
|
"Zain": " 扎因",
|
||||||
|
"Casper": " 卡斯帕",
|
||||||
|
"Blasco": "布拉斯科",
|
||||||
|
}
|
||||||
|
classes_type_list = {
|
||||||
|
"Assault": "突击兵",
|
||||||
|
"Support": "支援兵",
|
||||||
|
"Recon": "侦察兵",
|
||||||
|
"Engineer": "工程兵"
|
||||||
|
}
|
||||||
|
|
||||||
|
ban_reason = {
|
||||||
|
0: "未处理",
|
||||||
|
1: "石锤",
|
||||||
|
2: "待自证",
|
||||||
|
3: "MOSS自证",
|
||||||
|
4: "无效举报",
|
||||||
|
5: "讨论中",
|
||||||
|
6: "需要更多管理投票",
|
||||||
|
7: "未知原因封禁",
|
||||||
|
8: "刷枪"
|
||||||
|
}
|
||||||
|
|
||||||
|
filepath = os.path.dirname(__file__).replace("\\", "/")
|
||||||
|
bf_ban_url = "https://api.gametools.network/bfban/checkban"
|
||||||
|
|
||||||
|
|
||||||
|
async def bf_2042_gen_pic(data, platform):
|
||||||
|
# 1.创建黑色板块 1920*1080
|
||||||
|
new_img = Image.new('RGBA', (1920, 1080), (0, 0, 0, 1000))
|
||||||
|
# 2.获取头像图片 150*150
|
||||||
|
platform_id = 1
|
||||||
|
nucleus_id = data['userId']
|
||||||
|
persona_id = data['id']
|
||||||
|
# 调用接口获取正确的头像
|
||||||
|
avatar = await get_avatar(platform_id, persona_id, nucleus_id)
|
||||||
|
avatar = png_resize(avatar, new_width=145, new_height=145)
|
||||||
|
avatar = circle_corner(avatar, 10)
|
||||||
|
# 3.获取背景 并 模糊
|
||||||
|
# 判断是否为support
|
||||||
|
bg_name = os.listdir(filepath + "/img/bg/common/")
|
||||||
|
index = random.randint(0, len(bg_name) - 1)
|
||||||
|
img = Image.open(filepath + f"/img/bg/common/{bg_name[index]}").convert('RGBA').resize((1920, 1080))
|
||||||
|
# img_filter = img.filter(ImageFilter.GaussianBlur(radius=3))
|
||||||
|
# 4.拼合板块+背景+logo
|
||||||
|
new_img.paste(img, (0, 0))
|
||||||
|
logo = Image.open(filepath + "/img/bf2042_logo/bf2042logo.png").convert('RGBA')
|
||||||
|
logo = png_resize(logo, new_width=145, new_height=145)
|
||||||
|
logo = circle_corner(logo, 10)
|
||||||
|
new_img = image_paste(logo, new_img, (1750, 30))
|
||||||
|
# 5.绘制头像框 (x1,y1,x2,y2)
|
||||||
|
# x2 = x1+width+img_width+width
|
||||||
|
# y2 = y1+width+img_height+width
|
||||||
|
draw = ImageDraw.Draw(new_img)
|
||||||
|
new_img = draw_rect(new_img, (25, 25, 768, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
# 6添加头像
|
||||||
|
new_img = image_paste(avatar, new_img, (30, 30))
|
||||||
|
# 7.添加用户信息文字
|
||||||
|
|
||||||
|
# # 等级计算
|
||||||
|
# xp = data["XP"][0]["total"]
|
||||||
|
# unit = 93944
|
||||||
|
# level = int((xp \\ unit) + 0.55)
|
||||||
|
# color = 'white'
|
||||||
|
# if int((xp \\ 93944) + 0.55) > 0:
|
||||||
|
# level = ('S' + str(level - 99))
|
||||||
|
# color = '#FF3333'
|
||||||
|
|
||||||
|
# 载入字体
|
||||||
|
en_text_font = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 36)
|
||||||
|
ch_text_font = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 36)
|
||||||
|
# 获取用化名
|
||||||
|
player_name = data["userName"]
|
||||||
|
plat = Image.open(filepath + "/img/platform/origin.png").convert("RGBA").resize((40, 40))
|
||||||
|
if platform == "pc":
|
||||||
|
plat = Image.open(filepath + "/img/platform/origin.png").convert("RGBA").resize((40, 40))
|
||||||
|
elif platform == "psn":
|
||||||
|
plat = Image.open(filepath + "/img/platform/playstation.png").convert("RGBA").resize((40, 40))
|
||||||
|
elif platform == "xbl":
|
||||||
|
plat = Image.open(filepath + "/img/platform/xbox.png").convert("RGBA").resize((40, 40))
|
||||||
|
draw.text((208, 33), '玩家:', fill='white', font=ch_text_font)
|
||||||
|
draw.text((308, 30), f'{player_name}', fill='white', font=en_text_font)
|
||||||
|
# 游玩平台
|
||||||
|
new_img = image_paste(plat, new_img, (208, 120))
|
||||||
|
draw.text((260, 120), '游玩时长:', fill='white', font=ch_text_font)
|
||||||
|
time_played = data["timePlayed"]
|
||||||
|
if ',' in time_played:
|
||||||
|
times = time_played.split(',')
|
||||||
|
if "days" in times[0]:
|
||||||
|
times_1 = int(times[0].replace("days", "").strip()) * 24
|
||||||
|
else:
|
||||||
|
times_1 = int(times[0].replace("day", "").strip()) * 24
|
||||||
|
times_2 = times[1].split(':')
|
||||||
|
time_part2 = int(times_2[0]) + Decimal(int(times_2[1]) / 60).quantize(Decimal("0.00"))
|
||||||
|
time_played = str(times_1 + time_part2)
|
||||||
|
else:
|
||||||
|
time_part2 = Decimal(int(time_played.split(':')[1]) / 60).quantize(Decimal("0.00"))
|
||||||
|
time_played = int(time_played.split(':')[0]) + time_part2
|
||||||
|
draw.text((430, 118), f'{time_played} H', fill='white', font=en_text_font)
|
||||||
|
# 8.绘制最佳专家外框
|
||||||
|
# 获取兵种图标
|
||||||
|
best_class = sorted(data["classes"], key=lambda k: k['kills'], reverse=True)[0]
|
||||||
|
# 专家名称
|
||||||
|
best_specialist = best_class["characterName"]
|
||||||
|
# 专家击杀数
|
||||||
|
best_specialist_kills = best_class["kills"]
|
||||||
|
# 专家kpm
|
||||||
|
best_specialist_kpm = best_class["kpm"]
|
||||||
|
# 专家kd
|
||||||
|
best_specialist_kill_death = best_class["killDeath"]
|
||||||
|
# 游玩时长
|
||||||
|
seconds = best_class["secondsPlayed"]
|
||||||
|
best_specialist_played = round(seconds / 3600, 2)
|
||||||
|
# 专家图标
|
||||||
|
class_icon = await get_special_icon(best_class)
|
||||||
|
# 图像缩放
|
||||||
|
class_icon = class_icon.resize((90, 90))
|
||||||
|
# 绘制最佳专家
|
||||||
|
ch_text_font_bc = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 38)
|
||||||
|
ch_text_font_s = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 30)
|
||||||
|
new_img = draw_rect(new_img, (768 + 25, 25, 1318, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
draw.text((815, 55), '最 佳', fill='lightgreen', font=ch_text_font_bc)
|
||||||
|
draw.text((815, 105), '专 家', fill='lightgreen', font=ch_text_font_bc)
|
||||||
|
new_img = image_paste(class_icon, new_img, (930, 35))
|
||||||
|
spec_name = classesList[best_specialist]
|
||||||
|
draw.text((918, 130), f'{spec_name}', fill='skyblue', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 40), f'KD:{best_specialist_kill_death}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 70), f'KPM:{best_specialist_kpm}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 103), f'击杀数:{best_specialist_kills}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 138), f'时长:{best_specialist_played}', fill='white', font=ch_text_font_s)
|
||||||
|
|
||||||
|
# 9.MVP/最佳小队
|
||||||
|
# 绘制最佳小队/MVP
|
||||||
|
new_img = draw_rect(new_img, (1318 + 25, 25, 1920 - 195, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
# 游玩场数
|
||||||
|
matches = data["matchesPlayed"]
|
||||||
|
# mvp
|
||||||
|
mvp = "MVP:" + str(data["mvp"])
|
||||||
|
# 最佳小队
|
||||||
|
best_squad = "最佳小队:" + str(data["bestSquad"])
|
||||||
|
best_show = random.choice((mvp, best_squad))
|
||||||
|
ch_text_font2 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 36)
|
||||||
|
draw.text((1368, 50), f'游玩场数: {matches}', fill='white', font=ch_text_font2)
|
||||||
|
draw.text((1368, 111), f'{best_show}', fill='white', font=ch_text_font2)
|
||||||
|
# 10.绘制生涯框
|
||||||
|
new_img = draw_rect(new_img, (25, 205, 1920 - 25, 455), 10, fill=(0, 0, 0, 150))
|
||||||
|
ch_text_font3 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 32)
|
||||||
|
en_text_font3 = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 36)
|
||||||
|
# 分割的击杀数据
|
||||||
|
divided_kills = data["dividedKills"]
|
||||||
|
# 处理击杀玩家的百分比
|
||||||
|
kill_human_per = data["humanPrecentage"]
|
||||||
|
kill_human_per = float(kill_human_per.strip('%')) / 100
|
||||||
|
# kd
|
||||||
|
kd = data["killDeath"]
|
||||||
|
# 四舍五入计算真实KD
|
||||||
|
real_kd = round(kill_human_per * kd, 2)
|
||||||
|
# 击杀数
|
||||||
|
kills = data["kills"]
|
||||||
|
# kpm
|
||||||
|
kpm = data["killsPerMinute"]
|
||||||
|
# 真实kpm
|
||||||
|
real_kpm = round(kill_human_per * kpm, 2)
|
||||||
|
# 步战kd
|
||||||
|
infantryKillDeath = data["infantryKillDeath"]
|
||||||
|
# 场均击杀
|
||||||
|
k_per_match = data["killsPerMatch"]
|
||||||
|
# 爆头率
|
||||||
|
hs = data["headshots"]
|
||||||
|
# 命中率
|
||||||
|
acc = data["accuracy"]
|
||||||
|
# 胜场
|
||||||
|
win = data["winPercent"]
|
||||||
|
# 人类百分比
|
||||||
|
human_per = data["humanPrecentage"]
|
||||||
|
# AI击杀数量
|
||||||
|
AI_kill = divided_kills["ai"]
|
||||||
|
# 阵亡
|
||||||
|
deaths = data["deaths"]
|
||||||
|
# 急救
|
||||||
|
revives = data["revives"]
|
||||||
|
# 标记敌人数
|
||||||
|
eme = data["enemiesSpotted"]
|
||||||
|
# 摧毁载具数量
|
||||||
|
vehiclesDestroyed = data["vehiclesDestroyed"]
|
||||||
|
# 载具击杀数
|
||||||
|
vehicle_kill = divided_kills["vehicle"]
|
||||||
|
# 数据1
|
||||||
|
draw.text((150, 220), f'K/D: {kd}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((150, 265), f'步战 K/D: {infantryKillDeath}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((150, 310), f'击杀: {kills}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((150, 355), f'载具击杀: {vehicle_kill}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((150, 400), f'死亡数: {deaths}', fill='white', font=ch_text_font3)
|
||||||
|
|
||||||
|
# 数据2
|
||||||
|
draw.text((550, 220), f'KPM: {kpm}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((550, 265), f'真实KPM: {real_kpm}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((550, 310), f'爆头率: {hs}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((550, 355), f'命中率: {acc}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((550, 400), f'胜率: {win}', fill='white', font=ch_text_font3)
|
||||||
|
|
||||||
|
# 数据3
|
||||||
|
draw.text((950, 220), f'AI击杀: {AI_kill}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((950, 265), f'场均击杀: {k_per_match}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((950, 310), f'急救数: {revives}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((950, 355), f'标记敌人数: {eme}', fill='white', font=ch_text_font3)
|
||||||
|
draw.text((950, 400), f'摧毁载具数: {vehiclesDestroyed}', fill='white', font=ch_text_font3)
|
||||||
|
|
||||||
|
# 数据4 BF TRACKER个人主页
|
||||||
|
# en_text_font_ext = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 24)
|
||||||
|
# qr_img = qr_code_gen(player_name, platform)
|
||||||
|
# qr_img = qr_img.resize((145, 145))
|
||||||
|
# draw.text((1300, 228), "BATTLEFIELD\n TRACKER", fill="lightgreen", font=en_text_font_ext)
|
||||||
|
# new_img.paste(qr_img, (1300, 290))
|
||||||
|
|
||||||
|
weapon_list = sorted(data["weapons"], key=lambda k: k['kills'], reverse=True)
|
||||||
|
|
||||||
|
# 数据5 简易检测器
|
||||||
|
hacker_check_res = hacker_check(weapon_list)
|
||||||
|
final = "未知"
|
||||||
|
color = "white"
|
||||||
|
check_res = False
|
||||||
|
|
||||||
|
if 3 in hacker_check_res:
|
||||||
|
final = "鉴定为红橙黄绿蓝紫\n没有青吗?"
|
||||||
|
color = "#FF9999"
|
||||||
|
check_res = True
|
||||||
|
elif 2 in hacker_check_res:
|
||||||
|
final = "挂?\n样本太少了"
|
||||||
|
color = "yellow"
|
||||||
|
check_res = True
|
||||||
|
elif 1 in hacker_check_res:
|
||||||
|
final = "数据不对?\n样本太少了"
|
||||||
|
color = "yellow"
|
||||||
|
check_res = True
|
||||||
|
elif 0 in hacker_check_res:
|
||||||
|
final = "可疑?\n建议详查"
|
||||||
|
color = "yellow"
|
||||||
|
check_res = True
|
||||||
|
if not check_res:
|
||||||
|
# kpm大于1 总kd大于2 真实kd大于1.5
|
||||||
|
if kpm > 1.00 and kd > 2 and real_kd > 1.5:
|
||||||
|
final = "Pro哥\n你带我走吧T_T"
|
||||||
|
color = "gold"
|
||||||
|
else:
|
||||||
|
final = "薯薯\n别拷打我了哥>_<"
|
||||||
|
color = "skyblue"
|
||||||
|
|
||||||
|
ch_text_font_ext = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 32)
|
||||||
|
ch_text_font_ext2 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 28)
|
||||||
|
draw.text((1300, 220), f'机器棱鉴定结果(仅供参考):', fill="white", font=ch_text_font_ext)
|
||||||
|
draw.text((1300, 240), f'\n{final}', fill=f"{color}", font=ch_text_font_ext2)
|
||||||
|
|
||||||
|
# 添加BF ban 检测结果
|
||||||
|
bf_ban_res = await get_bf_ban_check(data["userName"], data["userId"], data["id"])
|
||||||
|
draw.text((1300, 360), f'联BAN查询:', fill="white", font=ch_text_font_ext)
|
||||||
|
draw.text((1300, 380), f'\n{bf_ban_res}', fill="yellow", font=ch_text_font_ext2)
|
||||||
|
|
||||||
|
# 11.绘制第三部分 TOP4武器/载具 947.5-12.5
|
||||||
|
new_img = draw_rect(new_img, (25, 480, 1920 - 25, 1080 - 25), 10, fill=(0, 0, 0, 150))
|
||||||
|
ch_text_font4 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 32)
|
||||||
|
en_text_font4 = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 32)
|
||||||
|
# 武器部分
|
||||||
|
top_weapon_list = sorted(data["weapons"], key=lambda k: k['kills'], reverse=True)
|
||||||
|
height = 500
|
||||||
|
line_height = 845
|
||||||
|
for i in range(0, 5):
|
||||||
|
# 1
|
||||||
|
# 修饰线条
|
||||||
|
if i < 3:
|
||||||
|
draw.line([45, height + 5, 45, height + 85], fill="#CCFF00", width=5, joint=None)
|
||||||
|
else:
|
||||||
|
draw.line([45, line_height, 45, line_height+80], fill="#66CCFF", width=5, joint=None)
|
||||||
|
line_height += 110
|
||||||
|
new_img = image_paste(get_top_object_img(top_weapon_list[i]).resize((160, 80)), new_img, (50, height + 5))
|
||||||
|
draw.text((230, height), f'{top_weapon_list[i]["weaponName"]}', fill="white", font=en_text_font4)
|
||||||
|
draw.text((230, height + 45), f'击杀:{top_weapon_list[i]["kills"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((450, height), f'爆头率:{top_weapon_list[i]["headshots"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((450, height + 45), f'命中率:{top_weapon_list[i]["accuracy"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((730, height), f'KPM:{top_weapon_list[i]["killsPerMinute"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((730, height + 45), f'时长:{int(int(top_weapon_list[i]["timeEquipped"]) / 3600 + 0.55)} H',
|
||||||
|
fill="white",
|
||||||
|
font=ch_text_font4)
|
||||||
|
height += 110
|
||||||
|
|
||||||
|
# 分割线
|
||||||
|
draw.line([950, 505, 950, 1030], fill="white", width=5, joint=None)
|
||||||
|
|
||||||
|
# 载具部分
|
||||||
|
top_vehicles_list = sorted(data["vehicles"], key=lambda k: k['kills'], reverse=True)
|
||||||
|
height = 500
|
||||||
|
line_height = 845
|
||||||
|
for n in range(0, 5):
|
||||||
|
# 修饰线条
|
||||||
|
if n < 3:
|
||||||
|
draw.line([975, height + 5, 975, height + 85], fill="#CCFF00", width=5, joint=None)
|
||||||
|
else:
|
||||||
|
draw.line([975, line_height, 975, line_height + 80], fill="#66CCFF", width=5, joint=None)
|
||||||
|
line_height += 110
|
||||||
|
new_img = image_paste(get_top_object_img(top_vehicles_list[n]).resize((320, 80)), new_img, (980, height + 5))
|
||||||
|
draw.text((1325, height), f'{top_vehicles_list[n]["vehicleName"]}', fill="white", font=en_text_font4)
|
||||||
|
draw.text((1325, height+45), f'击杀:{top_vehicles_list[n]["kills"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((1630, height), f'KPM:{top_vehicles_list[n]["killsPerMinute"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((1630, height+45), f'摧毁数:{top_vehicles_list[n]["vehiclesDestroyedWith"]}', fill="white", font=ch_text_font4)
|
||||||
|
height += 110
|
||||||
|
|
||||||
|
# 添加开发团队logo
|
||||||
|
new_img = paste_ic_logo(new_img)
|
||||||
|
# 图片处理完成 发送
|
||||||
|
# sv.logger.info(f"玩家:{player_name}->图片处理完成")
|
||||||
|
# 显示图片
|
||||||
|
# new_img.show()
|
||||||
|
b_io = BytesIO()
|
||||||
|
new_img.save(b_io, format="PNG")
|
||||||
|
base64_str = 'base64://' + base64.b64encode(b_io.getvalue()).decode()
|
||||||
|
return base64_str
|
||||||
|
|
||||||
|
|
||||||
|
async def bf2042_weapon(data, platform):
|
||||||
|
# 1.创建黑色板块 1920*1080
|
||||||
|
new_img = Image.new('RGBA', (1920, 1080), (0, 0, 0, 1000))
|
||||||
|
# 2.获取头像图片 150*150
|
||||||
|
platform_id = 1
|
||||||
|
nucleus_id = data['userId']
|
||||||
|
persona_id = data['id']
|
||||||
|
# 调用接口获取正确的头像
|
||||||
|
avatar = await get_avatar(platform_id, persona_id, nucleus_id)
|
||||||
|
avatar = png_resize(avatar, new_width=145, new_height=145)
|
||||||
|
avatar = circle_corner(avatar, 10)
|
||||||
|
# 3.获取背景 并 模糊
|
||||||
|
# 判断是否为support
|
||||||
|
bg_name = os.listdir(filepath + "/img/bg/common/")
|
||||||
|
index = random.randint(0, len(bg_name) - 1)
|
||||||
|
img = Image.open(filepath + f"/img/bg/common/{bg_name[index]}").convert('RGBA').resize((1920, 1080))
|
||||||
|
# img_filter = img.filter(ImageFilter.GaussianBlur(radius=3))
|
||||||
|
# 4.拼合板块+背景+logo
|
||||||
|
new_img.paste(img, (0, 0))
|
||||||
|
logo = Image.open(filepath + "/img/bf2042_logo/bf2042logo.png").convert('RGBA')
|
||||||
|
logo = png_resize(logo, new_width=145, new_height=145)
|
||||||
|
logo = circle_corner(logo, 10)
|
||||||
|
new_img = image_paste(logo, new_img, (1750, 30))
|
||||||
|
# 5.绘制头像框 (x1,y1,x2,y2)
|
||||||
|
# x2 = x1+width+img_width+width
|
||||||
|
# y2 = y1+width+img_height+width
|
||||||
|
draw = ImageDraw.Draw(new_img)
|
||||||
|
new_img = draw_rect(new_img, (25, 25, 768, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
# 6添加头像
|
||||||
|
new_img = image_paste(avatar, new_img, (30, 30))
|
||||||
|
# 7.添加用户信息文字
|
||||||
|
|
||||||
|
# # 等级计算
|
||||||
|
# xp = data["XP"][0]["total"]
|
||||||
|
# unit = 93944
|
||||||
|
# level = int((xp \\ unit) + 0.55)
|
||||||
|
# color = 'white'
|
||||||
|
# if int((xp \\ 93944) + 0.55) > 0:
|
||||||
|
# level = ('S' + str(level - 99))
|
||||||
|
# color = '#FF3333'
|
||||||
|
|
||||||
|
# 载入字体
|
||||||
|
en_text_font = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 36)
|
||||||
|
ch_text_font = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 36)
|
||||||
|
# 获取用化名
|
||||||
|
player_name = data["userName"]
|
||||||
|
plat = Image.open(filepath + "/img/platform/origin.png").convert("RGBA").resize((40, 40))
|
||||||
|
if platform == "pc":
|
||||||
|
plat = Image.open(filepath + "/img/platform/origin.png").convert("RGBA").resize((40, 40))
|
||||||
|
elif platform == "psn":
|
||||||
|
plat = Image.open(filepath + "/img/platform/playstation.png").convert("RGBA").resize((40, 40))
|
||||||
|
elif platform == "xbl":
|
||||||
|
plat = Image.open(filepath + "/img/platform/xbox.png").convert("RGBA").resize((40, 40))
|
||||||
|
draw.text((208, 33), '玩家:', fill='white', font=ch_text_font)
|
||||||
|
draw.text((308, 30), f'{player_name}', fill='white', font=en_text_font)
|
||||||
|
# 游玩平台
|
||||||
|
# draw.rectangle([208, 120, 248, 160], fill="black")
|
||||||
|
# r, g, b, alpha = plat.split()
|
||||||
|
# new_img.paste(plat, (208, 120), mask=alpha)
|
||||||
|
new_img = image_paste(plat, new_img, (208, 120))
|
||||||
|
draw.text((260, 120), '游玩时长:', fill='white', font=ch_text_font)
|
||||||
|
time_played = data["timePlayed"]
|
||||||
|
if ',' in time_played:
|
||||||
|
times = time_played.split(',')
|
||||||
|
if "days" in times[0]:
|
||||||
|
times_1 = int(times[0].replace("days", "").strip()) * 24
|
||||||
|
else:
|
||||||
|
times_1 = int(times[0].replace("day", "").strip()) * 24
|
||||||
|
times_2 = times[1].split(':')
|
||||||
|
time_part2 = int(times_2[0]) + Decimal(int(times_2[1]) / 60).quantize(Decimal("0.00"))
|
||||||
|
time_played = str(times_1 + time_part2)
|
||||||
|
else:
|
||||||
|
time_part2 = Decimal(int(time_played.split(':')[1]) / 60).quantize(Decimal("0.00"))
|
||||||
|
time_played = int(time_played.split(':')[0]) + time_part2
|
||||||
|
draw.text((430, 118), f'{time_played} H', fill='white', font=en_text_font)
|
||||||
|
# 8.绘制最佳专家外框
|
||||||
|
# 获取兵种图标
|
||||||
|
best_class = sorted(data["classes"], key=lambda k: k['kills'], reverse=True)[0]
|
||||||
|
# 专家名称
|
||||||
|
best_specialist = best_class["characterName"]
|
||||||
|
# 专家击杀数
|
||||||
|
best_specialist_kills = best_class["kills"]
|
||||||
|
# 专家kpm
|
||||||
|
best_specialist_kpm = best_class["kpm"]
|
||||||
|
# 专家kd
|
||||||
|
best_specialist_kill_death = best_class["killDeath"]
|
||||||
|
# 游玩时长
|
||||||
|
seconds = best_class["secondsPlayed"]
|
||||||
|
best_specialist_played = round(seconds / 3600, 2)
|
||||||
|
# 专家图标
|
||||||
|
class_icon = await get_special_icon(best_class)
|
||||||
|
# 图像缩放
|
||||||
|
class_icon = class_icon.resize((90, 90))
|
||||||
|
# class_icon = png_resize(class_icon, new_width=90, new_height=90)
|
||||||
|
# (300, 360)
|
||||||
|
# 绘制最佳专家
|
||||||
|
ch_text_font_bc = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 38)
|
||||||
|
ch_text_font_s = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 30)
|
||||||
|
new_img = draw_rect(new_img, (768 + 25, 25, 1318, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
draw.text((815, 55), '最 佳', fill='lightgreen', font=ch_text_font_bc)
|
||||||
|
draw.text((815, 105), '专 家', fill='lightgreen', font=ch_text_font_bc)
|
||||||
|
new_img = image_paste(class_icon, new_img, (930, 35))
|
||||||
|
spec_name = classesList[best_specialist]
|
||||||
|
draw.text((918, 130), f'{spec_name}', fill='skyblue', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 40), f'KD:{best_specialist_kill_death}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 70), f'KPM:{best_specialist_kpm}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 100), f'击杀数:{best_specialist_kills}', fill='white', font=ch_text_font_s)
|
||||||
|
draw.text((1050, 130), f'时长:{best_specialist_played}', fill='white', font=ch_text_font_s)
|
||||||
|
|
||||||
|
# 9.MVP/最佳小队
|
||||||
|
# 绘制最佳小队/MVP
|
||||||
|
new_img = draw_rect(new_img, (1318 + 25, 25, 1920 - 195, 180), 10, fill=(0, 0, 0, 150))
|
||||||
|
# 游玩场数
|
||||||
|
matches = data["matchesPlayed"]
|
||||||
|
# mvp
|
||||||
|
mvp = "MVP:" + str(data["mvp"])
|
||||||
|
# 最佳小队
|
||||||
|
best_squad = "最佳小队:" + str(data["bestSquad"])
|
||||||
|
best_show = random.choice((mvp, best_squad))
|
||||||
|
ch_text_font2 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 36)
|
||||||
|
draw.text((1368, 50), f'游玩场数: {matches}', fill='white', font=ch_text_font2)
|
||||||
|
draw.text((1368, 111), f'{best_show}', fill='white', font=ch_text_font2)
|
||||||
|
|
||||||
|
# 10.绘制武器框
|
||||||
|
new_img = draw_rect(new_img, (25, 205, 1920 - 25, 1080 - 25), 10, fill=(0, 0, 0, 150))
|
||||||
|
|
||||||
|
# 武器击杀数排序
|
||||||
|
top_weapon_list = sorted(data["weapons"], key=lambda k: k['kills'], reverse=True)
|
||||||
|
|
||||||
|
# 载入字体
|
||||||
|
ch_text_font4 = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 32)
|
||||||
|
en_text_font4 = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 32)
|
||||||
|
|
||||||
|
# 遍历 左
|
||||||
|
height = 220
|
||||||
|
index = 0
|
||||||
|
for i in range(0, 8):
|
||||||
|
new_img = image_paste(get_top_object_img(top_weapon_list[i]).resize((160, 80)), new_img, (50, height + 5))
|
||||||
|
draw.text((230, height), f'{top_weapon_list[i]["weaponName"]}', fill="white", font=en_text_font4)
|
||||||
|
draw.text((230, height + 45), f'击杀:{top_weapon_list[i]["kills"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((450, height), f'爆头率:{top_weapon_list[i]["headshots"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((450, height + 45), f'命中率:{top_weapon_list[i]["accuracy"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((730, height), f'KPM:{top_weapon_list[0]["killsPerMinute"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((730, height + 45), f'时长:{int(int(top_weapon_list[0]["timeEquipped"]) / 3600 + 0.55)} H',
|
||||||
|
fill="white",
|
||||||
|
font=ch_text_font4)
|
||||||
|
if i != 7:
|
||||||
|
new_img = await draw_point_line(new_img, start_point=(50, height + 90), end_point=(1820, height + 90),
|
||||||
|
line_color='green')
|
||||||
|
height += 105
|
||||||
|
index = i
|
||||||
|
|
||||||
|
# 分割线
|
||||||
|
draw.line([950, 225, 950, 1030], fill="white", width=5, joint=None)
|
||||||
|
# 遍历 右
|
||||||
|
height = 220
|
||||||
|
for i in range(index, index + 8):
|
||||||
|
new_img = image_paste(get_top_object_img(top_weapon_list[i]).resize((160, 80)), new_img, (975, height + 5))
|
||||||
|
draw.text((1160, height), f'{top_weapon_list[i]["weaponName"]}', fill="white", font=en_text_font4)
|
||||||
|
draw.text((1160, height + 45), f'击杀:{top_weapon_list[i]["kills"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((1380, height), f'爆头率:{top_weapon_list[i]["headshots"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((1380, height + 45), f'命中率:{top_weapon_list[i]["accuracy"]}', fill="white", font=ch_text_font4)
|
||||||
|
|
||||||
|
draw.text((1660, height), f'KPM:{top_weapon_list[0]["killsPerMinute"]}', fill="white", font=ch_text_font4)
|
||||||
|
draw.text((1660, height + 45), f'时长:{int(int(top_weapon_list[0]["timeEquipped"]) / 3600 + 0.55)} H',
|
||||||
|
fill="white",
|
||||||
|
font=ch_text_font4)
|
||||||
|
height += 105
|
||||||
|
# 添加开发团队logo
|
||||||
|
new_img = paste_ic_logo(new_img)
|
||||||
|
b_io = BytesIO()
|
||||||
|
new_img.save(b_io, format="PNG")
|
||||||
|
base64_str = 'base64://' + base64.b64encode(b_io.getvalue()).decode()
|
||||||
|
return base64_str
|
56
hexi/plugins/battlefield2042status/data.py
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
import asyncio
|
||||||
|
import json
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
from aiohttp_retry import RetryClient, ExponentialRetry
|
||||||
|
|
||||||
|
from .bf2042 import bf_2042_gen_pic, bf2042_weapon
|
||||||
|
|
||||||
|
|
||||||
|
async def query_data(player, platform, query_type):
|
||||||
|
url = f"https://api.gametools.network/bf2042/stats/?raw=false&format_values=true&name={player}&platform={platform}"
|
||||||
|
headers = {
|
||||||
|
'accept': 'application/json'
|
||||||
|
}
|
||||||
|
mes = (False, "没有获取到数据呢")
|
||||||
|
retry_options = ExponentialRetry(attempts=2, exceptions=(aiohttp.ClientError,))
|
||||||
|
async with RetryClient(retry_options=retry_options) as session:
|
||||||
|
try:
|
||||||
|
async with session.get(url, headers=headers, timeout=15) as response:
|
||||||
|
rest = await response.text()
|
||||||
|
rest = str_filter(rest)
|
||||||
|
if response.status == 200:
|
||||||
|
result = json.loads(rest)
|
||||||
|
if query_type == 0:
|
||||||
|
img = await bf_2042_gen_pic(result, platform)
|
||||||
|
mes = (True, img)
|
||||||
|
elif query_type == 1:
|
||||||
|
img = await bf2042_weapon(result, platform)
|
||||||
|
mes = (True, img)
|
||||||
|
else:
|
||||||
|
mes = (False, "请求错误")
|
||||||
|
except asyncio.TimeoutError as e:
|
||||||
|
if e:
|
||||||
|
mes = (False, f"请求超时:{e}")
|
||||||
|
mes = (False, f"请求超时:玩家数据请求超时")
|
||||||
|
except aiohttp.ClientError as e:
|
||||||
|
if e:
|
||||||
|
mes = (False, f"请求异常:{e}")
|
||||||
|
mes = (False, f"请求异常:玩家数据请求异常")
|
||||||
|
return mes
|
||||||
|
|
||||||
|
|
||||||
|
obj_filter = {
|
||||||
|
"AH-64GX Apache Warchief": "Apache Warchief",
|
||||||
|
"GOL Sniper Magnum": "GOL Magnum",
|
||||||
|
"AH-6J Little Bird": "Little Bird",
|
||||||
|
"Sd. Kfz 251 Halftrack": "251 Halftrack",
|
||||||
|
"9K22 Tunguska-M": "Tunguska-M"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def str_filter(obj_str):
|
||||||
|
# 遍历字典,替换字符串中的键为对应的值
|
||||||
|
for key in obj_filter:
|
||||||
|
obj_str = obj_str.replace(key, obj_filter[key])
|
||||||
|
return obj_str
|
BIN
hexi/plugins/battlefield2042status/data/user.db
Normal file
107
hexi/plugins/battlefield2042status/data_tools.py
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
|
filepath = os.path.dirname(__file__).replace("\\", "/")
|
||||||
|
bf_ban_url = "https://api.gametools.network/bfban/checkban"
|
||||||
|
|
||||||
|
ban_reason = {
|
||||||
|
0: "未处理",
|
||||||
|
1: "石锤",
|
||||||
|
2: "待自证",
|
||||||
|
3: "MOSS自证",
|
||||||
|
4: "无效举报",
|
||||||
|
5: "讨论中",
|
||||||
|
6: "需要更多管理投票",
|
||||||
|
7: "未知原因封禁",
|
||||||
|
8: "刷枪"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def hacker_check(weapon_data):
|
||||||
|
"""
|
||||||
|
简易外挂数据检测
|
||||||
|
:param weapon_data: 武器数据
|
||||||
|
:return: 返回检测的数据标记,
|
||||||
|
击杀数大于100小于切爆头率大于30小于40标记1,
|
||||||
|
击杀数大于100切爆头率大于40标记2(基本实锤)
|
||||||
|
"""
|
||||||
|
ignore_type = ["DMR", "Bolt Action", "Railguns", "Lever-Action Carbines", "Sidearm", "Crossbows", "Shotguns"]
|
||||||
|
sign = []
|
||||||
|
for weapon in weapon_data:
|
||||||
|
if weapon["type"] not in ignore_type:
|
||||||
|
sign.append(headshot(weapon))
|
||||||
|
continue
|
||||||
|
return sign
|
||||||
|
|
||||||
|
|
||||||
|
def headshot(weapon):
|
||||||
|
sign = 999
|
||||||
|
if 30.00 <= float(weapon["headshots"].replace('%', "")) and float(weapon["kills"]) >= 100:
|
||||||
|
if float(weapon["headshots"].replace('%', "")) <= 40.00:
|
||||||
|
if float(weapon["kills"]) < 200:
|
||||||
|
sign = 1
|
||||||
|
else:
|
||||||
|
sign = 0
|
||||||
|
elif float(weapon["headshots"].replace('%', "")) > 40.00:
|
||||||
|
if float(weapon["kills"]) < 200:
|
||||||
|
sign = 2
|
||||||
|
else:
|
||||||
|
sign = 3
|
||||||
|
return sign
|
||||||
|
|
||||||
|
|
||||||
|
async def get_bf_ban_check(user_name, userids, personaids):
|
||||||
|
url = "https://api.gametools.network/bfban/checkban/"
|
||||||
|
params = {
|
||||||
|
"names": user_name,
|
||||||
|
"userids": userids,
|
||||||
|
"personaids": personaids
|
||||||
|
}
|
||||||
|
headers = {'accept': 'application/json'}
|
||||||
|
trans = "未查询到相关信息"
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(url, headers=headers, params=params) as response:
|
||||||
|
if response.status == 200:
|
||||||
|
res = await response.json()
|
||||||
|
hacker_name = res["names"][user_name.lower()]["hacker"]
|
||||||
|
hacker_userids = res["userids"][f"{userids}"]["hacker"]
|
||||||
|
hacker_personaids = res["personaids"][f"{personaids}"]["hacker"]
|
||||||
|
if hacker_name:
|
||||||
|
ban_result = res["names"][user_name.lower()]["status"]
|
||||||
|
trans = ban_reason[ban_result]
|
||||||
|
elif hacker_userids:
|
||||||
|
ban_result = res["userids"][f"{userids}"]["status"]
|
||||||
|
trans = ban_reason[ban_result]
|
||||||
|
elif hacker_personaids:
|
||||||
|
ban_result = res["personaids"][f"{personaids}"]["status"]
|
||||||
|
trans = ban_reason[ban_result]
|
||||||
|
else:
|
||||||
|
if "status" in str(res):
|
||||||
|
res_data = search_field_in_json(res, "status")
|
||||||
|
trans = ban_reason[res_data]
|
||||||
|
return trans
|
||||||
|
|
||||||
|
|
||||||
|
def search_field_in_json(obj, field_name):
|
||||||
|
"""
|
||||||
|
递归搜索 JSON 对象中的指定字段名
|
||||||
|
:param obj: JSON 对象
|
||||||
|
:param field_name: 指定的字段名
|
||||||
|
:return: 找到的字段值,未找到时返回 None
|
||||||
|
"""
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
for key, value in obj.items():
|
||||||
|
if key == field_name:
|
||||||
|
return value
|
||||||
|
else:
|
||||||
|
result = search_field_in_json(value, field_name)
|
||||||
|
if result is not None:
|
||||||
|
return result
|
||||||
|
elif isinstance(obj, list):
|
||||||
|
for item in obj:
|
||||||
|
result = search_field_in_json(item, field_name)
|
||||||
|
if result is not None:
|
||||||
|
return result
|
||||||
|
else:
|
||||||
|
return None
|
BIN
hexi/plugins/battlefield2042status/font/BF_Modernista-Bold.ttf
Normal file
BIN
hexi/plugins/battlefield2042status/font/NotoSansSCMedium-4.ttf
Normal file
After Width: | Height: | Size: 9.0 KiB |
After Width: | Height: | Size: 868 KiB |
After Width: | Height: | Size: 1.1 MiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 43 KiB |
BIN
hexi/plugins/battlefield2042status/img/class_icon/No-Pats.png
Normal file
After Width: | Height: | Size: 39 KiB |
BIN
hexi/plugins/battlefield2042status/img/class_icon/Recon_Icon.png
Normal file
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 16 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 12 KiB |
BIN
hexi/plugins/battlefield2042status/img/dev_logo/IC.png
Normal file
After Width: | Height: | Size: 228 B |
BIN
hexi/plugins/battlefield2042status/img/object_icon/12M Auto.png
Normal file
After Width: | Height: | Size: 31 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/AC-42.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/AC9.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/AK-24.png
Normal file
After Width: | Height: | Size: 28 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/AM40.png
Normal file
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 49 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/Avancys.png
Normal file
After Width: | Height: | Size: 52 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/BSV-M.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/EBLC-Ram.png
Normal file
After Width: | Height: | Size: 88 KiB |
After Width: | Height: | Size: 24 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/Falck.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/GEW-46.png
Normal file
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 48 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/LCMG.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/M1A5.png
Normal file
After Width: | Height: | Size: 38 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/M5A3.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/M5C Bolte.png
Normal file
After Width: | Height: | Size: 34 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/MAV.png
Normal file
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 40 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/PBX-45.png
Normal file
After Width: | Height: | Size: 22 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/PP-2000.png
Normal file
After Width: | Height: | Size: 14 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/PP-29.png
Normal file
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 35 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/RM68.png
Normal file
After Width: | Height: | Size: 27 KiB |
After Width: | Height: | Size: 55 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/SFAR-M GL.png
Normal file
After Width: | Height: | Size: 27 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/SWS-10.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/Sundance.png
Normal file
After Width: | Height: | Size: 9.2 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/T28.png
Normal file
After Width: | Height: | Size: 30 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/VHX D3.png
Normal file
After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 34 KiB |
BIN
hexi/plugins/battlefield2042status/img/object_icon/default.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
hexi/plugins/battlefield2042status/img/platform/origin.png
Normal file
After Width: | Height: | Size: 6.9 KiB |
BIN
hexi/plugins/battlefield2042status/img/platform/playstation.png
Normal file
After Width: | Height: | Size: 6.6 KiB |
BIN
hexi/plugins/battlefield2042status/img/platform/xbox.png
Normal file
After Width: | Height: | Size: 7.8 KiB |
BIN
hexi/plugins/battlefield2042status/img/specialist_icon/Falck.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
After Width: | Height: | Size: 4.2 KiB |
374
hexi/plugins/battlefield2042status/picture_tools.py
Normal file
@ -0,0 +1,374 @@
|
|||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import logging as sv
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import time
|
||||||
|
from io import BytesIO
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
import cairosvg
|
||||||
|
import qrcode
|
||||||
|
import requests
|
||||||
|
import requests.exceptions
|
||||||
|
from PIL import Image, ImageDraw, ImageFont
|
||||||
|
|
||||||
|
filepath = os.path.dirname(__file__).replace("\\", "/")
|
||||||
|
# 记录URL
|
||||||
|
bf_ban_url = "https://api.gametools.network/bfban/checkban"
|
||||||
|
|
||||||
|
|
||||||
|
# 圆角遮罩处理
|
||||||
|
def draw_rect(img, pos, radius, **kwargs):
|
||||||
|
transp = Image.new('RGBA', img.size, (0, 0, 0, 0))
|
||||||
|
alpha_draw = ImageDraw.Draw(transp, "RGBA")
|
||||||
|
alpha_draw.rounded_rectangle(pos, radius, **kwargs)
|
||||||
|
img.paste(Image.alpha_composite(img, transp))
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 圆角处理
|
||||||
|
def circle_corner(img, radii):
|
||||||
|
"""
|
||||||
|
半透明圆角处理
|
||||||
|
:param img: 要修改的文件
|
||||||
|
:param radii: 圆角弧度
|
||||||
|
:return: 返回修改过的文件
|
||||||
|
"""
|
||||||
|
circle = Image.new('L', (radii * 2, radii * 2), 0) # 创建黑色方形
|
||||||
|
draw = ImageDraw.Draw(circle)
|
||||||
|
draw.ellipse((0, 0, radii * 2, radii * 2), fill=255) # 黑色方形内切白色圆形
|
||||||
|
|
||||||
|
img = img.convert("RGBA")
|
||||||
|
w, h = img.size
|
||||||
|
|
||||||
|
# 创建一个alpha层,存放四个圆角,使用透明度切除圆角外的图片
|
||||||
|
alpha = Image.new('L', img.size, 255)
|
||||||
|
alpha.paste(circle.crop((0, 0, radii, radii)), (0, 0)) # 左上角
|
||||||
|
alpha.paste(circle.crop((radii, 0, radii * 2, radii)),
|
||||||
|
(w - radii, 0)) # 右上角
|
||||||
|
alpha.paste(circle.crop((radii, radii, radii * 2, radii * 2)),
|
||||||
|
(w - radii, h - radii)) # 右下角
|
||||||
|
alpha.paste(circle.crop((0, radii, radii, radii * 2)),
|
||||||
|
(0, h - radii)) # 左下角
|
||||||
|
img.putalpha(alpha) # 白色区域透明可见,黑色区域不可见
|
||||||
|
|
||||||
|
# 添加圆角边框
|
||||||
|
draw = ImageDraw.Draw(img)
|
||||||
|
draw.rounded_rectangle(img.getbbox(), outline="white", width=3, radius=radii)
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 获取专家类型图片
|
||||||
|
def get_class_type(class_type):
|
||||||
|
"""
|
||||||
|
获取专家类型
|
||||||
|
:param class_type: 专家类型
|
||||||
|
:return: 返回对应的图标路径
|
||||||
|
"""
|
||||||
|
icon_path = filepath + "/img/class_icon/No-Pats.png"
|
||||||
|
if class_type == 'Assault':
|
||||||
|
icon_path = filepath + "/img/class_icon/ui/Assault_Icon_small.png"
|
||||||
|
elif class_type == 'Support':
|
||||||
|
icon_path = filepath + "/img/class_icon/ui/Support_Icon_small.png"
|
||||||
|
elif class_type == 'Recon':
|
||||||
|
icon_path = filepath + "/img/class_icon/ui/Recon_Icon_small.png"
|
||||||
|
elif class_type == 'Engineer':
|
||||||
|
icon_path = filepath + "/img/class_icon/ui/Engineer_Icon_small.png"
|
||||||
|
return icon_path
|
||||||
|
|
||||||
|
|
||||||
|
# PNG重绘大小
|
||||||
|
def png_resize(source_file, new_width=0, new_height=0, resample="LANCZOS", ref_file=''):
|
||||||
|
"""
|
||||||
|
PNG缩放透明度处理
|
||||||
|
:param source_file: 源文件(Image.open())
|
||||||
|
:param new_width: 设置的宽度
|
||||||
|
:param new_height: 设置的高度
|
||||||
|
:param resample: 抗锯齿
|
||||||
|
:param ref_file: 参考文件
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
img = source_file
|
||||||
|
img = img.convert("RGBA")
|
||||||
|
width, height = img.size
|
||||||
|
|
||||||
|
if ref_file != '':
|
||||||
|
imgRef = Image.open(ref_file)
|
||||||
|
new_width, new_height = imgRef.size
|
||||||
|
else:
|
||||||
|
if new_height == 0:
|
||||||
|
new_height = new_width * width / height
|
||||||
|
|
||||||
|
bands = img.split()
|
||||||
|
resample_map = {
|
||||||
|
"NEAREST": Image.NEAREST,
|
||||||
|
"BILINEAR": Image.BILINEAR,
|
||||||
|
"BICUBIC": Image.BICUBIC,
|
||||||
|
"LANCZOS": Image.LANCZOS
|
||||||
|
}
|
||||||
|
resample_method = resample_map.get(resample, Image.LANCZOS) # 默认使用 LANCZOS
|
||||||
|
|
||||||
|
bands = [b.resize((new_width, new_height), resample=resample_method) for b in bands]
|
||||||
|
resized_file = Image.merge('RGBA', bands)
|
||||||
|
|
||||||
|
return resized_file
|
||||||
|
|
||||||
|
|
||||||
|
# 获取物品图片
|
||||||
|
def get_top_object_img(object_data):
|
||||||
|
"""
|
||||||
|
获取对应物品图标
|
||||||
|
:param object_data: 物品数据
|
||||||
|
:return: 图标
|
||||||
|
"""
|
||||||
|
img_url = object_data["image"]
|
||||||
|
img = Image.open(filepath + "/img/object_icon/default.png").convert('RGBA')
|
||||||
|
# object_name = "default"
|
||||||
|
path = filepath + "/img/object_icon/"
|
||||||
|
try:
|
||||||
|
obj_name = os.listdir(path)
|
||||||
|
if "weaponName" in object_data:
|
||||||
|
object_name = object_data["weaponName"]
|
||||||
|
if object_name in str(obj_name):
|
||||||
|
sv.info(f"本地已存在{object_name}物品图标")
|
||||||
|
img = Image.open(f"{path}{object_name}.png").convert('RGBA')
|
||||||
|
else:
|
||||||
|
sv.info(f"未检测到{object_name}物品图标,缓存至本地")
|
||||||
|
img = Image.open(BytesIO(requests.get(img_url).content)).convert('RGBA')
|
||||||
|
img.save(filepath + f"/img/object_icon/{object_name}.png")
|
||||||
|
elif "vehicleName" in object_data:
|
||||||
|
object_name = object_data["vehicleName"]
|
||||||
|
if object_name in str(obj_name):
|
||||||
|
sv.info(f"本地已存在{object_name}物品图标")
|
||||||
|
img = Image.open(f"{path}{object_name}.png").convert('RGBA')
|
||||||
|
else:
|
||||||
|
sv.info(f"未检测到{object_name}物品图标,缓存至本地")
|
||||||
|
img = Image.open(BytesIO(requests.get(img_url).content)).convert('RGBA')
|
||||||
|
img.save(filepath + f"/img/object_icon/{object_name}.png")
|
||||||
|
except Exception as err:
|
||||||
|
print(err)
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 二维码生成
|
||||||
|
def qr_code_gen(player, platform):
|
||||||
|
"""
|
||||||
|
version :QR code 的版次,可以设置 1 ~ 40 的版次。
|
||||||
|
error_correction :容错率,可选 7%、15%、25%、30%,参数如下 :
|
||||||
|
qrcode.constants.ERROR_CORRECT_L :7%
|
||||||
|
qrcode.constants.ERROR_CORRECT_M :15%(预设)
|
||||||
|
qrcode.constants.ERROR_CORRECT_Q :25%
|
||||||
|
qrcode.constants.ERROR_CORRECT_H :30%
|
||||||
|
box_size :每个模块的像素个数。
|
||||||
|
border :边框区的厚度,预设是 4。
|
||||||
|
image_factory :图片格式,默认是 PIL。
|
||||||
|
mask_pattern :mask_pattern 参数是 0 ~ 7,如果省略会自行使用最适当的方法。
|
||||||
|
"""
|
||||||
|
if "pc" == platform:
|
||||||
|
platform = "origin"
|
||||||
|
bf_tracker_link = f"https://battlefieldtracker.com/bf2042/profile/{platform}/{player}/overview"
|
||||||
|
qr = qrcode.QRCode(version=1,
|
||||||
|
error_correction=qrcode.constants.ERROR_CORRECT_M,
|
||||||
|
box_size=5,
|
||||||
|
border=2)
|
||||||
|
qr.add_data(bf_tracker_link)
|
||||||
|
img = qr.make_image(fill_color='white', back_color="black")
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 图片粘贴
|
||||||
|
def image_paste(paste_image, under_image, pos):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:param paste_image: 需要粘贴的图片
|
||||||
|
:param under_image: 底图
|
||||||
|
:param pos: 位置(x,y)坐标
|
||||||
|
:return: 返回图片
|
||||||
|
"""
|
||||||
|
# 获取需要贴入图片的透明通道
|
||||||
|
r, g, b, alpha = paste_image.split()
|
||||||
|
# 粘贴时将alpha值传递至mask属性
|
||||||
|
under_image.paste(paste_image, pos, alpha)
|
||||||
|
return under_image
|
||||||
|
|
||||||
|
|
||||||
|
# 获取专属图库
|
||||||
|
def get_favorite_image(uid):
|
||||||
|
bg_path = filepath + f"/img/bg/user/{uid}/"
|
||||||
|
if os.listdir(bg_path):
|
||||||
|
bg_name = os.listdir(bg_path)
|
||||||
|
index = random.randint(0, len(bg_name) - 1)
|
||||||
|
img = Image.open(bg_path + f"{bg_name[index]}").convert('RGBA').resize((1920, 1080))
|
||||||
|
else:
|
||||||
|
common_bg_name = os.listdir(filepath + "/img/bg/common/")
|
||||||
|
index = random.randint(0, len(common_bg_name) - 1)
|
||||||
|
img = Image.open(filepath + f"/img/bg/common/{common_bg_name[index]}").convert('RGBA').resize((1920, 1080))
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 获取bot管理员专属图库
|
||||||
|
def get_user_avatar(user):
|
||||||
|
avatar = download_avatar(user)
|
||||||
|
avatar = Image.open(BytesIO(avatar)).convert('RGBA').resize((1920, 1080))
|
||||||
|
return avatar
|
||||||
|
|
||||||
|
|
||||||
|
# 下载QQ头像
|
||||||
|
def download_avatar(user_id: str) -> bytes:
|
||||||
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=640"
|
||||||
|
data = download_url(url)
|
||||||
|
if not data or hashlib.md5(data).hexdigest() == "acef72340ac0e914090bd35799f5594e":
|
||||||
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=100"
|
||||||
|
data = download_url(url)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
# 根据URL下载文件
|
||||||
|
def download_url(url: str) -> bytes:
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
resp = requests.get(url)
|
||||||
|
if resp.status_code != 200:
|
||||||
|
continue
|
||||||
|
return resp.content
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error downloading {url}, retry {i}/3: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
|
# 保存用户的图片
|
||||||
|
async def user_img_save(pic_data: bytes, uid: int):
|
||||||
|
bg_path = filepath + f"/img/bg/user/{uid}/"
|
||||||
|
try:
|
||||||
|
# 裁剪图片
|
||||||
|
pic_data = cut_image(pic_data, 16 / 9)
|
||||||
|
# 保存图片
|
||||||
|
time_now = int(time.time())
|
||||||
|
pic_data = pic_data.convert('RGB')
|
||||||
|
pic_data = pic_data.resize((1920, 1080))
|
||||||
|
pic_data.save(bg_path + str(time_now) + ".jpeg", quality=95)
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("图片保存失败")
|
||||||
|
|
||||||
|
|
||||||
|
# 图片裁剪
|
||||||
|
def cut_image(pic_data: bytes, target_ratio: float):
|
||||||
|
try:
|
||||||
|
pic_data = Image.open(BytesIO(pic_data))
|
||||||
|
w, h = pic_data.size
|
||||||
|
pic_ratio = w / h
|
||||||
|
if pic_ratio > target_ratio:
|
||||||
|
# 宽高比大于目标比例,按高度缩放。保持宽度不变
|
||||||
|
new_h = w / target_ratio
|
||||||
|
h_delta = (h - new_h) / 2
|
||||||
|
w_delta = 0
|
||||||
|
else:
|
||||||
|
# 宽高比小于目标比例,按宽度缩放。保持高度不变
|
||||||
|
new_w = h * target_ratio
|
||||||
|
w_delta = (w - new_w) / 2
|
||||||
|
h_delta = 0
|
||||||
|
cropped = pic_data.crop((w_delta, h_delta, w - w_delta, h - h_delta))
|
||||||
|
return cropped
|
||||||
|
except Exception as e:
|
||||||
|
raise Exception("图片剪裁失败")
|
||||||
|
|
||||||
|
|
||||||
|
# 加logo
|
||||||
|
def paste_ic_logo(img):
|
||||||
|
# 载入logo
|
||||||
|
ic_logo = filepath + "/img/dev_logo/IC.png"
|
||||||
|
# 载入字体
|
||||||
|
en_text_font = ImageFont.truetype(filepath + '/font/BF_Modernista-Bold.ttf', 18)
|
||||||
|
# 载入字体
|
||||||
|
ch_text_font = ImageFont.truetype(filepath + '/font/NotoSansSCMedium-4.ttf', 18)
|
||||||
|
logo_file = Image.open(ic_logo).convert("RGBA").resize((20, 20))
|
||||||
|
draw = ImageDraw.Draw(img)
|
||||||
|
img = draw_rect(img, (25, 1058, 1895, 1078), 1, fill=(0, 0, 0, 150))
|
||||||
|
draw.text((30, 1056), "Data Source From : GAMETOOLS.NETWORK", fill="white", font=en_text_font)
|
||||||
|
draw.text((700, 1056), "BF2042 Player‘s Status Plugin Designed By", fill="white", font=en_text_font)
|
||||||
|
img = image_paste(logo_file, img, (1040, 1058))
|
||||||
|
draw.text((1065, 1056), "SANSENHOSHI", fill="skyblue", font=en_text_font)
|
||||||
|
draw.text((1400, 1058), "友情合作:", fill="white", font=ch_text_font)
|
||||||
|
draw.text((1500, 1058), "铁幕重工:224077009", fill="#99CC00", font=ch_text_font)
|
||||||
|
draw.text((1700, 1058), "贴吧官群:559190861", fill="#99CC00", font=ch_text_font)
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
# 获取EA头像
|
||||||
|
async def get_avatar(platform_id, persona_id, nucleus_id):
|
||||||
|
default_avatar_path = filepath + "/img/class_icon/No-Pats.png"
|
||||||
|
try:
|
||||||
|
url = f"https://api.gametools.network/bf2042/feslid/?platformid={platform_id}&personaid={persona_id}&nucleusid={nucleus_id}"
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get(url, headers={'accept': 'application/json'}) as response:
|
||||||
|
response.raise_for_status()
|
||||||
|
data = json.loads(await response.text())
|
||||||
|
avatar_url = data.get('avatar')
|
||||||
|
sv.info("头像URL处理" + avatar_url)
|
||||||
|
if avatar_url:
|
||||||
|
try:
|
||||||
|
# 添加10s超时判断,如果超时直接使用默认头像
|
||||||
|
res = BytesIO(requests.get(avatar_url, timeout=10).content)
|
||||||
|
avatar = Image.open(res).convert('RGBA')
|
||||||
|
return avatar
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
sv.warning(f"请求异常:{e}")
|
||||||
|
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
sv.warning(f"请求异常:{e}")
|
||||||
|
|
||||||
|
# 使用默认头像
|
||||||
|
avatar = Image.open(default_avatar_path).convert('RGBA')
|
||||||
|
return avatar
|
||||||
|
|
||||||
|
|
||||||
|
async def get_special_icon(special):
|
||||||
|
"""
|
||||||
|
获取专家头像
|
||||||
|
:return: 专家头像
|
||||||
|
"""
|
||||||
|
"""
|
||||||
|
获取对应物品图标
|
||||||
|
:param object_data: 物品数据
|
||||||
|
:return: 图标
|
||||||
|
"""
|
||||||
|
img_url = special["image"]
|
||||||
|
img = Image.open(filepath + "/img/specialist_icon/No-Pats.png").convert('RGBA')
|
||||||
|
# object_name = "default"
|
||||||
|
path = filepath + "/img/specialist_icon/"
|
||||||
|
try:
|
||||||
|
icons_name = os.listdir(path)
|
||||||
|
character_name = special["characterName"]
|
||||||
|
if character_name in str(icons_name):
|
||||||
|
sv.info(f"本地已存在{character_name}专家图标")
|
||||||
|
img = Image.open(f"{path}{character_name}.png").convert('RGBA')
|
||||||
|
else:
|
||||||
|
sv.info(f"未检测到{character_name}专家图标,缓存至本地")
|
||||||
|
out_put = filepath + f"/img/specialist_icon/{character_name}.png"
|
||||||
|
img = await svg_to_png(img_url, out_put)
|
||||||
|
except Exception as err:
|
||||||
|
sv.error(f"获取专家图标失败:{str(err)}")
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
|
async def svg_to_png(svg_file, png_file, width=500, height=500):
|
||||||
|
try:
|
||||||
|
# 使用 cairosvg 将 SVG 转换为 PNG,并指定输出大小
|
||||||
|
cairosvg.svg2png(url=svg_file,
|
||||||
|
write_to=png_file,
|
||||||
|
output_width=width,
|
||||||
|
output_height=height)
|
||||||
|
character_icon = Image.open(png_file)
|
||||||
|
return character_icon
|
||||||
|
except Exception as err:
|
||||||
|
sv.error(f"获取图标失败:{str(err)}")
|
||||||
|
|
||||||
|
|
||||||
|
async def draw_point_line(image, start_point, end_point, line_spacing=5, line_length=10, line_width=2,
|
||||||
|
line_color='white'):
|
||||||
|
# 创建一个绘图对象
|
||||||
|
draw = ImageDraw.Draw(image)
|
||||||
|
# 绘制虚线
|
||||||
|
for x in range(start_point[0], end_point[0], line_length + line_spacing):
|
||||||
|
draw.line([(x, start_point[1]), (x + line_length, start_point[1])], fill=line_color, width=line_width)
|
||||||
|
return image
|
270
hexi/plugins/battlefield2042status/user_manager.py
Normal file
@ -0,0 +1,270 @@
|
|||||||
|
import os
|
||||||
|
import sqlite3
|
||||||
|
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
|
# 路径设置
|
||||||
|
_path = os.path.dirname(__file__).replace("\\", "/")
|
||||||
|
|
||||||
|
DATABASE = _path + '/data/user.db'
|
||||||
|
|
||||||
|
_database = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_db():
|
||||||
|
global _database
|
||||||
|
if _database is None:
|
||||||
|
_database = sqlite3.connect(DATABASE)
|
||||||
|
return _database
|
||||||
|
|
||||||
|
|
||||||
|
def close_db(exception):
|
||||||
|
global _database
|
||||||
|
if _database is not None:
|
||||||
|
_database.close()
|
||||||
|
|
||||||
|
|
||||||
|
# 添加名单表结构
|
||||||
|
async def add_user_bind(bot, ev):
|
||||||
|
uid = ev.user_id
|
||||||
|
if uid == bot.config.SUPERUSERS[0]:
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
sql = """CREATE TABLE user_bind(
|
||||||
|
ID INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
player TEXT NOT NULL,
|
||||||
|
platform TEXT NOT NULL,
|
||||||
|
qq_id TEXT NOT NULL,
|
||||||
|
nucleusId TEXT,
|
||||||
|
personaId TEXT,
|
||||||
|
support INTEGER NOT NULL
|
||||||
|
);"""
|
||||||
|
res = cursor.execute(sql)
|
||||||
|
cursor.close()
|
||||||
|
connect.commit()
|
||||||
|
connect.close()
|
||||||
|
if res.rowcount > 0:
|
||||||
|
await bot.send(ev, "创建成功!")
|
||||||
|
else:
|
||||||
|
await bot.send(ev, "无权限")
|
||||||
|
|
||||||
|
|
||||||
|
# 查询白名单
|
||||||
|
async def query_user_bind(bot, ev, page_number=1, page_size=10):
|
||||||
|
uid = ev.user_id
|
||||||
|
mes = "=====名单=====\n"
|
||||||
|
if uid == bot.config.SUPERUSERS[0]:
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
offset = (page_number - 1) * page_size
|
||||||
|
# 获取总记录数
|
||||||
|
cursor.execute("SELECT COUNT(*) FROM user_bind")
|
||||||
|
total_count = cursor.fetchone()[0]
|
||||||
|
# 执行查询
|
||||||
|
sql = f"SELECT player as 玩家名称, qq_id as QQ, platform as 平台 FROM user_bind LIMIT {page_size} OFFSET {offset}"
|
||||||
|
cursor.execute(sql)
|
||||||
|
users = cursor.fetchall()
|
||||||
|
connect.commit()
|
||||||
|
for user in users:
|
||||||
|
mes += "玩家名称:" + user[0] + "\n" + "QQ:" + user[1] + "\n" + "平台:" + user[2] + "\n\n"
|
||||||
|
# 添加总记录数信息
|
||||||
|
mes += f"\n 当前页为{page_number},总记录数为{total_count}"
|
||||||
|
await bot.send(ev, mes)
|
||||||
|
else:
|
||||||
|
await bot.send(ev, "无权限")
|
||||||
|
|
||||||
|
|
||||||
|
# 绑定用户
|
||||||
|
async def bind_user(uid, player, platform):
|
||||||
|
mes = ''
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
try:
|
||||||
|
info = await get_user_info(player, uid, platform)
|
||||||
|
print(info)
|
||||||
|
except KeyError as e:
|
||||||
|
mes += f"异常:{e}\n"
|
||||||
|
return mes
|
||||||
|
sql = 'INSERT INTO user_bind(player,platform,qq_id,nucleusId,personaId,support) VALUES (?,?,?,?,?,?);'
|
||||||
|
cursor.execute(sql, info)
|
||||||
|
|
||||||
|
connect.commit()
|
||||||
|
if cursor.rowcount > 0:
|
||||||
|
mes += f"绑定成功,用户{uid}当前绑定的游戏id为:{player}"
|
||||||
|
return mes
|
||||||
|
|
||||||
|
|
||||||
|
async def get_user_info(player_name, uid, platform):
|
||||||
|
url = f'https://api.gametools.network/bf2042/stats/' \
|
||||||
|
f'?raw=false&format_values=true&name={player_name}&platform={platform}&skip_battlelog=false'
|
||||||
|
headers = {
|
||||||
|
'accept': 'application/json'
|
||||||
|
}
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
try:
|
||||||
|
async with session.get(url, headers=headers) as response:
|
||||||
|
result = await response.json()
|
||||||
|
except aiohttp.ClientError as e:
|
||||||
|
# 处理网络请求异常
|
||||||
|
print(f"网络请求异常: {e}")
|
||||||
|
return None
|
||||||
|
player_name = player_name.upper()
|
||||||
|
if "userName" in result:
|
||||||
|
if player_name == result['userName'].upper():
|
||||||
|
nucleusId = result["userId"]
|
||||||
|
personaId = result["id"]
|
||||||
|
platform = platform
|
||||||
|
name = result["userName"]
|
||||||
|
info = (name, platform, uid, nucleusId, personaId, 0)
|
||||||
|
return info
|
||||||
|
else:
|
||||||
|
raise ValueError("玩家数据不存在")
|
||||||
|
else:
|
||||||
|
# 抛出自定义异常
|
||||||
|
raise KeyError("玩家数据不存在")
|
||||||
|
|
||||||
|
|
||||||
|
# 添加支援者专属
|
||||||
|
async def add_support_user(bot, ev):
|
||||||
|
# 获取指令发送者的qq
|
||||||
|
su_uid = ev.user_id
|
||||||
|
# 获取当前群号
|
||||||
|
cu_gid = ev.group_id
|
||||||
|
# 判断是否为bot管理员
|
||||||
|
if su_uid == bot.config.SUPERUSERS[0]:
|
||||||
|
# 判断是否为at消息
|
||||||
|
if ev.message[0].type == 'at':
|
||||||
|
white_id = ev.message[0].data['qq']
|
||||||
|
data1 = await bot.get_group_member_info(group_id=cu_gid, user_id=white_id)
|
||||||
|
nickname = data1['card'] if len(data1['card']) != 0 else data1['nickname']
|
||||||
|
if await update_support(white_id, 1):
|
||||||
|
await bot.send(ev, f"添加 {nickname}->成功")
|
||||||
|
else:
|
||||||
|
await bot.finish(ev, '添加失败')
|
||||||
|
else:
|
||||||
|
await bot.send(ev, "无权限")
|
||||||
|
|
||||||
|
|
||||||
|
# 添加支援者专属
|
||||||
|
async def update_support(uid, support):
|
||||||
|
flag = False
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
data = (support, uid)
|
||||||
|
sql = 'UPDATE user_bind SET support =? WHERE qq_id =?'
|
||||||
|
cursor.execute(sql, data)
|
||||||
|
|
||||||
|
connect.commit()
|
||||||
|
save_path_dir = _path + f'/img/bg/user/{uid}'
|
||||||
|
if cursor.rowcount > 0:
|
||||||
|
if not os.path.exists(save_path_dir):
|
||||||
|
os.makedirs(save_path_dir)
|
||||||
|
flag = True
|
||||||
|
else:
|
||||||
|
print("更新失败")
|
||||||
|
return flag
|
||||||
|
|
||||||
|
|
||||||
|
# 移除白名单
|
||||||
|
async def delete_user_bind(bot, ev):
|
||||||
|
# 获取指令发送者的qq
|
||||||
|
su_uid = ev.user_id
|
||||||
|
# 获取当前群号
|
||||||
|
cu_gid = ev.group_id
|
||||||
|
# 判断是否为bot管理员
|
||||||
|
if su_uid == bot.config.SUPERUSERS[0]:
|
||||||
|
# 判断是否为at消息
|
||||||
|
if ev.message[0].type == 'at':
|
||||||
|
white_id = ev.message[0].data['qq']
|
||||||
|
data1 = await bot.get_group_member_info(group_id=cu_gid, user_id=white_id)
|
||||||
|
nickname = data1['card'] if len(data1['card']) != 0 else data1['nickname']
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
sql = "DELETE FROM user_bind WHERE qq_id = ?"
|
||||||
|
result = cursor.execute(sql, (white_id,))
|
||||||
|
|
||||||
|
connect.commit()
|
||||||
|
if cursor.rowcount > 0:
|
||||||
|
await bot.send(ev, f"{nickname}->移除成功")
|
||||||
|
else:
|
||||||
|
await bot.send(ev, "无权限")
|
||||||
|
|
||||||
|
|
||||||
|
async def change_bind(uid, player, platform):
|
||||||
|
flag = False
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
try:
|
||||||
|
info = await get_user_info(player, uid)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"异常:{e}\n")
|
||||||
|
return e
|
||||||
|
name = info[0]
|
||||||
|
nucleusId = info[3]
|
||||||
|
personaId = info[4]
|
||||||
|
data = (name, nucleusId, personaId, platform, uid)
|
||||||
|
sql = 'UPDATE user_bind SET player = ?, nucleusId = ?, personaId = ?,platform = ? WHERE qq_id = ?'
|
||||||
|
cursor.execute(sql, data)
|
||||||
|
|
||||||
|
connect.commit()
|
||||||
|
if cursor.rowcount > 0:
|
||||||
|
flag = True
|
||||||
|
else:
|
||||||
|
print("更新失败")
|
||||||
|
return flag
|
||||||
|
|
||||||
|
|
||||||
|
# 绑定检查
|
||||||
|
async def check_user_bind(uid):
|
||||||
|
flag = False
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
data = (uid,)
|
||||||
|
sql = "SELECT player,platform FROM user_bind WHERE qq_id =?"
|
||||||
|
result = cursor.execute(sql, data)
|
||||||
|
users = result.fetchall()
|
||||||
|
player = ""
|
||||||
|
platform = 'pc'
|
||||||
|
if len(users) > 0:
|
||||||
|
player = users[0][0]
|
||||||
|
platform = users[0][0]
|
||||||
|
flag = True
|
||||||
|
connect.commit()
|
||||||
|
res = (player, flag, platform)
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
# 支援者检查
|
||||||
|
async def check_user_support(uid):
|
||||||
|
flag = False
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
data = (uid,)
|
||||||
|
sql = "SELECT support FROM user_bind WHERE qq_id =?"
|
||||||
|
result = cursor.execute(sql, data)
|
||||||
|
users = result.fetchall()
|
||||||
|
if len(users) > 0:
|
||||||
|
if users[0][0] == 1:
|
||||||
|
flag = True
|
||||||
|
connect.commit()
|
||||||
|
return flag
|
||||||
|
|
||||||
|
|
||||||
|
# 支援者检查2
|
||||||
|
async def check_user_support2(uid, user_name):
|
||||||
|
flag = False
|
||||||
|
connect = get_db()
|
||||||
|
cursor = connect.cursor()
|
||||||
|
data = (uid,)
|
||||||
|
sql = "SELECT support,player FROM user_bind WHERE qq_id =?"
|
||||||
|
result = cursor.execute(sql, data)
|
||||||
|
users = result.fetchall()
|
||||||
|
if len(users) > 0:
|
||||||
|
if users[0][0] == 1:
|
||||||
|
db_user = users[0][1]
|
||||||
|
db_user = db_user.upper()
|
||||||
|
data_user = user_name.upper()
|
||||||
|
if db_user == data_user:
|
||||||
|
flag = True
|
||||||
|
connect.commit()
|
||||||
|
return flag
|
0
hexi/plugins/core/__init__.py
Normal file
37
hexi/plugins/core/message_handle.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from nonebot.adapters.onebot.v11 import MessageSegment
|
||||||
|
|
||||||
|
|
||||||
|
class TextMessage:
|
||||||
|
def __init__(self, text):
|
||||||
|
self.text = text
|
||||||
|
|
||||||
|
|
||||||
|
class ImageMessage:
|
||||||
|
def __init__(self, image):
|
||||||
|
self.image = image
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownMessage:
|
||||||
|
def __init__(self, raw):
|
||||||
|
self.raw = raw
|
||||||
|
|
||||||
|
|
||||||
|
class MessageState:
|
||||||
|
def __init__(self, data_dict):
|
||||||
|
self.data_dict = data_dict
|
||||||
|
|
||||||
|
# 获取命令头
|
||||||
|
def get_command(self):
|
||||||
|
return self.data_dict['_prefix']['command']
|
||||||
|
|
||||||
|
# 获取命令参数
|
||||||
|
def get_command_arg(self):
|
||||||
|
command_arg_list = self.data_dict['_prefix']['command_arg']
|
||||||
|
if command_arg_list:
|
||||||
|
command_arg = command_arg_list[0]
|
||||||
|
if isinstance(command_arg, MessageSegment):
|
||||||
|
if command_arg.type == 'text':
|
||||||
|
return TextMessage(command_arg.data['text'])
|
||||||
|
elif command_arg.type == 'image':
|
||||||
|
return ImageMessage(command_arg.data['url'])
|
||||||
|
return None # 返回 None 表示命令参数为空或无法解析
|
674
hexi/plugins/dailywife/LICENSE
Normal file
@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
47
hexi/plugins/dailywife/README.md
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
# 今日老婆
|
||||||
|
|
||||||
|
一个适用于HoshinoBot的随机群友老婆插件
|
||||||
|
|
||||||
|
### ★ 如果你喜欢的话,请给仓库点一个star支持一下23333 ★
|
||||||
|
|
||||||
|
## 本项目地址:
|
||||||
|
|
||||||
|
https://github.com/SonderXiaoming/dailywife
|
||||||
|
|
||||||
|
## 部署教程:
|
||||||
|
|
||||||
|
1.下载或git clone本插件:
|
||||||
|
|
||||||
|
在 HoshinoBot\hoshino\modules 目录下使用以下命令拉取本项目
|
||||||
|
|
||||||
|
git clone https://github.com/SonderXiaoming/dailywife
|
||||||
|
|
||||||
|
2.启用:
|
||||||
|
|
||||||
|
在 HoshinoBot\hoshino\config\ **bot**.py 文件的 MODULES_ON 加入 'dailywife'
|
||||||
|
|
||||||
|
然后重启 HoshinoBot
|
||||||
|
|
||||||
|
## 指令
|
||||||
|
|
||||||
|
【今日老婆】
|
||||||
|
|
||||||
|
随机抓一位群友当老婆
|
||||||
|
|
||||||
|
每天群友老婆是固定的
|
||||||
|
|
||||||
|
每个群友只能当一个人的老婆
|
||||||
|
|
||||||
|
## 彩蛋
|
||||||
|
|
||||||
|
超管必抽到bot
|
||||||
|
|
||||||
|
群友必抽不到bot
|
||||||
|
|
||||||
|
(与原版老婆指令对应,想ntr我老婆?)
|
||||||
|
|
||||||
|
修改的话只要把laopo.py的82,83,94行注释掉,84行elif改成if
|
||||||
|
|
||||||
|
## 已知问题
|
||||||
|
|
||||||
|
储存数据用json可能不太好
|
118
hexi/plugins/dailywife/__init__.py
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
import base64
|
||||||
|
import datetime
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from random import choice
|
||||||
|
|
||||||
|
import httpx
|
||||||
|
from nonebot import on_command
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageEvent, Bot, MessageSegment
|
||||||
|
from nonebot.plugin import PluginMetadata
|
||||||
|
|
||||||
|
__plugin_meta__ = PluginMetadata(
|
||||||
|
name="今日老婆",
|
||||||
|
description="随机抓取群友作为老婆",
|
||||||
|
usage="发送【今日老婆】",
|
||||||
|
type="application",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
wife = on_command("今日老婆", aliases={"今日老婆"})
|
||||||
|
|
||||||
|
|
||||||
|
def get_member_list(all_list):
|
||||||
|
id_list = []
|
||||||
|
for member_list in all_list:
|
||||||
|
id_list.append(member_list['user_id'])
|
||||||
|
return id_list
|
||||||
|
|
||||||
|
|
||||||
|
async def download_avatar(user_id: str) -> bytes:
|
||||||
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=640"
|
||||||
|
data = await download_url(url)
|
||||||
|
if not data or hashlib.md5(data).hexdigest() == "acef72340ac0e914090bd35799f5594e":
|
||||||
|
url = f"http://q1.qlogo.cn/g?b=qq&nk={user_id}&s=100"
|
||||||
|
data = await download_url(url)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
async def download_url(url: str) -> bytes:
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
for i in range(3):
|
||||||
|
try:
|
||||||
|
resp = await client.get(url)
|
||||||
|
if resp.status_code != 200:
|
||||||
|
continue
|
||||||
|
return resp.content
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error downloading {url}, retry {i}/3: {str(e)}")
|
||||||
|
|
||||||
|
|
||||||
|
async def get_wife_info(member_info, qq_id):
|
||||||
|
img = await download_avatar(qq_id)
|
||||||
|
base64_str = base64.b64encode(img).decode()
|
||||||
|
avatar = 'base64://' + base64_str
|
||||||
|
member_name = (member_info["card"] or member_info["nickname"])
|
||||||
|
msg = (MessageSegment.text('你今天的群友老婆是:'), MessageSegment.image(avatar), MessageSegment.text(f'{member_name}({qq_id})'))
|
||||||
|
return msg
|
||||||
|
|
||||||
|
|
||||||
|
def load_group_config(group_id: str) -> int:
|
||||||
|
filename = os.path.join(os.path.dirname(__file__), 'config', f'{group_id}.json')
|
||||||
|
try:
|
||||||
|
with open(filename, encoding='utf8') as f:
|
||||||
|
config = json.load(f)
|
||||||
|
return config
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def write_group_config(group_id: str, link_id: str, wife_id: str, date: str, config) -> int:
|
||||||
|
config_file = os.path.join(os.path.dirname(__file__), 'config', f'{group_id}.json')
|
||||||
|
if config is not None:
|
||||||
|
config[link_id] = [wife_id, date]
|
||||||
|
else:
|
||||||
|
config = {link_id: [wife_id, date]}
|
||||||
|
with open(config_file, 'w', encoding='utf-8') as f:
|
||||||
|
json.dump(config, f, ensure_ascii=False)
|
||||||
|
|
||||||
|
|
||||||
|
@wife.handle()
|
||||||
|
async def wife_handle(bot: Bot, ev: MessageEvent):
|
||||||
|
group_id = ev.group_id
|
||||||
|
user_id = ev.user_id
|
||||||
|
bot_id = ev.self_id
|
||||||
|
wife_id = None
|
||||||
|
today = str(datetime.date.today())
|
||||||
|
config = load_group_config(group_id)
|
||||||
|
|
||||||
|
# if priv.check_priv(ev, priv.SUPERUSER):
|
||||||
|
# wife_id = bot_id
|
||||||
|
if config is not None:
|
||||||
|
if str(user_id) in list(config):
|
||||||
|
if config[str(user_id)][1] == today:
|
||||||
|
wife_id = config[str(user_id)][0]
|
||||||
|
else:
|
||||||
|
del config[str(user_id)]
|
||||||
|
|
||||||
|
if wife_id is None:
|
||||||
|
all_list = await bot.get_group_member_list(group_id=group_id)
|
||||||
|
id_list = get_member_list(all_list)
|
||||||
|
id_list.remove(bot_id)
|
||||||
|
id_list.remove(user_id)
|
||||||
|
if config is not None:
|
||||||
|
for record_id in list(config):
|
||||||
|
if config[record_id][1] != today:
|
||||||
|
del config[record_id]
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
id_list.remove(int(config[record_id][0]))
|
||||||
|
except:
|
||||||
|
del config[record_id]
|
||||||
|
wife_id = choice(id_list)
|
||||||
|
|
||||||
|
write_group_config(group_id, user_id, wife_id, today, config)
|
||||||
|
member_info = await bot.get_group_member_info(group_id=group_id, user_id=wife_id)
|
||||||
|
result = await get_wife_info(member_info, wife_id)
|
||||||
|
await bot.send(ev, result, at_sender=True)
|
4299
poetry.lock
generated
Normal file
94
pyproject.toml
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
authors = ["sansenhoshi <sansenhoshi@outlook.com>"]
|
||||||
|
description = "基于 NoneBot2 的机器人"
|
||||||
|
license = "MIT"
|
||||||
|
name = "hexi"
|
||||||
|
readme = "README.md"
|
||||||
|
repository = ""
|
||||||
|
version = "0.0.1"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.10"
|
||||||
|
eorzeaenv = "^2.2.8"
|
||||||
|
matplotlib = "^3.7.1"
|
||||||
|
expiringdict = "^1.2.2"
|
||||||
|
|
||||||
|
nonebot2 = { extras = ["httpx", "fastapi", "websockets"], version = "^2.1.0" }
|
||||||
|
nb-cli = "^1.2.3"
|
||||||
|
nonebot-adapter-onebot = "2.2.4"
|
||||||
|
|
||||||
|
nonebot-plugin-datastore = "^1.1.2"
|
||||||
|
nonebot-plugin-wordcloud = "^0.5.2"
|
||||||
|
nonebot-plugin-treehelp = "^0.3.0"
|
||||||
|
nonebot-plugin-user = "^0.0.1"
|
||||||
|
|
||||||
|
nonebot-plugin-apscheduler = "^0.3.0"
|
||||||
|
nonebot-plugin-send-anything-anywhere = "^0.3.1"
|
||||||
|
nonebot-plugin-alconna = "^0.24.0"
|
||||||
|
nonebot-plugin-session = "^0.1.0"
|
||||||
|
nonebot-plugin-userinfo = "^0.1.0"
|
||||||
|
|
||||||
|
nonebot-plugin-sentry = "^0.4.0"
|
||||||
|
nonebot-plugin-memes = "0.4.7"
|
||||||
|
nonebot-bison = "0.8.2"
|
||||||
|
nonebot-plugin-gscode = "0.2.1"
|
||||||
|
nonebot-plugin-status = "0.7.1"
|
||||||
|
nonebot-plugin-bawiki = "0.9.3"
|
||||||
|
|
||||||
|
[tool.poetry.group.dev.dependencies]
|
||||||
|
nonebug = "^0.3.3"
|
||||||
|
pytest-cov = "^4.0.0"
|
||||||
|
pytest-mock = "^3.6.1"
|
||||||
|
pytest-xdist = "^3.0.2"
|
||||||
|
pytest-asyncio = "^0.21.0"
|
||||||
|
respx = "^0.20.1"
|
||||||
|
freezegun = "^1.2.2"
|
||||||
|
nonebug-saa = { git = "https://github.com/MountainDash/nonebug-saa.git" }
|
||||||
|
|
||||||
|
[tool.nonebot]
|
||||||
|
adapters = [
|
||||||
|
{ name = "OneBot V11", module_name = "nonebot.adapters.onebot.v11" },
|
||||||
|
{ name = "OneBot V12", module_name = "nonebot.adapters.onebot.v12" },
|
||||||
|
{name = "minecraft", module_name = "nonebot.adapter.minecraft"},
|
||||||
|
]
|
||||||
|
plugin_dirs = ["hexi/plugins"]
|
||||||
|
plugins = [
|
||||||
|
"onebot_qqguild_extension",
|
||||||
|
"nonebot_plugin_apscheduler",
|
||||||
|
"nonebot_plugin_saa",
|
||||||
|
"nonebot_plugin_alconna",
|
||||||
|
"nonebot_plugin_datastore",
|
||||||
|
"nonebot_plugin_session",
|
||||||
|
"nonebot_plugin_userinfo",
|
||||||
|
"nonebot_plugin_user",
|
||||||
|
"nonebot_plugin_sentry",
|
||||||
|
"nonebot_plugin_treehelp",
|
||||||
|
"nonebot_plugin_wordcloud",
|
||||||
|
"nonebot_plugin_memes",
|
||||||
|
"nonebot_plugin_status",
|
||||||
|
"nonebot_plugin_bawiki",
|
||||||
|
"nonebot_plugin_admin",
|
||||||
|
]
|
||||||
|
|
||||||
|
[tool.black]
|
||||||
|
line-length = 88
|
||||||
|
|
||||||
|
[tool.isort]
|
||||||
|
profile = "black"
|
||||||
|
line_length = 88
|
||||||
|
skip_gitignore = true
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
asyncio_mode = "auto"
|
||||||
|
|
||||||
|
[tool.pyright]
|
||||||
|
typeCheckingMode = "basic"
|
||||||
|
|
||||||
|
[tool.ruff]
|
||||||
|
select = ["E", "W", "F", "UP", "C", "T", "PYI", "Q"]
|
||||||
|
ignore = ["E402", "E501", "E711", "C901", "UP037"]
|
||||||
|
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
160
requirements.txt
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
aiofiles==23.2.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
aiosqlite==0.19.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
alembic==1.12.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
anyio==3.7.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
apscheduler==3.10.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
arclet-alconna-tools==0.6.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
arclet-alconna==1.7.32 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
arrow==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
bbcode==1.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
beautifulsoup4==4.12.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
bidict==0.22.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
binaryornot==0.4.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
bs4==0.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
cachetools==5.3.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
cashews==6.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
certifi==2023.7.22 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
chardet==5.2.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
charset-normalizer==3.3.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
click==8.1.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
colorama==0.4.6 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32" or python_version >= "3.10" and python_version < "4.0" and platform_system == "Windows"
|
||||||
|
contourpy==1.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
cookiecutter==2.4.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
cycler==0.12.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
dateparser==1.1.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
distlib==0.3.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
emoji==2.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
eorzeaenv==2.2.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
exceptiongroup==1.1.3 ; python_version >= "3.10" and python_version < "3.11"
|
||||||
|
expiringdict==1.2.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
fastapi==0.104.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
feedparser==6.0.10 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
filelock==3.12.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
filetype==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
fonttools==4.43.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
greenlet==3.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
h11==0.14.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
h2==4.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
hpack==4.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
httpcore==0.18.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
httptools==0.6.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
httpx==0.25.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
httpx[http2]==0.25.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
humanize==4.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
hyperframe==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
idna==3.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
jieba==0.42.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
jinja2==3.1.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
kiwisolver==1.4.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
loguru==0.7.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
lxml==4.9.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
mako==1.2.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
markdown-it-py==3.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
markdown==3.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
markupsafe==2.1.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
matplotlib==3.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
mdurl==0.1.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
meme-generator==0.0.16 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
msgpack==1.0.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
multidict==6.0.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nb-cli==1.2.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nepattern==0.5.15 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-adapter-onebot==2.2.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-bison==0.8.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-alconna==0.24.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-apscheduler==0.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-bawiki==0.9.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-cesaa==0.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-chatrecorder==0.4.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-datastore==1.1.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-gscode==0.2.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-htmlrender==0.2.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-localstore==0.5.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-memes==0.4.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-send-anything-anywhere==0.3.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-sentry==0.4.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-session==0.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-status==0.7.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-treehelp==0.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-user==0.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-userinfo==0.1.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot-plugin-wordcloud==0.5.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot2==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot2[fastapi,httpx,websockets]==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot2[fastapi]==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
nonebot2[httpx]==2.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
noneprompt==0.1.9 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
numpy==1.25.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
opencv-python-headless==4.8.1.78 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
packaging==23.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pil-utils==0.1.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pillow==10.1.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
platformdirs==3.11.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
playwright==1.39.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
prompt-toolkit==3.0.39 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
psutil==5.9.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pydantic==1.10.13 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pydantic[dotenv]==1.10.13 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pyee==11.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pyfiglet==0.8.post1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pygments==2.16.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pygtrie==2.5.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pyjwt==2.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pymdown-extensions==10.3.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pyparsing==3.1.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pypinyin==0.49.0 ; python_version >= "3.10" and python_version < "4"
|
||||||
|
python-dateutil==2.8.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-dotenv==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-engineio==4.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-markdown-math==0.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-multipart==0.0.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-slugify==8.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
python-socketio==5.10.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pytz==2023.3.post1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
pyyaml==6.0.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
rapidfuzz==2.15.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
regex==2023.10.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
requests==2.31.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
rich==13.6.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
sentry-sdk==1.32.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
setuptools-scm==8.0.4 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
setuptools==68.2.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
sgmllib3k==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
simple-websocket==1.0.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
six==1.16.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
sniffio==1.3.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
soupsieve==2.5 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
sqlalchemy==2.0.22 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
sqlalchemy[aiosqlite]==2.0.22 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
starlette==0.27.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
strenum==0.4.15 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
tarina==0.4.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
text-unidecode==1.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
tinydb==4.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
toml==0.10.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
tomli==2.0.1 ; python_version >= "3.10" and python_version < "3.11"
|
||||||
|
tomlkit==0.12.1 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
types-python-dateutil==2.8.19.14 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
typing-extensions==4.8.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
tzdata==2023.3 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
tzlocal==5.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
urllib3==2.0.7 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
uvicorn==0.23.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
uvicorn[standard]==0.23.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
uvloop==0.19.0 ; sys_platform != "win32" and sys_platform != "cygwin" and platform_python_implementation != "PyPy" and python_version >= "3.10" and python_version < "4.0"
|
||||||
|
virtualenv==20.24.6 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
watchfiles==0.21.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
wcwidth==0.2.8 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
websockets==12.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
win32-setctime==1.1.0 ; python_version >= "3.10" and python_version < "4.0" and sys_platform == "win32"
|
||||||
|
wordcloud==1.9.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
wsproto==1.2.0 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
yarl==1.9.2 ; python_version >= "3.10" and python_version < "4.0"
|
||||||
|
|
||||||
|
httpx~=0.25.0
|
||||||
|
SQLAlchemy~=2.0.22
|
||||||
|
aiohttp~=3.8.6
|
||||||
|
Pillow~=10.1.0
|
||||||
|
CairoSVG~=2.7.1
|
||||||
|
qrcode~=7.4.2
|
||||||
|
requests~=2.31.0
|
24
test/__init__.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
from nonebot import on_command
|
||||||
|
from nonebot.plugin import PluginMetadata
|
||||||
|
from nonebot.adapters.onebot.v11 import MessageEvent
|
||||||
|
|
||||||
|
__plugin_meta__ = PluginMetadata(
|
||||||
|
"测试",
|
||||||
|
"测试",
|
||||||
|
"测试",
|
||||||
|
)
|
||||||
|
|
||||||
|
test = on_command("测试", aliases={"测试"})
|
||||||
|
|
||||||
|
|
||||||
|
@test.handle()
|
||||||
|
async def handle_test(event: MessageEvent):
|
||||||
|
msg = str(event.message).split(" ")[1]
|
||||||
|
uid = event.user_id
|
||||||
|
gid = event.group_id
|
||||||
|
nickname = event.sender.nickname
|
||||||
|
mes = f"测试所在群聊:{gid}\n" \
|
||||||
|
f"测试发送者:{uid}\n" \
|
||||||
|
f"测试者昵称:{nickname}\n" \
|
||||||
|
f"测试附加内容:{msg}"
|
||||||
|
await test.finish(mes)
|