WIKI使用oss发送静态资源,节省空间
@ -42,3 +42,4 @@ def create_matcher(chat_word: str, pattern: str, cooldown: int, pro: float, resp
|
|||||||
for k, v in chat_list.items():
|
for k, v in chat_list.items():
|
||||||
create_matcher(k, v['pattern'], v['cooldown'], v['pro'], v['files'])
|
create_matcher(k, v['pattern'], v['cooldown'], v['pro'], v['files'])
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,7 +299,7 @@ async def draw_daily_note_card(data, uid):
|
|||||||
bg_img.alpha_composite(role_img, (1220, 200))
|
bg_img.alpha_composite(role_img, (1220, 200))
|
||||||
now = datetime.datetime.now().strftime('%m月%d日%H:%M')
|
now = datetime.datetime.now().strftime('%m月%d日%H:%M')
|
||||||
bg_draw.text((554, 1794), 'Created by LittlePaimon·' + now, fill='#5680d2', font=get_font(40, '优设标题黑.ttf'))
|
bg_draw.text((554, 1794), 'Created by LittlePaimon·' + now, fill='#5680d2', font=get_font(40, '优设标题黑.ttf'))
|
||||||
bg_img = bg_img.resize((int(bg_img.size[0] * 0.37), int(bg_img.size[1] * 0.37)), Image.ANTIALIAS)
|
bg_img = bg_img.resize((int(bg_img.size[0] * 0.35), int(bg_img.size[1] * 0.35)), Image.ANTIALIAS)
|
||||||
bg_img = pil2b64(bg_img)
|
bg_img = pil2b64(bg_img, 70)
|
||||||
bg_img = MessageSegment.image(bg_img)
|
bg_img = MessageSegment.image(bg_img)
|
||||||
return bg_img
|
return bg_img
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
import os
|
import os
|
||||||
from PIL import Image
|
|
||||||
from pathlib import Path
|
|
||||||
from nonebot import on_endswith, on_command, on_regex
|
from nonebot import on_endswith, on_command, on_regex
|
||||||
from nonebot.params import RegexDict
|
from nonebot.params import RegexDict
|
||||||
from nonebot.adapters.onebot.v11 import MessageSegment, MessageEvent
|
from nonebot.adapters.onebot.v11 import MessageSegment, MessageEvent
|
||||||
from ..utils.character_alias import get_id_by_alias
|
from ..utils.character_alias import get_id_by_alias
|
||||||
from ..utils.util import pil2b64, exception_handler
|
from ..utils.util import exception_handler
|
||||||
from .blue import get_blue_pic
|
from .blue import get_blue_pic
|
||||||
from .abyss_rate_draw import draw_rate_rank, draw_teams_rate
|
from .abyss_rate_draw import draw_rate_rank, draw_teams_rate
|
||||||
import re
|
import re
|
||||||
@ -40,15 +38,12 @@ abyss_team = on_regex(r'^(深渊|深境螺旋)(?P<floor>上半|下半)阵容(排
|
|||||||
async def genshin_guide(event: MessageEvent):
|
async def genshin_guide(event: MessageEvent):
|
||||||
name: str = event.message.extract_plain_text().replace('角色攻略', '').strip()
|
name: str = event.message.extract_plain_text().replace('角色攻略', '').strip()
|
||||||
realname = get_id_by_alias(name)
|
realname = get_id_by_alias(name)
|
||||||
if not realname:
|
if name in ['风主', '岩主', '雷主'] or realname:
|
||||||
await guide.finish(f'没有找到{name}的攻略', at_sender=True)
|
name = realname[1][0] if name not in ['风主', '岩主', '雷主'] else name
|
||||||
elif realname[1][0] in ['八重神子', '神里绫华', '神里绫人', '温迪', '七七', '雷电将军']:
|
img = MessageSegment.image(file=f'https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon/XFGuide/{name}.jpg')
|
||||||
path = os.path.join(res_path, 'role_guide', f'{realname[1][0]}.png')
|
await guide.finish(img)
|
||||||
img = MessageSegment.image(file=Path(path))
|
|
||||||
await guide.finish(img, at_sender=True)
|
|
||||||
else:
|
else:
|
||||||
img = MessageSegment.image(file=f'https://adachi-bot.oss-cn-beijing.aliyuncs.com/Version2/guide/{realname[1][0]}.png')
|
await guide.finish(f'没有找到{name}的攻略', at_sender=True)
|
||||||
await guide.finish(img, at_sender=True)
|
|
||||||
|
|
||||||
|
|
||||||
@material.handle()
|
@material.handle()
|
||||||
@ -56,51 +51,40 @@ async def genshin_guide(event: MessageEvent):
|
|||||||
async def genshin_material(event: MessageEvent):
|
async def genshin_material(event: MessageEvent):
|
||||||
name: str = event.message.extract_plain_text().replace('角色材料', '').strip()
|
name: str = event.message.extract_plain_text().replace('角色材料', '').strip()
|
||||||
realname = get_id_by_alias(name)
|
realname = get_id_by_alias(name)
|
||||||
if name in ['夜兰', '久岐忍']:
|
if name in ['夜兰', '久岐忍'] or realname:
|
||||||
path = os.path.join(res_path, "role_material", f"{name}材料.png")
|
name = realname[1][0] if realname else name
|
||||||
img = MessageSegment.image(file=Path(path))
|
print(name)
|
||||||
await material.finish(img, at_sender=True)
|
img = MessageSegment.image(
|
||||||
elif not realname:
|
file=f'https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon/RoleMaterials/{name}材料.jpg')
|
||||||
await material.finish(f'没有找到{name}的材料', at_sender=True)
|
await material.finish(img)
|
||||||
else:
|
else:
|
||||||
path = os.path.join(res_path, 'role_material', f'{realname[1][0]}材料.png')
|
await material.finish(f'没有找到{name}的材料', at_sender=True)
|
||||||
img = MessageSegment.image(file=Path(path))
|
|
||||||
await material.finish(img, at_sender=True)
|
|
||||||
|
|
||||||
|
|
||||||
@attribute.handle()
|
@attribute.handle()
|
||||||
@exception_handler()
|
@exception_handler()
|
||||||
async def genshinAttribute(event: MessageEvent):
|
async def genshinAttribute(event: MessageEvent):
|
||||||
name: str = event.message.extract_plain_text().replace('参考面板', '').strip()
|
name: str = event.message.extract_plain_text().replace('参考面板', '').strip()
|
||||||
if name not in ['风主', '岩主', '雷主']:
|
realname = get_id_by_alias(name)
|
||||||
realname = get_id_by_alias(name)
|
if name in ['风主', '岩主', '雷主'] or realname:
|
||||||
if not realname:
|
name = realname[1][0] if name not in ['风主', '岩主', '雷主'] else name
|
||||||
await attribute.finish(f'没有找到{name}的参考面板', at_sender=True)
|
img = await get_blue_pic(name)
|
||||||
return
|
await attribute.finish(MessageSegment.image(file=img))
|
||||||
realname = realname[1][0]
|
|
||||||
else:
|
else:
|
||||||
realname = name
|
await attribute.finish(f'没有找到{name}的参考面板', at_sender=True)
|
||||||
pic_data = get_blue_pic(realname)
|
|
||||||
pic = Image.open(os.path.join(res_path, 'blue', f'{pic_data[0]}.jpg'))
|
|
||||||
pic = pic.crop((0, pic_data[1][0], 1080, pic_data[1][1]))
|
|
||||||
pic = pil2b64(pic, 85)
|
|
||||||
await attribute.finish(MessageSegment.image(pic), at_sender=True)
|
|
||||||
|
|
||||||
|
|
||||||
@attribute2.handle()
|
@attribute2.handle()
|
||||||
@exception_handler()
|
@exception_handler()
|
||||||
async def genshinAttribute2(event: MessageEvent):
|
async def genshinAttribute2(event: MessageEvent):
|
||||||
name: str = event.message.extract_plain_text().replace('收益曲线', '').strip()
|
name: str = event.message.extract_plain_text().replace('收益曲线', '').strip()
|
||||||
if name not in ['风主', '岩主', '雷主']:
|
realname = get_id_by_alias(name)
|
||||||
realname = get_id_by_alias(name)
|
if name in ['风主', '岩主', '雷主'] or realname:
|
||||||
if not realname:
|
name = realname[1][0] if name not in ['风主', '岩主', '雷主'] else name
|
||||||
await attribute2.finish(f'没有找到{name}的参考面板', at_sender=True)
|
img = MessageSegment.image(file=f'https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon/blue/{name}.jpg')
|
||||||
realname = realname[1][0]
|
await attribute2.finish(img)
|
||||||
else:
|
else:
|
||||||
realname = name
|
await attribute2.finish(f'没有找到{name}的收益曲线', at_sender=True)
|
||||||
pic = Image.open(os.path.join(res_path, 'blue', f'{realname}.png'))
|
|
||||||
pic = pil2b64(pic, 85)
|
|
||||||
await attribute2.finish(MessageSegment.image(pic), at_sender=True)
|
|
||||||
|
|
||||||
|
|
||||||
@daily_material.handle()
|
@daily_material.handle()
|
||||||
@ -127,12 +111,15 @@ async def daily_material_handle(event: MessageEvent):
|
|||||||
if week == "0":
|
if week == "0":
|
||||||
await daily_material.finish('周日所有材料都可以刷哦!', at_sender=True)
|
await daily_material.finish('周日所有材料都可以刷哦!', at_sender=True)
|
||||||
elif week in ['1', '4']:
|
elif week in ['1', '4']:
|
||||||
path = os.path.join(res_path, "daily_material", "周一周四.jpg")
|
img = MessageSegment.image(file='https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon'
|
||||||
|
'/DailyMaterials/周一周四.jpg')
|
||||||
elif week in ['2', '5']:
|
elif week in ['2', '5']:
|
||||||
path = os.path.join(res_path, "daily_material", "周二周五.jpg")
|
img = MessageSegment.image(file='https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon'
|
||||||
|
'/DailyMaterials/周二周五.jpg')
|
||||||
else:
|
else:
|
||||||
path = os.path.join(res_path, "daily_material", "周三周六.jpg")
|
img = MessageSegment.image(file='https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon'
|
||||||
await daily_material.finish(MessageSegment.image(file=Path(path)), at_sender=True)
|
'/DailyMaterials/周三周六.jpg')
|
||||||
|
await daily_material.finish(img)
|
||||||
|
|
||||||
|
|
||||||
@abyss_rate.handle()
|
@abyss_rate.handle()
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from ..utils.util import get_pic, pil2b64
|
||||||
|
|
||||||
blue = {
|
blue = {
|
||||||
'胡桃': ['火', (0, 1886)],
|
'胡桃': ['火', (0, 1886)],
|
||||||
'托马': ['火', (1886, 2420)],
|
'托马': ['火', (1886, 2420)],
|
||||||
@ -54,8 +56,11 @@ blue = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def get_blue_pic(name):
|
async def get_blue_pic(name):
|
||||||
for c in blue.items():
|
for c in blue.items():
|
||||||
if c[0] == name:
|
if c[0] == name:
|
||||||
return c[1]
|
img = await get_pic(f'https://cherishmoon.oss-cn-shenzhen.aliyuncs.com/LittlePaimon/blue/{c[1][0]}.jpg')
|
||||||
|
img = img.crop((0, c[1][1][0], 1080, c[1][1][1]))
|
||||||
|
img = pil2b64(img, 100)
|
||||||
|
return img
|
||||||
return None
|
return None
|
||||||
|
BIN
res/blue/七七.png
Before Width: | Height: | Size: 781 KiB |
BIN
res/blue/丽莎.png
Before Width: | Height: | Size: 826 KiB |
Before Width: | Height: | Size: 937 KiB |
BIN
res/blue/五郎.png
Before Width: | Height: | Size: 312 KiB |
BIN
res/blue/优菈.png
Before Width: | Height: | Size: 1.1 MiB |
BIN
res/blue/冰.jpg
Before Width: | Height: | Size: 2.0 MiB |
BIN
res/blue/凝光.png
Before Width: | Height: | Size: 869 KiB |
BIN
res/blue/凯亚.png
Before Width: | Height: | Size: 874 KiB |
BIN
res/blue/刻晴.png
Before Width: | Height: | Size: 816 KiB |
BIN
res/blue/北斗.png
Before Width: | Height: | Size: 822 KiB |
BIN
res/blue/可莉.png
Before Width: | Height: | Size: 792 KiB |
BIN
res/blue/安柏.png
Before Width: | Height: | Size: 819 KiB |
BIN
res/blue/宵宫.png
Before Width: | Height: | Size: 1.1 MiB |
BIN
res/blue/岩.jpg
Before Width: | Height: | Size: 1.9 MiB |
BIN
res/blue/岩主.png
Before Width: | Height: | Size: 934 KiB |
BIN
res/blue/早柚.png
Before Width: | Height: | Size: 641 KiB |
Before Width: | Height: | Size: 771 KiB |
BIN
res/blue/水.jpg
Before Width: | Height: | Size: 1.6 MiB |
BIN
res/blue/温迪.png
Before Width: | Height: | Size: 751 KiB |
BIN
res/blue/火.jpg
Before Width: | Height: | Size: 2.8 MiB |
BIN
res/blue/烟绯.png
Before Width: | Height: | Size: 858 KiB |
Before Width: | Height: | Size: 1.1 MiB |
BIN
res/blue/班尼特.png
Before Width: | Height: | Size: 756 KiB |
BIN
res/blue/琴.png
Before Width: | Height: | Size: 892 KiB |
BIN
res/blue/甘雨.png
Before Width: | Height: | Size: 871 KiB |
BIN
res/blue/砂糖.png
Before Width: | Height: | Size: 801 KiB |
Before Width: | Height: | Size: 1.3 MiB |
Before Width: | Height: | Size: 876 KiB |
BIN
res/blue/胡桃.png
Before Width: | Height: | Size: 773 KiB |
BIN
res/blue/芭芭拉.png
Before Width: | Height: | Size: 774 KiB |
Before Width: | Height: | Size: 1006 KiB |
BIN
res/blue/莫娜.png
Before Width: | Height: | Size: 744 KiB |
BIN
res/blue/菲谢尔.png
Before Width: | Height: | Size: 710 KiB |
BIN
res/blue/行秋.png
Before Width: | Height: | Size: 744 KiB |
BIN
res/blue/诺艾尔.png
Before Width: | Height: | Size: 818 KiB |
BIN
res/blue/辛焱.png
Before Width: | Height: | Size: 936 KiB |
Before Width: | Height: | Size: 775 KiB |
BIN
res/blue/迪卢克.png
Before Width: | Height: | Size: 891 KiB |
BIN
res/blue/迪奥娜.png
Before Width: | Height: | Size: 653 KiB |
BIN
res/blue/重云.png
Before Width: | Height: | Size: 818 KiB |
BIN
res/blue/钟离.png
Before Width: | Height: | Size: 987 KiB |
BIN
res/blue/阿贝多.png
Before Width: | Height: | Size: 1.0 MiB |
BIN
res/blue/雷.jpg
Before Width: | Height: | Size: 3.4 MiB |
BIN
res/blue/雷主.png
Before Width: | Height: | Size: 629 KiB |
BIN
res/blue/雷泽.png
Before Width: | Height: | Size: 847 KiB |
Before Width: | Height: | Size: 926 KiB |
BIN
res/blue/风.jpg
Before Width: | Height: | Size: 1.5 MiB |
BIN
res/blue/风主.png
Before Width: | Height: | Size: 629 KiB |
BIN
res/blue/香菱.png
Before Width: | Height: | Size: 728 KiB |
BIN
res/blue/魈.png
Before Width: | Height: | Size: 967 KiB |
Before Width: | Height: | Size: 156 KiB |
Before Width: | Height: | Size: 157 KiB |
Before Width: | Height: | Size: 165 KiB |
Before Width: | Height: | Size: 3.5 MiB |
Before Width: | Height: | Size: 4.2 MiB |
Before Width: | Height: | Size: 3.6 MiB |
Before Width: | Height: | Size: 3.6 MiB |
Before Width: | Height: | Size: 3.4 MiB |
Before Width: | Height: | Size: 3.8 MiB |
@ -1,9 +1,9 @@
|
|||||||
character_alias = {
|
character_alias = {
|
||||||
10000002: ['神里绫华', '绫华', '大小姐', '小乌龟', '白鹭公主', '0华', '神里', '神里妹'],
|
10000002: ['神里绫华', '绫华', '大小姐', '小乌龟', '白鹭公主', '0华', '神里', '神里妹', '凌华', '神里凌华'],
|
||||||
10000003: ['琴', '团长', '琴团长', '蒲公英骑士'],
|
10000003: ['琴', '团长', '琴团长', '蒲公英骑士'],
|
||||||
10000005: ['空', '空哥', '龙哥', '哥哥', '旅行者'],
|
10000005: ['空', '空哥', '龙哥', '哥哥', '旅行者', '主角'],
|
||||||
10000006: ['丽莎', '蔷薇魔女'],
|
10000006: ['丽莎', '蔷薇魔女'],
|
||||||
10000007: ['荧', '荧妹', '爷', '妹妹', '旅行者'],
|
10000007: ['荧', '荧妹', '爷', '妹妹', '旅行者', '主角'],
|
||||||
10000014: ['芭芭拉', '偶像', '内鬼', '牧师'],
|
10000014: ['芭芭拉', '偶像', '内鬼', '牧师'],
|
||||||
10000015: ['凯亚', '凝冰渡海真君', '矿工'],
|
10000015: ['凯亚', '凝冰渡海真君', '矿工'],
|
||||||
10000016: ['迪卢克', '卢姥爷', '姥爷', '老爷', '卢锅巴', '正义人', '正e人', '落魄人'],
|
10000016: ['迪卢克', '卢姥爷', '姥爷', '老爷', '卢锅巴', '正义人', '正e人', '落魄人'],
|
||||||
@ -47,7 +47,7 @@ character_alias = {
|
|||||||
10000062: ['埃洛伊'],
|
10000062: ['埃洛伊'],
|
||||||
10000063: ['申鹤', '小姨', '小姨妈'],
|
10000063: ['申鹤', '小姨', '小姨妈'],
|
||||||
10000064: ['云堇', '云先生'],
|
10000064: ['云堇', '云先生'],
|
||||||
10000066: ['神里绫人', '0人', '大舅子', '小舅子', '绫人', '神里哥']
|
10000066: ['神里绫人', '0人', '大舅子', '小舅子', '绫人', '神里哥', '凌人', '神里凌人']
|
||||||
}
|
}
|
||||||
short_name = {
|
short_name = {
|
||||||
'胡桃': '胡桃',
|
'胡桃': '胡桃',
|
||||||
|
@ -11,6 +11,7 @@ import functools
|
|||||||
import inspect
|
import inspect
|
||||||
import json
|
import json
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from PIL import Image
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from nonebot import get_bot
|
from nonebot import get_bot
|
||||||
@ -83,15 +84,15 @@ def exception_handler():
|
|||||||
await func(**kwargs)
|
await func(**kwargs)
|
||||||
except FinishedException:
|
except FinishedException:
|
||||||
raise
|
raise
|
||||||
except ActionFailed as e:
|
except ActionFailed:
|
||||||
logger.exception('账号可能被风控,消息发送失败')
|
logger.exception('账号可能被风控,消息发送失败')
|
||||||
await get_bot().send(event, f'派蒙可能被风控,消息发送失败,{e.info["wording"]}')
|
await get_bot().send(event, f'派蒙可能被风控,也可能是没有该图片资源,消息发送失败')
|
||||||
except JSONDecodeError:
|
except JSONDecodeError:
|
||||||
await get_bot().send(event, '派蒙获取信息失败,重试一下吧')
|
await get_bot().send(event, '派蒙获取信息失败,重试一下吧')
|
||||||
except IndexError or KeyError as e:
|
# except IndexError or KeyError as e:
|
||||||
await get_bot().send(event, f'派蒙获取信息失败,请确认参数无误,{e}')
|
# await get_bot().send(event, f'派蒙获取信息失败,请确认参数无误,{e}')
|
||||||
except TypeError or AttributeError as e:
|
# except TypeError or AttributeError as e:
|
||||||
await get_bot().send(event, f'派蒙好像没有该UID的绑定信息, {e}')
|
# await get_bot().send(event, f'派蒙好像没有该UID的绑定信息, {e}')
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
file_name = re.search(r'\'(.*)\'', str(e)).group(1)
|
file_name = re.search(r'\'(.*)\'', str(e)).group(1)
|
||||||
file_name = file_name.replace('\\\\', '/').split('/')
|
file_name = file_name.replace('\\\\', '/').split('/')
|
||||||
@ -137,6 +138,14 @@ class FreqLimiter2:
|
|||||||
return int(self.next_time[key1][key2] - time()) + 1
|
return int(self.next_time[key1][key2] - time()) + 1
|
||||||
|
|
||||||
|
|
||||||
|
async def get_pic(url):
|
||||||
|
async with ClientSession() as session:
|
||||||
|
res = await session.get(url)
|
||||||
|
res = await res.read()
|
||||||
|
img = Image.open(BytesIO(res))
|
||||||
|
return img
|
||||||
|
|
||||||
|
|
||||||
# 获取可用的cookie
|
# 获取可用的cookie
|
||||||
async def get_use_cookie(user_id, uid='', mys_id='', action=''):
|
async def get_use_cookie(user_id, uid='', mys_id='', action=''):
|
||||||
cache_cookie = await get_cookie_cache(uid, 'uid')
|
cache_cookie = await get_cookie_cache(uid, 'uid')
|
||||||
|