mirror of
https://github.com/TeamPGM/PagerMaid_Plugins_Pyro.git
synced 2024-11-25 18:15:26 +00:00
tel 修复 API
This commit is contained in:
parent
df0f55f73a
commit
36b0ad7627
56
tel/main.py
56
tel/main.py
@ -1,42 +1,26 @@
|
|||||||
import json
|
from pagermaid.enums import AsyncClient
|
||||||
import sys, codecs
|
|
||||||
|
|
||||||
sys.stdout = codecs.getwriter("utf-8")(sys.stdout.detach())
|
|
||||||
from requests import get
|
|
||||||
from pyrogram import Client
|
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from pagermaid.utils import Message
|
from pagermaid.utils import Message
|
||||||
|
|
||||||
|
|
||||||
@listener(command="tel",
|
@listener(command="tel", description="手机号码归属地等信息查询。")
|
||||||
description="手机号码归属地等信息查询。")
|
async def tel(message: Message, request: AsyncClient):
|
||||||
async def tel(_: Client, context: Message):
|
if not (phone := message.arguments.strip()).isnumeric():
|
||||||
await context.edit("获取中 . . .")
|
return await message.edit("出错了呜呜呜 ~ 无效的参数。")
|
||||||
try:
|
message = await message.edit("获取中 . . .") # type: ignore
|
||||||
message = context.arguments
|
res = await request.post("https://tenapi.cn/v2/phone", params={"tel": phone})
|
||||||
except ValueError:
|
data = None
|
||||||
await context.edit("出错了呜呜呜 ~ 无效的参数。")
|
if res.is_success and (data := res.json())["code"] == 200:
|
||||||
return
|
data = data["data"]
|
||||||
req = get(f"https://tenapi.cn/tel?tel={message}")
|
await message.edit(
|
||||||
if req.status_code == 200:
|
f"查询目标: {phone}\n"
|
||||||
data = json.loads(req.text)
|
f"地区: {data['local']}\n"
|
||||||
res = (
|
f"号段: {data['num']}\n"
|
||||||
data['msg']
|
f"卡类型: {data['type']}\n"
|
||||||
if 'msg' in data
|
f"运营商: {data['isp']}\n"
|
||||||
else '电话号码:'
|
f"通信标准: {data['std']}"
|
||||||
+ str(data['tel'])
|
|
||||||
+ '\n'
|
|
||||||
+ str(data['local'])
|
|
||||||
+ '\n'
|
|
||||||
+ str(data['duan'])
|
|
||||||
+ '\n'
|
|
||||||
+ str(data['type'])
|
|
||||||
+ '\n'
|
|
||||||
+ str(data['yys'])
|
|
||||||
+ '\n'
|
|
||||||
+ str(data['bz'])
|
|
||||||
)
|
)
|
||||||
|
|
||||||
await context.edit(res)
|
|
||||||
else:
|
else:
|
||||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
await message.edit(
|
||||||
|
"出错了呜呜呜 ~ API 服务器返回了错误。" + ("\n" + data.get("msg") if data else "")
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user