mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-10-21 16:27:15 +08:00
fix 原神日历
This commit is contained in:
parent
050d4f5598
commit
1c16196df4
@ -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.adapters.onebot.v11 import MessageEvent, Message, MessageSegment
|
||||||
from nonebot.params import CommandArg
|
from nonebot.params import CommandArg
|
||||||
from nonebot.plugin import PluginMetadata
|
from nonebot.plugin import PluginMetadata
|
||||||
|
|
||||||
from utils.file_handler import load_json, save_json
|
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 *
|
from .generate import *
|
||||||
import re
|
import re
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
'type': '原神Wiki',
|
'type': '原神Wiki',
|
||||||
'range': ['private', 'group', 'guild'],
|
'range': ['private', 'group', 'guild'],
|
||||||
"author": "nicklly <1134741727@qq.com>",
|
"author": "nicklly <1134741727@qq.com>",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -79,7 +79,7 @@ async def _(event: MessageEvent, msg: Message = CommandArg()):
|
|||||||
|
|
||||||
if not msg:
|
if not msg:
|
||||||
im = await generate_day_schedule(server)
|
im = await generate_day_schedule(server)
|
||||||
await calendar.finish( MessageSegment.image(im))
|
await calendar.finish(MessageSegment.image(im))
|
||||||
else:
|
else:
|
||||||
push_data = load_json('calender_push.json')
|
push_data = load_json('calender_push.json')
|
||||||
if msg.startswith(('开启', 'on', '打开')):
|
if msg.startswith(('开启', 'on', '打开')):
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
from PIL import Image, ImageDraw, ImageFont
|
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')
|
res_path = Path(__file__).parent.parent / 'res'
|
||||||
font = ImageFont.truetype(os.path.join(res_path, 'wqy-microhei.ttc'), 20)
|
font = ImageFont.truetype(str(res_path / 'wqy-microhei.ttc'), 20)
|
||||||
|
|
||||||
width = 500
|
width = 500
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import os
|
from pathlib import Path
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from utils.aiorequests import get
|
from utils.aiorequests import get
|
||||||
@ -8,8 +8,7 @@ import functools
|
|||||||
import re
|
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
|
# type 0 普通常驻任务深渊 1 新闻 2 蛋池 3 限时活动H5
|
||||||
event_data = {
|
event_data = {
|
||||||
'cn': [],
|
'cn': [],
|
||||||
@ -172,7 +171,7 @@ async def load_event_cn():
|
|||||||
'forever': False,
|
'forever': False,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'color': '#580dda',
|
'color': '#580dda',
|
||||||
'banner': res + '/sy.jpg'
|
'banner': res / 'sy.jpg'
|
||||||
})
|
})
|
||||||
event_data['cn'].append({
|
event_data['cn'].append({
|
||||||
'title': '「深境螺旋」· 下半段 ',
|
'title': '「深境螺旋」· 下半段 ',
|
||||||
@ -181,7 +180,7 @@ async def load_event_cn():
|
|||||||
'forever': False,
|
'forever': False,
|
||||||
'type': 3,
|
'type': 3,
|
||||||
'color': '#580dda',
|
'color': '#580dda',
|
||||||
'banner': res + '/sy.jpg'
|
'banner': res / 'sy.jpg'
|
||||||
})
|
})
|
||||||
i = i+1
|
i = i+1
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import base64
|
from nonebot import require
|
||||||
from io import BytesIO
|
|
||||||
|
|
||||||
|
require("nonebot_plugin_htmlrender")
|
||||||
from nonebot_plugin_htmlrender import html_to_pic
|
from nonebot_plugin_htmlrender import html_to_pic
|
||||||
import jinja2
|
import jinja2
|
||||||
|
|
||||||
@ -8,19 +8,11 @@ from .event import *
|
|||||||
from .draw import *
|
from .draw import *
|
||||||
|
|
||||||
body = []
|
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)
|
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'):
|
async def generate_day_schedule(server='cn'):
|
||||||
|
|
||||||
events = await get_events(server, 0, 15)
|
events = await get_events(server, 0, 15)
|
||||||
has_prediction = False
|
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)
|
content = await template.render_async(body=body, css_path=template_path)
|
||||||
return await html_to_pic(content, wait=0, viewport={"width": 600, "height": 100})
|
return await html_to_pic(content, wait=0, viewport={"width": 600, "height": 100})
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user