forked from a-fruity-melon/PagerMaid_Plugins
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathresou.py
83 lines (75 loc) · 3.31 KB
/
resou.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import json
from requests import get
from json.decoder import JSONDecodeError
from pagermaid import version
from pagermaid.listener import listener
@listener(is_plugin=True, outgoing=True, command="zhrs",
description="知乎热搜。")
async def zhrs(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/zhihuresou")
if req.status_code == 200:
try:
data = json.loads(req.text)
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
return
res = '知乎实时热搜榜:\n'
for i in range(0, 10):
res += f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["query"]}</a>」'
await context.edit(res, parse_mode='html', link_preview=False)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
@listener(is_plugin=True, outgoing=True, command="wbrs",
description="微博热搜。")
async def wbrs(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/resou")
if req.status_code == 200:
try:
data = json.loads(req.text)
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
return
res = '微博实时热搜榜:\n'
for i in range(0, 10):
res += f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["name"]}</a>」 ' \
f'热度:{data["list"][i]["hot"]}'
await context.edit(res, parse_mode='html', link_preview=True)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
@listener(is_plugin=True, outgoing=True, command="dyrs",
description="抖音热搜。")
async def dyrs(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/douyinresou")
if req.status_code == 200:
try:
data = json.loads(req.text)
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
return
res = '抖音实时热搜榜:\n'
for i in range(0, 10):
res += f'\n{i + 1}.「{data["list"][i]["name"]}」 热度:{data["list"][i]["hot"]}'
await context.edit(res, parse_mode='html', link_preview=True)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
@listener(is_plugin=True, outgoing=True, command="brank",
description="B站排行榜。")
async def brank(context):
await context.edit("获取中 . . .")
req = get("https://api.imjad.cn/bilibili/v2/?get=rank&type=all")
if req.status_code == 200:
try:
data = json.loads(req.content)['rank']['list']
except JSONDecodeError:
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
return
res = 'B站实时排行榜:\n'
for i in range(0, 10):
res += f'\n{i + 1}.「<a href="https://www.bilibili.com/video/{data[i]["bvid"]}">{data[i]["title"]}</a>」 - ' \
f'{data[i]["author"]}'
await context.edit(res, parse_mode='html', link_preview=False)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")