-
Notifications
You must be signed in to change notification settings - Fork 33
/
bin.py
66 lines (62 loc) · 2.09 KB
/
bin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import json
import requests
from json.decoder import JSONDecodeError
from pagermaid import version
from pagermaid.listener import listener
from pagermaid.utils import obtain_message, alias_command
@listener(is_plugin=True, outgoing=True, command=alias_command("bin"),
description="查询信用卡信息",
parameters="<bin(4到8位数字)>")
async def card(context):
await context.edit('正在查询中...')
try:
card_bin = await obtain_message(context)
except ValueError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
try:
r = requests.get("https://lookup.binlist.net/" + card_bin)
except:
await context.edit("出错了呜呜呜 ~ 无法访问到binlist。")
return
if r.status_code == 404:
await context.edit("出错了呜呜呜 ~ 目标卡头不存在")
return
if r.status_code == 429:
await context.edit("出错了呜呜呜 ~ 每分钟限额超过,请等待一分钟再试")
return
try:
bin_json = json.loads(r.content.decode("utf-8"))
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ 无效的参数。")
return
msg_out = []
msg_out.extend(["BIN:" + card_bin])
try:
msg_out.extend(["卡品牌:" + bin_json['scheme']])
except (KeyError, TypeError):
pass
try:
msg_out.extend(["卡类型:" + bin_json['type']])
except (KeyError, TypeError):
pass
try:
msg_out.extend(["卡种类:" + bin_json['brand']])
except (KeyError, TypeError):
pass
try:
msg_out.extend(["发卡行:" + bin_json['bank']["name"]])
except (KeyError, TypeError):
pass
try:
if bin_json['prepaid']:
msg_out.extend(["是否预付:是"])
else:
msg_out.extend(["是否预付:否"])
except (KeyError, TypeError):
pass
try:
msg_out.extend(["发卡国家:" + bin_json['country']['name']])
except (KeyError, TypeError):
pass
await context.edit("\n".join(msg_out))