diff --git a/bin.py b/bin.py new file mode 100644 index 0000000..03ae9c8 --- /dev/null +++ b/bin.py @@ -0,0 +1,58 @@ +import json, requests +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="") +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 + + bin_json = json.loads(r.content.decode("utf-8")) + + msg_out = [] + msg_out.extend(["BIN:" + card_bin]) + try: + msg_out.extend(["卡品牌:" + bin_json['scheme']]) + except KeyError: + pass + try: + msg_out.extend(["卡类型:" + bin_json['type']]) + except KeyError: + pass + try: + msg_out.extend(["卡种类:" + bin_json['brand']]) + except KeyError: + pass + try: + msg_out.extend(["发卡行:" + bin_json['bank']["name"]]) + except KeyError: + pass + try: + if bin_json['prepaid']: + msg_out.extend(["是否预付:是"]) + else: + msg_out.extend(["是否预付:否"]) + except KeyError: + pass + try: + msg_out.extend(["发卡国家:" + bin_json['country']['name']]) + except KeyError: + pass + await context.edit("\n".join(msg_out)) diff --git a/list.json b/list.json index e93bd48..58e185a 100644 --- a/list.json +++ b/list.json @@ -579,6 +579,16 @@ "supported": true, "des-short": "列出群组中所有潜水超过 n 天的管理员。", "des": "列出群组中所有潜水超过 n 天的管理员。(n>=7)。命令:fuckadmin 。" + }, + { + "name": "bin", + "version": "1.0", + "section": "daily", + "maintainer": "paulkm", + "size": "1.8 kb", + "supported": true, + "des-short": "查询信用卡bin信息。", + "des": "使用binlist api查询,1分钟限额10次否则报错。使用方法:-bin xxx (xxx为信用卡卡号前4-8位,推荐6位)" } ] }