fix 原神日历

This commit is contained in:
CMHopeSunshine 2022-06-22 10:36:40 +08:00
parent 050d4f5598
commit 1c16196df4
4 changed files with 20 additions and 31 deletions

View File

@ -1,10 +1,10 @@
from nonebot import require, get_bot, on_command, logger
from nonebot import get_bot, on_command, logger
from nonebot.adapters.onebot.v11 import MessageEvent, Message, MessageSegment
from nonebot.params import CommandArg
from nonebot.plugin import PluginMetadata
from utils.file_handler import load_json, save_json
from utils.message_util import MessageBuild, get_message_id
from utils.message_util import get_message_id
from .generate import *
import re
@ -22,7 +22,7 @@ __plugin_meta__ = PluginMetadata(
'type': '原神Wiki',
'range': ['private', 'group', 'guild'],
"author": "nicklly <1134741727@qq.com>",
"version": "1.0.0",
"version": "1.0.1",
},
)

View File

@ -1,8 +1,8 @@
from PIL import Image, ImageDraw, ImageFont
import os
from pathlib import Path
font_Path = res_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'res')
font = ImageFont.truetype(os.path.join(res_path, 'wqy-microhei.ttc'), 20)
res_path = Path(__file__).parent.parent / 'res'
font = ImageFont.truetype(str(res_path / 'wqy-microhei.ttc'), 20)
width = 500

View File

@ -1,4 +1,4 @@
import os
from pathlib import Path
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
from utils.aiorequests import get
@ -8,8 +8,7 @@ import functools
import re
res = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'Paimon_Calendar/template')
res = Path(__file__).parent / 'template'
# type 0 普通常驻任务深渊 1 新闻 2 蛋池 3 限时活动H5
event_data = {
'cn': [],
@ -172,7 +171,7 @@ async def load_event_cn():
'forever': False,
'type': 3,
'color': '#580dda',
'banner': res + '/sy.jpg'
'banner': res / 'sy.jpg'
})
event_data['cn'].append({
'title': '「深境螺旋」· 下半段 ',
@ -181,7 +180,7 @@ async def load_event_cn():
'forever': False,
'type': 3,
'color': '#580dda',
'banner': res + '/sy.jpg'
'banner': res / 'sy.jpg'
})
i = i+1

View File

@ -1,6 +1,6 @@
import base64
from io import BytesIO
from nonebot import require
require("nonebot_plugin_htmlrender")
from nonebot_plugin_htmlrender import html_to_pic
import jinja2
@ -8,19 +8,11 @@ from .event import *
from .draw import *
body = []
template_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'Paimon_Calendar/template')
template_path = Path(__file__).parent / 'template'
env = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path), enable_async=True)
def im2base64str(im):
io = BytesIO()
im.save(io, 'png')
base64_str = f"base64://{base64.b64encode(io.getvalue()).decode()}"
return base64_str
async def generate_day_schedule(server='cn'):
events = await get_events(server, 0, 15)
has_prediction = False
""" 追加数据前先执行清除,以防数据叠加 """
@ -55,5 +47,3 @@ async def generate_day_schedule(server='cn'):
content = await template.render_async(body=body, css_path=template_path)
return await html_to_pic(content, wait=0, viewport={"width": 600, "height": 100})