PagerMaid_Plugins_Pyro/bin/main.py

52 lines
1.6 KiB
Python
Raw Permalink Normal View History

from json.decoder import JSONDecodeError
2024-09-28 14:35:08 +00:00
2024-11-06 14:21:40 +00:00
from pagermaid.enums import Message, AsyncClient
from pagermaid.listener import listener
2023-07-01 12:18:58 +00:00
@listener(command="bin", description="查询信用卡信息", parameters="[bin4到8位数字]")
2024-11-06 14:21:40 +00:00
async def card(request: AsyncClient, message: Message):
2023-07-01 12:18:58 +00:00
await message.edit("正在查询中...")
try:
2024-11-06 14:21:40 +00:00
card_bin = int(message.arguments)
except ValueError:
await message.edit("出错了呜呜呜 ~ 无效的参数。")
return
try:
2024-11-06 14:21:40 +00:00
r = await request.get(f"https://data.handyapi.com/bin/{card_bin}")
except:
2024-11-06 14:21:40 +00:00
await message.edit("出错了呜呜呜 ~ 无法访问到 handyapi 。")
return
try:
2024-11-06 14:21:40 +00:00
bin_json = r.json()
except JSONDecodeError:
await message.edit("出错了呜呜呜 ~ 无效的参数。")
return
2024-11-06 14:21:40 +00:00
status = bin_json.get("Status")
if status != "SUCCESS":
await message.edit("出错了呜呜呜 ~ 无效的 bin 。")
return
msg_out = [f"BIN{card_bin}"]
try:
2024-11-06 14:21:40 +00:00
msg_out.append("卡品牌:" + bin_json["Scheme"].lower())
except (KeyError, TypeError):
pass
try:
2024-11-06 14:21:40 +00:00
msg_out.append("卡类型:" + bin_json["Type"].lower())
except (KeyError, TypeError):
pass
try:
2024-11-06 14:21:40 +00:00
msg_out.append("卡种类:" + bin_json["CardTier"].lower())
except (KeyError, TypeError):
pass
try:
2024-11-06 14:21:40 +00:00
msg_out.append("发卡行:" + bin_json["Issuer"].lower())
except (KeyError, TypeError):
pass
try:
2024-11-06 14:21:40 +00:00
msg_out.append("发卡国家:" + bin_json["Country"]["Name"])
except (KeyError, TypeError):
pass
await message.edit("\n".join(msg_out))