2020-08-12 18:36:51 +00:00
|
|
|
import json
|
2021-06-16 07:09:40 +00:00
|
|
|
import sys, codecs
|
|
|
|
|
2020-08-12 18:36:51 +00:00
|
|
|
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
|
|
|
|
from requests import get
|
2022-01-18 08:47:20 +00:00
|
|
|
from pagermaid import version
|
2020-08-12 18:36:51 +00:00
|
|
|
from pagermaid.listener import listener
|
2021-06-16 07:09:40 +00:00
|
|
|
from pagermaid.utils import obtain_message, alias_command
|
|
|
|
|
2020-08-12 18:36:51 +00:00
|
|
|
|
2021-06-16 07:09:40 +00:00
|
|
|
@listener(outgoing=True, command=alias_command("tel"),
|
2020-08-12 18:36:51 +00:00
|
|
|
description="手机号码归属地等信息查询。")
|
2020-08-13 01:58:11 +00:00
|
|
|
async def tel(context):
|
2020-08-12 18:36:51 +00:00
|
|
|
await context.edit("获取中 . . .")
|
|
|
|
try:
|
|
|
|
message = await obtain_message(context)
|
|
|
|
except ValueError:
|
|
|
|
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
|
|
|
return
|
|
|
|
req = get("https://tenapi.cn/tel?tel=" + message)
|
|
|
|
if req.status_code == 200:
|
|
|
|
data = json.loads(req.text)
|
2020-08-13 01:58:11 +00:00
|
|
|
if not 'msg' in data:
|
|
|
|
res = '电话号码:' + str(data['tel']) + '\n' + str(data['local']) + '\n' + str(data['duan']) + '\n' + str(
|
|
|
|
data['type']) + '\n' + str(data['yys']) + '\n' + str(data['bz'])
|
|
|
|
else:
|
|
|
|
res = data['msg']
|
2020-08-12 18:36:51 +00:00
|
|
|
await context.edit(res)
|
|
|
|
else:
|
|
|
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|