Skip to content

Commit

Permalink
Merge pull request #40 from lenlino/change-api
Browse files Browse the repository at this point in the history
完成
  • Loading branch information
lenlino authored Dec 28, 2023
2 parents 5fcae55 + c3ab048 commit 4bdc4e0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
21 changes: 16 additions & 5 deletions commands/CardCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,20 @@ async def button_callback(interaction):
is_hideUID=is_uid_hide
, calculating_standard=calculation_value, lang=lang,
is_hide_roll=is_roll_hide)
#image_binary.write(panel_img_result['img'])
panel_img = panel_img_result['img']
panel_img.save(image_binary, 'PNG')
if "detail" in panel_img_result:
res_embed = discord.Embed(
title=f"Error",
description=panel_img_result["detail"],
color=discord.Colour.red(),
)
await interaction.followup.send(embed=res_embed)
generate_button.label = i18n.t('message.generate', locale=lang)
generate_button.disabled = False
await set_uid(uid)
return
image_binary.write(panel_img_result['img'])
#panel_img = panel_img_result['img']
#panel_img.save(image_binary, 'PNG')
image_binary.seek(0)
dt_now = datetime.datetime.now()
file = discord.File(image_binary, f"hertacardsys_{dt_now.strftime('%Y%m%d%H%M')}.png")
Expand All @@ -126,8 +137,8 @@ async def button_callback(interaction):
weight_text += f"{i18n.t(f'message.{k}', locale=lang)}: {v}\n"
res_embed.add_field(name=i18n.t(f'message.weight', locale=lang), value=weight_text)

#score_rank = panel_img_result["header"]
score_rank = generate.utils.get_score_rank(int(avatar_id), uid, panel_img_result['score'])
score_rank = panel_img_result["header"]
#score_rank = generate.utils.get_score_rank(int(avatar_id), uid, panel_img_result['score'])
# 統計
rank_text = ""
rank_text += f"{i18n.t('message.Rank', locale=lang)}: {score_rank['rank']} / {score_rank['data_count']}\n"
Expand Down
5 changes: 3 additions & 2 deletions generate/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

async def generate_panel(uid="805477392", chara_id=1, template=1, is_hideUID=False, calculating_standard="compatibility", lang="jp", is_hide_roll=False):
result_json = {}
'''async with aiohttp.ClientSession(connector_owner=False, connector=conn) as session:
async with aiohttp.ClientSession(connector_owner=False, connector=conn) as session:
async with session.get(f"https://hcs.lenlino.com/gen_card/{uid}?lang={lang}&select_number={chara_id}&calculation_value={calculating_standard}"
f"&is_uid_hide={is_hideUID}&is_hide_roll={is_hide_roll}") as response:

Expand All @@ -28,7 +28,8 @@ async def generate_panel(uid="805477392", chara_id=1, template=1, is_hideUID=Fal
"data_count": response.headers.get("x-data-count")}
return result_json
else:
result_json["detail"] = response.status'''
result_json["detail"] = response.status
return result_json

if template == 1:
return await one.generate_panel(uid=uid, chara_id=chara_id, is_hideUID=is_hideUID, calculating_standard=calculating_standard)
Expand Down

0 comments on commit 4bdc4e0

Please sign in to comment.