Giter Club home page Giter Club logo

nonebot-plugin-gachalogs's Introduction

Monst.x =^ω^=

Amateur developer writing junk code.

Information currently available

  • ⚙ Majoring in electrical engineering and automation.
  • 🍻 Love Japanese anime about love and fighting especially.
  • 📃 Like to browse and write blogs in my spare time.
  • 💩 Can write the most basic HTML code, not JavaScript.
  • 🎯 Looking forward to learning Node.js / Vue.js / PHP / Python etc.

Recently published articles

* See how this works in this article.

nonebot-plugin-gachalogs's People

Contributors

monsterxcn avatar pre-commit-ci[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

nonebot-plugin-gachalogs's Issues

关于生成 AuthKey 接口

您好,关于这个更新链接的功能我尝试在 ts 中实现,但是在生成 authKey 的地方遇到了难题,目前提示我 角色还未绑定通行证账号。请问您知道这是哪种原因造成的吗?

{
  "data": null,
  "message": "角色还未绑定通行证账号",
  "retcode": 1016
}

请求参数中的header信息,body 参数中也传入了 game_uid 等信息。

{
    "auth_appid": "webview_gacha",
    "game_biz": "hk4e_cn",
    "game_uid": 18******82,
    "region": "cn_gf01"
}
{
    accept: [ 'Accept', 'application/json, text/plain, */*' ],
    'content-type': [ 'Content-Type', 'application/json' ],
    cookie: [
      'cookie',
      '_MHYUUID=147da997-3189-4fb7-8dfc-cca4bd53b033; ltuid=28*****600; mi18nLang=zh-cn; DEVICEFP_SEED_ID=7e860152c2d12622; DEVICEFP_SEED_TIME=1660707891339; account_id=28*****600; _ga_75FBFDLZKM=GS1.1.1660707892.1.1.1660708662.0.0.0; DEVICEFP=38d7eb252c8cc; _ga=GA1.2.2030340896.1652349741; _ga_9TTX3TE5YL=GS1.1.1663422069.9.1.1663423171.0.0.0; _gid=GA1.2.582532231.1663514587; ltoken=fI2euI****************oSAPfi3M; cookie_token=BAG***********************4jFFm; login_uid=28*****600; login_ticket=Kh****************4qISXaG7BeJi;stuid=28*****600;stoken=CSi******************o7o2gXnlDqvCAmrcJ'
    ],
    ds: [ 'ds', '1663598803,Pwvz5Y,fb71762d8fdd7a545fe71df1c9825422' ],
    host: [ 'host', 'api-takumi.mihoyo.com' ],
    referer: [ 'referer', 'https://app.mihoyo.com' ],
    'user-agent': [ 'user-agent', 'okhttp/4.8.0' ],
    'x-rpc-app_version': [ 'x-rpc-app_version', '2.28.1' ],
    'x-rpc-channel': [ 'x-rpc-channel', 'mihoyo' ],
    'x-rpc-client_type': [ 'x-rpc-client_type', '2' ],
    'x-rpc-device_id': [ 'x-rpc-device_id', '21eae5b6-bb97-4bc6-a4ef-180f607e2374' ],
    'x-rpc-device_model': [ 'x-rpc-device_model', 'SM-977N' ],
    'x-rpc-device_name': [ 'x-rpc-device_name', 'Samsung SM-G977N' ],
    'x-rpc-sys_version': [ 'x-rpc-sys_version', '12' ],
    'content-length': [ 'Content-Length', 97 ]
  }

功能改进

  • 抽卡记录导入 完成于 4604c89
  • 限定五星标记 完成于 e9afaf9
  • 限定五星花费分析 完成于 e9afaf9
  • 卡池运势标记 完成于 6ace13e
  • 出货之最分析 完成于 e9afaf9
  • 物品图片绘制
  • 抽卡成就 完成于 0f27711
  • 适配 UIGF v2.3 完成于 68ca1d2

* 欢迎在此 issue 下方提出功能改进建议,尽可能实现,感谢喵💕

尚不明晰成因的饼图黑底问题

已经有两位朋友出现绘图结果中饼图为黑底的情况了,如下图:

Q`G9 ~)G8R_MW}JI7Q8Y81M

我尚不清楚这是哪里导致的问题,在自己的 Windows、Linux 上尝试多次均未能复现,因此修复仍需时日。

饼图是由 matplotlib 绘制的,画完之后仅利用 pillow 进行了简单的裁剪、缩放、粘贴处理,我不理解何处会导致此问题。

欢迎在此 issue 下回复任何你认为对解决此问题有帮助的信息,感谢!有条件的话也欢迎测试下面代码在问题机器上的效果:

测试代码
import asyncio
from base64 import b64encode
from io import BytesIO
from typing import Dict, Literal, Tuple, Union

import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
from PIL import Image

PIE_FONT = "/home/ubuntu/Service/nonebot/data/gachalogs/LXGW-Bold-minipie.ttf"  # 修改此处为自己的字体路径
stat = {
    "total": 1266,
    "cntNot5": 8,
    "cntStar3": 1068,
    "cntChar4": 123,
    "cntWeapon4": 55,
    "cntChar5": 20,
    "cntWeapon5": 0,
}


# https://github.com/monsterxcn/nonebot-plugin-gachalogs/blob/c231ab667872b10789e7f12afa6f4707dbb41b20/nonebot_plugin_gachalogs/data_render.py#L291-L344
async def drawPie(
    stat: Dict, rt: Literal["base64", "image"] = "base64"
) -> Tuple[Union[str, Image.Image], bool]:
    """
    单个饼图绘制

    * ``param stat: Dict`` 统计数据,由 ``calcStat()`` 生成
    * ``param rt: Literal["base64", "image"] = "base64"`` 返回结果类型,默认为 Base64 编码字符串,传入 ``image`` 则返回 ``PIL.Image.Image`` 对象
    - ``return: Tuple[Union[str, Image.Image], bool]`` 返回结果、是否展示三星物品数据
    """
    partMap = [
        {"label": "三星武器", "color": "#73c0de", "total": stat["cntStar3"]},
        {"label": "四星武器", "color": "#91cc75", "total": stat["cntWeapon4"]},
        {"label": "四星角色", "color": "#5470c6", "total": stat["cntChar4"]},
        {"label": "五星武器", "color": "#ee6666", "total": stat["cntWeapon5"]},
        {"label": "五星角色", "color": "#fac858", "total": stat["cntChar5"]},
    ]
    # 如果可显示项目多于 4 项,考虑隐藏三星数据
    showStar3 = True
    if len([p for p in partMap if p["total"]]) > 4:
        partMap = [p for p in partMap if p["label"] != "三星武器"]
        showStar3 = False
    # 提取数据
    labels = [p["label"] for p in partMap if p["total"]]
    colors = [p["color"] for p in partMap if p["total"]]
    sizes = [p["total"] for p in partMap if p["total"]]
    explode = [(0.05 if "五星" in p["label"] else 0) for p in partMap if p["total"]]
    # 绘制饼图
    textprops = {"fontproperties": fm.FontProperties(fname=PIE_FONT, size=18)}  # type: ignore
    fig, ax = plt.subplots()
    fig.set_facecolor("#f9f9f9")  # 这里应该可以任意调整图片底色
    ax.set_facecolor("#f9f9f9")
    ax.pie(
        sizes,
        labels=labels,
        colors=colors,
        autopct="%0.2f%%",
        labeldistance=1.1,
        pctdistance=0.7,
        startangle=60,
        radius=0.7,
        explode=explode,
        shadow=False,
        textprops=textprops,
    )
    ax.axis("equal")
    # 生成图片
    ioBytes = BytesIO()
    plt.savefig(ioBytes, format="png")
    ioBytes.seek(0)
    Image.open(ioBytes).convert("RGBA").save("pie.png")
    if rt == "base64":
        b64Code = b64encode(ioBytes.read()).decode()
        return b64Code, showStar3
    else:
        return Image.open(ioBytes), showStar3


asyncio.run(drawPie(stat, "image"))

感谢 @AquamarineCyan 已经帮我测试了几遍,但似乎单独拎出来测都没问题,一旦在 Bot 插件内运行就会出问题:在 data_render.py L340 附近与测试代码一样,手动加一条 Image.open(ioBytes).convert("RGBA").save("pie.png"),随后保存出来的图片便为黑底图片。

F7DM3T1$)BAJESTOW%KG@X

😫那咋回事呀..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.