增加帮助菜单指令

This commit is contained in:
CMHopeSunshine 2022-06-09 21:57:56 +08:00
parent f74f3cc81b
commit e4f6c34cc7
15 changed files with 341 additions and 24 deletions

View File

@ -16,9 +16,23 @@ setting_time = config.paimon_guess_voice # 游戏持续时间
dir_name = Path() / 'data' / 'LittlePaimon' / 'guess_voice' / 'voice'
__paimon_help__ = {
'type': '娱乐',
'range': ['group']
}
guess_game = on_command('原神猜语音', priority=12, block=True)
guess_game.__paimon_help__ = {
"usage": "原神猜语音[语言]",
"introduce": "来一起猜语音吧",
"priority": 5
}
ys_voice = on_command('原神语音', priority=12, block=True)
ys_voice.__paimon_help__ = {
"usage": "原神语音[语言]<角色名>",
"introduce": "随机发一条该角色的语音",
"priority": 6
}
update_ys_voice = on_command('更新原神语音资源', priority=12, permission=SUPERUSER, block=True)

View File

@ -16,7 +16,17 @@ HELP_STR = '''
原神日历 status : 查看本群日历推送设置
'''.strip()
__paimon_help__ = {
'type': '原神Wiki',
'range': ['private', 'group', 'guild']
}
calendar = on_command('原神日历', aliases={"原神日历", 'ysrl', '原神日程'}, priority=24, block=True)
calendar.__paimon_help__ = {
"usage": "原神日历",
"introduce": "查看原神活动日历后加on时间/off可以开启定时推送",
"priority": 99
}
scheduler = require('nonebot_plugin_apscheduler').scheduler

View File

@ -26,6 +26,8 @@ chat_lmt = FreqLimiter2(60)
update_voice = on_command('更新派蒙语音', priority=2)
# TODO 被动效果
def check_group(event: GroupMessageEvent) -> bool:
if event.group_id in config.paimon_chat_group:

View File

@ -23,12 +23,34 @@ __usage__ = '''
'''
__help_version__ = '1.0.1'
__paimon_help__ = {
'type': '原神模拟抽卡',
'range': ['private', 'group', 'guild']
}
sim_gacha = on_regex(r'^抽((?P<num>\d+)|(?:.*))十连(?P<pool>.*?)$', priority=5, block=True)
sim_gacha.__paimon_help__ = {
"usage": "抽[数量]十连[卡池]",
"introduce": "模拟抽卡池有角色1|角色2|武器|常驻|菜单",
"priority": 1
}
show_log = on_command('模拟抽卡记录', aliases={'查看模拟抽卡记录'}, priority=5, block=True)
show_log.__paimon_help__ = {
"usage": "模拟抽卡记录[角色|武器]",
"introduce": "查看你的模拟抽卡记录,前加删除可以删除记录",
"priority": 2
}
delete_log = on_command('删除模拟抽卡记录', priority=5, block=True)
show_dg = on_command('查看定轨', priority=5, block=True)
delete_dg = on_command('删除定轨', priority=5, block=True)
choose_dg = on_command('选择定轨', priority=5, block=True)
choose_dg.__paimon_help__ = {
"usage": "选择定轨<武器名>",
"introduce": "模拟抽卡定轨,另有 查看|删除定轨",
"priority": 3
}
lmt_group = FreqLimiter(config.paimon_gacha_cd_group)
lmt_user = FreqLimiter(config.paimon_gacha_cd_user)

View File

