forked from TeamPGM/PagerMaid_Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tel.py
30 lines (27 loc) · 1.1 KB
/
tel.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
import json
import sys, codecs
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
from requests import get
from pagermaid import version
from pagermaid.listener import listener
from pagermaid.utils import obtain_message, alias_command
@listener(outgoing=True, command=alias_command("tel"),
description="手机号码归属地等信息查询。")
async def tel(context):
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)
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']
await context.edit(res)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")