2022-06-06 10:22:14 +00:00
|
|
|
|
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
|
2022-06-06 10:22:14 +00:00
|
|
|
|
from pagermaid.listener import listener
|
|
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
|
@listener(command="bin", description="查询信用卡信息", parameters="[bin(4到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("正在查询中...")
|
2022-06-06 10:22:14 +00:00
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
card_bin = int(message.arguments)
|
2022-06-06 10:22:14 +00:00
|
|
|
|
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}")
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
await message.edit("出错了呜呜呜 ~ 无法访问到 handyapi 。")
|
2022-06-06 10:22:14 +00:00
|
|
|
|
return
|
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
bin_json = r.json()
|
2022-06-06 10:22:14 +00:00
|
|
|
|
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
|
2022-06-06 10:22:14 +00:00
|
|
|
|
|
2022-06-14 07:54:55 +00:00
|
|
|
|
msg_out = [f"BIN:{card_bin}"]
|
2022-06-06 10:22:14 +00:00
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
msg_out.append("卡品牌:" + bin_json["Scheme"].lower())
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
pass
|
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
msg_out.append("卡类型:" + bin_json["Type"].lower())
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
pass
|
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
msg_out.append("卡种类:" + bin_json["CardTier"].lower())
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
pass
|
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
msg_out.append("发卡行:" + bin_json["Issuer"].lower())
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
pass
|
|
|
|
|
try:
|
2024-11-06 14:21:40 +00:00
|
|
|
|
msg_out.append("发卡国家:" + bin_json["Country"]["Name"])
|
2022-06-06 10:22:14 +00:00
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
pass
|
|
|
|
|
await message.edit("\n".join(msg_out))
|