@ -20,10 +20,30 @@ __usage__ = '''
'''
__help_version__ = '0.9.0'
__paimon_help__ = {
'type': '原神抽卡记录',
'range': ['private', 'group', 'guild']
}
gacha_log_export = on_command('ckjldc', aliases={'抽卡记录导出', '导出抽卡记录'}, priority=5, block=True)
gacha_log_export.__paimon_help__ = {
"usage": "抽卡记录导出(uid)",
"introduce": "将抽卡记录导出到群文件中",
"priority": 3
}
gacha_log_update = on_command('ckjlgx', aliases={'抽卡记录更新', '更新抽卡记录', '获取抽卡记录'}, priority=5, block=True)
gacha_log_update.__paimon_help__ = {
"usage": "获取抽卡记录<链接>(uid)",
"introduce": "从抽卡链接获取抽卡记录,抽卡链接通过祈愿页面断网取得",
"priority": 1
}
gacha_log_show = on_command('ckjl', aliases={'抽卡记录', '查看抽卡记录'}, priority=5, block=True)
gacha_log_show.__paimon_help__ = {
"usage": "查看抽卡记录(uid)",
"introduce": "查看你的抽卡记录分析",
"priority": 2
}
data_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'user_data', 'gacha_log_data')
if not os.path.exists(data_path):

View File

