2022-06-07 14:51:55 +00:00
|
|
|
from pyrogram import Client
|
|
|
|
from json.decoder import JSONDecodeError
|
|
|
|
from pagermaid.listener import listener
|
|
|
|
from pagermaid.utils import Message, client
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(command="zhrs", description="知乎热搜。")
|
2022-06-07 14:51:55 +00:00
|
|
|
async def zhrs(_: Client, message: Message):
|
2022-06-07 15:00:19 +00:00
|
|
|
req = await client.get("https://tenapi.cn/zhihuresou/")
|
2022-06-07 14:51:55 +00:00
|
|
|
if req.status_code == 200:
|
|
|
|
try:
|
|
|
|
data = req.json()
|
|
|
|
except JSONDecodeError:
|
|
|
|
await message.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
|
|
|
return
|
2023-07-01 12:18:58 +00:00
|
|
|
res = "知乎实时热搜榜:\n"
|
2022-06-14 07:54:55 +00:00
|
|
|
for i in range(10):
|
2022-06-07 14:51:55 +00:00
|
|
|
res += f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["query"]}</a>」'
|
|
|
|
await message.edit(res)
|
|
|
|
else:
|
|
|
|
await message.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(command="wbrs", description="微博热搜。")
|
2022-06-07 14:51:55 +00:00
|
|
|
async def wbrs(_: Client, message: Message):
|
2022-06-07 15:00:19 +00:00
|
|
|
req = await client.get("https://tenapi.cn/resou/")
|
2022-06-07 14:51:55 +00:00
|
|
|
if req.status_code == 200:
|
|
|
|
try:
|
|
|
|
data = req.json()
|
|
|
|
except JSONDecodeError:
|
|
|
|
await message.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
|
|
|
return
|
2023-07-01 12:18:58 +00:00
|
|
|
res = "微博实时热搜榜:\n"
|
2022-06-14 07:54:55 +00:00
|
|
|
for i in range(10):
|
2023-07-01 12:18:58 +00:00
|
|
|
res += (
|
|
|
|
f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["name"]}</a>」 '
|
|
|
|
f'热度:{data["list"][i]["hot"]}'
|
|
|
|
)
|
2022-06-07 14:51:55 +00:00
|
|
|
await message.edit(res)
|
|
|
|
else:
|
|
|
|
await message.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
|
|
|
|
|
|
|
|
2023-07-01 12:18:58 +00:00
|
|
|
@listener(command="dyrs", description="抖音热搜。")
|
2022-06-07 14:51:55 +00:00
|
|
|
async def dyrs(_: Client, message: Message):
|
2022-06-07 15:00:19 +00:00
|
|
|
req = await client.get("https://tenapi.cn/douyinresou/")
|
2022-06-07 14:51:55 +00:00
|
|
|
if req.status_code == 200:
|
|
|
|
try:
|
|
|
|
data = req.json()
|
|
|
|
except JSONDecodeError:
|
|
|
|
await message.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
|
|
|
return
|
2023-07-01 12:18:58 +00:00
|
|
|
res = "抖音实时热搜榜:\n"
|
2022-06-14 07:54:55 +00:00
|
|
|
for i in range(10):
|
2022-06-07 14:51:55 +00:00
|
|
|
res += f'\n{i + 1}.「{data["list"][i]["name"]}」 热度:{data["list"][i]["hot"]}'
|
|
|
|
await message.edit(res)
|
|
|
|
else:
|
|
|
|
await message.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|