@ -59,23 +59,78 @@ __usage__ = '''
[添加公共ck cookie]添加公共cookie以供大众查询*仅管理员
'''
__paimon_help__ = {
'type': '原神信息查询',
'range': ['private', 'group', 'guild']
}
__help_version__ = '1.1.0'
sy = on_command('sy', aliases={'深渊信息', '深境螺旋信息'}, priority=7, block=True)
sy.__paimon_help__ = {
"usage": "sy[层数](uid)",
"introduce": "查看深渊战绩信息",
"priority": 6
}
ssbq = on_command('ssbq', aliases={'实时便笺', '实时便签', '当前树脂'}, priority=7, block=True)
ssbq.__paimon_help__ = {
"usage": "ssbq(uid)",
"introduce": "*查看当前树脂、洞天宝钱、派遣状况等",
"priority": 7
}
myzj = on_command('myzj', aliases={'札记信息', '每月札记'}, priority=7, block=True)
myzj.__paimon_help__ = {
"usage": "myzj[月份](uid)",
"introduce": "*查看该月份获得的原石、摩拉数",
"priority": 8
}
ys = on_command('ys', aliases={'原神卡片', '个人卡片'}, priority=7, block=True)
ys.__paimon_help__ = {
"usage": "ys(uid)",
"introduce": "查看原神个人卡片(宝箱、探索度等)",
"priority": 1
}
ysa = on_command('ysa', aliases={'角色背包'}, priority=7, block=True)
ysa.__paimon_help__ = {
"usage": "ysa(uid)",
"introduce": "查看原神公开角色的简略信息",
"priority": 2
}
ysc = on_command('ysc', aliases={'角色卡片'}, priority=7, block=True)
ysc.__paimon_help__ = {
"usage": "ysc<角色名>(uid)",
"introduce": "查看原神指定角色的简略信息",
"priority": 3
}
ysb = on_command('ysb', aliases={'原神绑定', '绑定cookie'}, priority=7, block=True)
ysb.__paimon_help__ = {
"usage": "ysb<cookie>",
"introduce": "绑定私人cookie以开启更多功能",
"priority": 99
}
mys_sign = on_command('mys_sign', aliases={'mys签到', '米游社签到'}, priority=7, block=True)
mys_sign_auto = on_command('mys_sign_auto', aliases={'mys自动签到', '米游社自动签到'}, priority=7, block=True)
mys_sign_auto.__paimon_help__ = {
"usage": "mys自动签到<on|off uid>",
"introduce": "*米游社原神区自动签到奖励获取",
"priority": 9
}
mys_sign_all = on_command('mys_sign_all', aliases={'全部重签'}, priority=1, permission=SUPERUSER, rule=to_me(), block=True)
update_all = on_command('update_all', aliases={'更新全部玩家'}, priority=1, permission=SUPERUSER, rule=to_me(), block=True)
add_public_ck = on_command('add_ck', aliases={'添加公共cookie', '添加公共ck'}, permission=SUPERUSER, priority=7, block=True)
delete_ck = on_command('delete_ck', aliases={'删除ck', '删除cookie'}, priority=7, block=True)
update_info = on_command('udi', aliases={'更新角色信息', '更新角色面板', '更新玩家信息'}, priority=6, block=True)
update_info.__paimon_help__ = {
"usage": "更新角色信息(uid)",
"introduce": "更新游戏内展柜8个角色的面板信息以便使用ysd指令",
"priority": 5
}
role_info = on_command('角色面板', aliases={'角色详情', '角色信息', 'ysd'}, block=True, priority=7)
role_info.__paimon_help__ = {
"usage": "ysd<角色名>(uid)",
"introduce": "查看指定角色的详细面板信息",
"priority": 4
}
@sy.handle()
@ -411,15 +466,15 @@ async def mys_sign_auto_handler(event: MessageEvent, msg: Message = CommandArg()
await mys_sign_auto.finish('请把正确的需要帮忙签到的uid给派蒙哦!', at_sender=True)
else:
uid = find_uid.group('uid')
find_action = re.search(r'(?P<action>开启|启用|打开|关闭|禁用)', msg)
find_action = re.search(r'(?P<action>开启|启用|打开|关闭|禁用|on|off)', msg)
if find_action:
if find_action.group('action') in ['开启', '启用', '打开']:
if find_action.group('action') in ['开启', '启用', '打开', 'on']:
cookie = await get_private_cookie(uid, key='uid')
if not cookie:
await mys_sign_auto.finish('你的该uid还没绑定cookie哦先用ysb绑定吧!', at_sender=True)
await add_auto_sign(str(event.user_id), uid, str(event.group_id))
await mys_sign_auto.finish('开启米游社自动签到成功,派蒙会在每日0点帮你签到', at_sender=True)
elif find_action.group('action') in ['关闭', '禁用']:
elif find_action.group('action') in ['关闭', '禁用', 'off']:
await delete_auto_sign(str(event.user_id), uid)
await mys_sign_auto.finish('关闭米游社自动签到成功', at_sender=True)
else:

View File

@ -1,21 +1,26 @@
# 点餐功能
from .order import *
# 新闻功能
from .news import *
# 随机图片功能
from .random_img import *
# 处理好友和群请求功能
from .auto_handle import *
# 对联功能
from .couplets import *
# # 点餐功能
# from .order import *
#
# # 新闻功能
# from .news import *
#
# # 随机图片功能
# from .random_img import *
#
# # 处理好友和群请求功能
# from .auto_handle import *
#
# # 对联功能
# from .couplets import *
#
# from .help import help_
# 如果不需要某项功能将其from xx import * 注释掉即可
from nonebot import load_plugins
import os
load_plugins(os.path.dirname(__file__))

View File

@ -7,7 +7,17 @@ from utils.message_util import get_message_id
from utils.config import config
from utils import aiorequests
__paimon_help__ = {
'type': '娱乐',
'range': ['private', 'group', 'guild']
}
couplets = on_command('对联', aliases={'对对联'}, priority=13, block=True)
couplets.__paimon_help__ = {
"usage": "对对联 <对联内容>",
"introduce": "人工智能和你对对联",
"priority": 8
}
couplets_limit = FreqLimiter(config.paimon_couplets_cd)

View File

@ -6,7 +6,17 @@ from utils import aiorequests
from utils.file_handler import load_json, save_json
from utils.message_util import get_message_id
__paimon_help__ = {
'type': '娱乐',
'range': ['private', 'group', 'guild']
}
news60s_pic = on_command('早报', aliases={'今日早报', '今日新闻', '60s读世界'}, priority=13, block=True)
news60s_pic.__paimon_help__ = {
"usage": "今日早报",
"introduce": "获取60秒读世界早报后加on时间/off可以开启/关闭推送",
"priority": 10
}
scheduler = require('nonebot_plugin_apscheduler').scheduler

View File

@ -5,7 +5,18 @@ from nonebot.adapters.onebot.v11 import Message, MessageEvent, MessageSegment
from utils.auth_util import FreqLimiter
from utils import aiorequests
__paimon_help__ = {
'type': '娱乐',
'range': ['private', 'group', 'guild']
}
order_pic = on_command('点菜', aliases={'点餐', '食谱', '我想吃'}, priority=13, block=True)
order_pic.__paimon_help__ = {
"usage": "点餐<食品名>",
"introduce": "群主,来一份派蒙!",
"priority": 11
}
order_lmt = FreqLimiter(10)

View File

@ -0,0 +1,131 @@
from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
from typing import Dict, List
from nonebot import on_command
from nonebot import plugin as nb_plugin
from nonebot.params import Depends
from nonebot.adapters.onebot.v11 import MessageEvent
from utils.message_util import MessageBuild
__version__ = 'v1.0.0'
__paimon_help__ = {
'type': '工具',
'range': ['private', 'group', 'guild']
}
help_ = on_command('help', aliases={'帮助菜单'}, priority=1, block=True)
help_.__paimon_help__ = {
"usage": "帮助菜单|help",
"introduce": "查看派蒙的帮助信息",
"priority": 99
}
font_path = Path(__file__).parent.parent / 'res'
res_path = Path(__file__).parent.parent / 'res' / 'help'
def get_font(size, font='hywh.ttf') -> ImageFont:
return ImageFont.truetype(str(font_path / font), size=size)
# 绘制带阴影的文字
def draw_shadow_text(draw: ImageDraw, pos: tuple, text: str, font: ImageFont, color: tuple, shadow_color: tuple,
shadow_offset: tuple = (1, 1)):
draw.text(pos, text, font=font, fill=shadow_color)
draw.text((pos[0] - shadow_offset[0], pos[1] - shadow_offset[1]), text, font=font, fill=color)
def draw_table(title: str, funcs: List[dict], total_width: int):
row = len(funcs) // 3 if not len(funcs) % 3 else len(funcs) // 3 + 1
total_height = 120 + row * 160
bg_color = (100, 100, 100, 100)
title_color = (40, 40, 40, 125)
usage_color = (255, 255, 255, 255)
introduce_color = (200, 200, 200, 255)
radius = 50
bg = Image.new('RGBA', (total_width, total_height), (0, 0, 0, 0))
bg_draw = ImageDraw.Draw(bg)
bg_draw.ellipse((0, 0, radius, radius), fill=bg_color)
bg_draw.ellipse((total_width - radius, 0, total_width, radius), fill=bg_color)
bg_draw.ellipse((0, total_height - radius, radius, total_height), fill=bg_color)
bg_draw.ellipse((total_width - radius, total_height - radius, total_width, total_height), fill=bg_color)
bg_draw.rectangle((radius / 2, 0, total_width - radius / 2, total_height), fill=bg_color)
bg_draw.rectangle((0, radius / 2, total_width, total_height - radius / 2), fill=bg_color)
draw_shadow_text(bg_draw, (50, 23), title, get_font(50), (255, 255, 255), (0, 0, 0, 255), (2, 2))
i = 0
for func in funcs:
x = (i % 3) * (total_width / 3) + 4
y = 100 + (i // 3) * 160 + 4
bg_draw.rectangle((x, y, x + total_width / 3 - 8, y + 160 - 8), fill=title_color)
bg_draw.text((x + 7, y + 7), func['usage'], font=get_font(36), fill=usage_color)
# 如果introduce长度大于15 就分多行绘制
if len(func['introduce']) > 15:
bg_draw.text((x + 10, y + 60), func['introduce'][:15], font=get_font(30), fill=introduce_color)
bg_draw.text((x + 10, y + 90), func['introduce'][15:], font=get_font(30), fill=introduce_color)
else:
bg_draw.text((x + 10, y + 60), func['introduce'], font=get_font(30), fill=introduce_color)
i += 1
return row, bg
def draw_help_info(help_info: dict):
total_height = 400 + len(help_info) * 150 - 50
for m in help_info:
total_height += 160 * len(help_info[m]) // 3
if len(help_info[m]) % 3:
total_height += 160
total_height += 150
img = Image.new('RGBA', (1500, total_height), color=(255, 255, 255, 255))
bg_img = Image.open(str(res_path / 'bg.jpg')).convert('RGBA').resize((1500, total_height))
img.paste(bg_img, (0, 0), bg_img)
draw = ImageDraw.Draw(img)
draw_shadow_text(draw, (50, 50), '派蒙帮助', get_font(140), (255, 255, 255), (0, 0, 0, 255), (3, 3))
draw_shadow_text(draw, (610, 140), __version__, get_font(50), (255, 255, 255), (0, 0, 0, 255), (3, 3))
draw_shadow_text(draw, (520, 250), '<>内为必须,[]内为可选,()内只需要第一次', get_font(50), (255, 255, 255), (0, 0, 0, 255), (2, 2))
draw_shadow_text(draw, (620, 300), '描述前带*号说明需要绑定私人cookie', get_font(50), (255, 255, 255), (0, 0, 0, 255), (2, 2))
n = 400
for type, func_list in help_info.items():
row, table = draw_table(type, func_list, 1500 - 100)
img.alpha_composite(table, (50, n))
n += 170 + row * 160
draw_shadow_text(draw, (800, n + 15), 'Created by LittlePaimon', get_font(50), (255, 255, 255), (0, 0, 0, 255), (2, 2))
return MessageBuild.Image(img, size=0.7, mode='RGB', quality=80)
async def get_all_plugin(event: MessageEvent) -> dict:
plugin_list = nb_plugin.get_loaded_plugins()
help_info: Dict[str, List[dict]] = {}
for plugin in plugin_list:
try:
plugin_info = plugin.module.__getattribute__('__paimon_help__')
except AttributeError:
plugin_info = {'type': '其他', 'range': ['private', 'group', 'guild']}
if event.message_type not in plugin_info['range']:
continue
if plugin_info['type'] not in help_info:
help_info[plugin_info['type']] = []
matchers = plugin.matcher
for matcher in matchers:
try:
matchers_info = matcher.__paimon_help__
if 'priority' not in matchers_info:
matchers_info['priority'] = 99
help_info[plugin_info['type']].append(matchers_info)
except AttributeError:
pass
help_info = {k: v for k, v in help_info.items() if v}
if not help_info:
await help_.finish('当前没有已加载的插件哦')
for m in help_info:
help_info[m].sort(key=lambda x: x['priority'])
help_info = dict(sorted(help_info.items(), key=lambda x: len(x[1]), reverse=True))
return help_info
@help_.handle()
async def _(event: MessageEvent, help_info: dict = Depends(get_all_plugin)):
await help_.finish(draw_help_info(help_info))

View File

@ -7,12 +7,27 @@ from utils.auth_util import FreqLimiter
from utils.message_util import get_message_id
from utils.decorator import auto_withdraw
__paimon_help__ = {
'type': '娱乐',
'range': ['private', 'group', 'guild']
}
cat_lmt = FreqLimiter(config.paimon_cat_cd)
ecy_lmt = FreqLimiter(config.paimon_ecy_cd)
ys_lmt = FreqLimiter(config.paimon_ysp_cd)
cat_img = on_command('猫图', aliases={'来点猫片', '看看猫猫', '来个猫猫'}, priority=13, block=True)
cat_img.__paimon_help__ = {
"usage": "来点猫片",
"introduce": "谁会拒绝可爱的猫猫图呢",
"priority": 13
}
ecy_img = on_regex(r'^来点(二次元|二刺螈|银发|兽耳|星空|竖屏|横屏)图?$', priority=13, block=True)
ecy_img.__paimon_help__ = {
"usage": "来点<类型>图",
"introduce": "懂得都懂,类型有原神|二次元|二刺螈|银发|兽耳|星空|竖屏|横屏",
"priority": 13
}
ys_img = on_command('原神壁纸', aliases={'来点原神图', '来点原神壁纸'}, priority=13, block=True)

View File

@ -23,6 +23,10 @@ __usage__ = '''
7.[深渊上半/下半阵容出场率]查看2.6深渊阵容出场率
'''
__help_version__ = '1.0.4'
__paimon_help__ = {
'type': '原神Wiki',
'range': ['private', 'group', 'guild']
}
res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res')
@ -96,8 +100,14 @@ async def abyss_team_handler(event: MessageEvent, reGroup=RegexDict()):
await abyss_team.finish(abyss_img)
def create_choice_command(endswith: str, type_: str, url: str, tips: str = None):
def create_choice_command(endswith: str, type_: str, url: str, tips: str = None, help_tips: str = None):
command = on_endswith(endswith, priority=6, block=True)
command.plugin_name = 'Paimon_Wiki'
command.__paimon_help__ = {
"usage": f'<{help_tips}名> ' + endswith,
"introduce": f"查看该{help_tips}{endswith}",
"priority": 3
}
@command.handle()
async def _(event: MessageEvent, state: T_State):
@ -105,7 +115,7 @@ def create_choice_command(endswith: str, type_: str, url: str, tips: str = None)
if name:
state['name'] = name
@command.got('name', prompt=f'请把要查询的{endswith[0:2]}告诉我哦~')
@command.got('name', prompt=f'请把要查询的{help_tips}告诉我哦~')
async def _(event: MessageEvent, state: T_State):
name = state['name']
if isinstance(name, Message):
@ -153,8 +163,8 @@ def create_choice_command(endswith: str, type_: str, url: str, tips: str = None)
await command.finish(await MessageBuild.StaticImage(url=url.format(choice), tips=tips.format(choice)))
create_choice_command('原魔图鉴', 'monsters', 'LittlePaimon/MonsterMaps/{}.jpg', '暂时没有{}的原魔图鉴哦~')
create_choice_command('武器攻略', 'weapons', 'LittlePaimon/WeaponGuild/{}.png', '暂时没有{}的武器攻略哦~')
create_choice_command('角色攻略', 'roles', 'LittlePaimon/XFGuide/{}.jpg', '暂时没有{}的角色攻略哦~')
create_choice_command('角色材料', 'roles', 'LittlePaimon/RoleMaterials/{}材料.jpg', '暂时没有{}的角色材料哦~')
create_choice_command('收益曲线', 'roles', 'LittlePaimon/blue/{}.jpg', '暂时没有{}的收益曲线哦~')
create_choice_command('原魔图鉴', 'monsters', 'LittlePaimon/MonsterMaps/{}.jpg', '暂时没有{}的原魔图鉴哦~', '原魔')
create_choice_command('武器攻略', 'weapons', 'LittlePaimon/WeaponGuild/{}.png', '暂时没有{}的武器攻略哦~', '武器')
create_choice_command('角色攻略', 'roles', 'LittlePaimon/XFGuide/{}.jpg', '暂时没有{}的角色攻略哦~', '角色')
create_choice_command('角色材料', 'roles', 'LittlePaimon/RoleMaterials/{}材料.jpg', '暂时没有{}的角色材料哦~', '角色')
create_choice_command('收益曲线', 'roles', 'LittlePaimon/blue/{}.jpg', '暂时没有{}的收益曲线哦~', '角色')

View File

@ -91,6 +91,8 @@
- 修复`模拟抽卡定轨``抽卡记录导出`bug
+ 6.7
- 修复`原神猜语音``模拟抽卡``nonebot2.0.0b3`版本Union校验产生的bug`原神猜语音`将暂时无法私聊使用
+ 6.9
- 新增`帮助菜单`指令~~(不太好看,继续美化)~~
## 丨功能列表

BIN
res/help/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB