mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-25 07:46:33 +00:00
* resou fix #171 * ⚡️ 使用循环优化代码 Co-authored-by: monsterxcn <monsterxcn@gmail.com>
This commit is contained in:
parent
67ac0fe0f0
commit
1cc3a12f6d
@ -162,9 +162,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "resou",
|
"name": "resou",
|
||||||
"version": "1.21",
|
"version": "1.22",
|
||||||
"section": "daily",
|
"section": "daily",
|
||||||
"maintainer": "KorenKrita、xtaodada",
|
"maintainer": "KorenKrita、xtaodada、monsterxcn",
|
||||||
"size": "6.1 kb",
|
"size": "6.1 kb",
|
||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "微博,知乎,抖音实时热搜,B站实时排行榜。",
|
"des-short": "微博,知乎,抖音实时热搜,B站实时排行榜。",
|
||||||
|
87
resou.py
87
resou.py
@ -1,27 +1,24 @@
|
|||||||
import json
|
import json
|
||||||
from requests import get
|
from requests import get
|
||||||
|
from json.decoder import JSONDecodeError
|
||||||
from pagermaid.listener import listener
|
from pagermaid.listener import listener
|
||||||
from pagermaid.utils import alias_command
|
from pagermaid.utils import alias_command
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=True, outgoing=True, command=alias_command("zhrs"),
|
@listener(is_plugin=True, outgoing=True, command=alias_command("zhrs"),
|
||||||
description="知乎热搜。")
|
description="知乎热搜。")
|
||||||
async def netease(context):
|
async def zhrs(context):
|
||||||
await context.edit("获取中 . . .")
|
await context.edit("获取中 . . .")
|
||||||
req = get("https://tenapi.cn/zhihuresou")
|
req = get("https://tenapi.cn/zhihuresou")
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
data = json.loads(req.text)
|
try:
|
||||||
res = '知乎实时热搜榜:' + '\n\n1.' + '「<a href=' + data['list']['1']['url'] + '>' + data['list']['1'][
|
data = json.loads(req.text)
|
||||||
'query'] + '</a>」' + '\n2.' + '「<a href=' + data['list']['2']['url'] + '>' + data['list']['2'][
|
except JSONDecodeError:
|
||||||
'query'] + '</a>」' + '\n3.' + '「<a href=' + data['list']['3']['url'] + '>' + data['list']['3'][
|
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
||||||
'query'] + '</a>」' + '\n4.' + '「<a href=' + data['list']['4']['url'] + '>' + data['list']['4'][
|
return
|
||||||
'query'] + '</a>」' + '\n5.' + '「<a href=' + data['list']['5']['url'] + '>' + data['list']['5'][
|
res = '知乎实时热搜榜:\n'
|
||||||
'query'] + '</a>」' + '\n6.' + '「<a href=' + data['list']['6']['url'] + '>' + data['list']['6'][
|
for i in range(0, 10):
|
||||||
'query'] + '</a>」' + '\n7.' + '「<a href=' + data['list']['7']['url'] + '>' + data['list']['7'][
|
res += f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["query"]}</a>」'
|
||||||
'query'] + '</a>」' + '\n8.' + '「<a href=' + data['list']['8']['url'] + '>' + data['list']['8'][
|
|
||||||
'query'] + '</a>」' + '\n9.' + '「<a href=' + data['list']['9']['url'] + '>' + data['list']['9'][
|
|
||||||
'query'] + '</a>」' + '\n10.' + '「<a href=' + data['list']['10']['url'] + '>' + data['list']['10'][
|
|
||||||
'query'] + '</a>」'
|
|
||||||
await context.edit(res, parse_mode='html', link_preview=False)
|
await context.edit(res, parse_mode='html', link_preview=False)
|
||||||
else:
|
else:
|
||||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
||||||
@ -29,26 +26,19 @@ async def netease(context):
|
|||||||
|
|
||||||
@listener(is_plugin=True, outgoing=True, command=alias_command("wbrs"),
|
@listener(is_plugin=True, outgoing=True, command=alias_command("wbrs"),
|
||||||
description="微博热搜。")
|
description="微博热搜。")
|
||||||
async def netease(context):
|
async def wbrs(context):
|
||||||
await context.edit("获取中 . . .")
|
await context.edit("获取中 . . .")
|
||||||
req = get("https://tenapi.cn/resou")
|
req = get("https://tenapi.cn/resou")
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
data = json.loads(req.text)
|
try:
|
||||||
res = '微博实时热搜榜:' + '\n\n1.' + '「<a href=' + data['list']['1']['url'] + '>' + data['list']['1'][
|
data = json.loads(req.text)
|
||||||
'name'] + '</a>」' + ' 热度:' + data['list']['1']['hot'] + '\n2.' + '「<a href=' + data['list']['2'][
|
except JSONDecodeError:
|
||||||
'url'] + '>' + data['list']['2']['name'] + '</a>」' + ' 热度:' + data['list']['2'][
|
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
||||||
'hot'] + '\n3.' + '「<a href=' + data['list']['3']['url'] + '>' + data['list']['3'][
|
return
|
||||||
'name'] + '</a>」' + ' 热度:' + data['list']['3']['hot'] + '\n4.' + '「<a href=' + data['list']['4'][
|
res = '微博实时热搜榜:\n'
|
||||||
'url'] + '>' + data['list']['4']['name'] + '</a>」' + ' 热度:' + data['list']['4'][
|
for i in range(0, 10):
|
||||||
'hot'] + '\n5.' + '「<a href=' + data['list']['5']['url'] + '>' + data['list']['5'][
|
res += f'\n{i + 1}.「<a href={data["list"][i]["url"]}>{data["list"][i]["name"]}</a>」 ' \
|
||||||
'name'] + '</a>」' + ' 热度:' + data['list']['5']['hot'] + '\n6.' + '「<a href=' + data['list']['6'][
|
f'热度:{data["list"][i]["hot"]}'
|
||||||
'url'] + '>' + data['list']['6']['name'] + '</a>」' + ' 热度:' + data['list']['6'][
|
|
||||||
'hot'] + '\n7.' + '「<a href=' + data['list']['7']['url'] + '>' + data['list']['7'][
|
|
||||||
'name'] + '</a>」' + ' 热度:' + data['list']['7']['hot'] + '\n8.' + '「<a href=' + data['list']['8'][
|
|
||||||
'url'] + '>' + data['list']['8']['name'] + '</a>」' + ' 热度:' + data['list']['8'][
|
|
||||||
'hot'] + '\n9.' + '「<a href=' + data['list']['9']['url'] + '>' + data['list']['9'][
|
|
||||||
'name'] + '</a>」' + ' 热度:' + data['list']['9']['hot'] + '\n10.' + '「<a href=' + data['list']['10'][
|
|
||||||
'url'] + '>' + data['list']['10']['name'] + '</a>」' + ' 热度:' + data['list']['10']['hot']
|
|
||||||
await context.edit(res, parse_mode='html', link_preview=True)
|
await context.edit(res, parse_mode='html', link_preview=True)
|
||||||
else:
|
else:
|
||||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
||||||
@ -56,21 +46,18 @@ async def netease(context):
|
|||||||
|
|
||||||
@listener(is_plugin=True, outgoing=True, command=alias_command("dyrs"),
|
@listener(is_plugin=True, outgoing=True, command=alias_command("dyrs"),
|
||||||
description="抖音热搜。")
|
description="抖音热搜。")
|
||||||
async def netease(context):
|
async def dyrs(context):
|
||||||
await context.edit("获取中 . . .")
|
await context.edit("获取中 . . .")
|
||||||
req = get("https://tenapi.cn/douyinresou")
|
req = get("https://tenapi.cn/douyinresou")
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
data = json.loads(req.text)
|
try:
|
||||||
res = '抖音实时热搜榜:' + '\n\n1.' + data['list']['1']['name'] + ' 热度:' + str(data['list']['1']['hot']) + '\n2.' + \
|
data = json.loads(req.text)
|
||||||
data['list']['2']['name'] + ' 热度:' + str(data['list']['2']['hot']) + '\n3.' + data['list']['3'][
|
except JSONDecodeError:
|
||||||
'name'] + ' 热度:' + str(data['list']['3']['hot']) + '\n4.' + data['list']['4'][
|
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
||||||
'name'] + ' 热度:' + str(data['list']['4']['hot']) + '\n5.' + data['list']['5'][
|
return
|
||||||
'name'] + ' 热度:' + str(data['list']['5']['hot']) + '\n6.' + data['list']['6'][
|
res = '抖音实时热搜榜:\n'
|
||||||
'name'] + ' 热度:' + str(data['list']['6']['hot']) + '\n7.' + data['list']['7'][
|
for i in range(0, 10):
|
||||||
'name'] + ' 热度:' + str(data['list']['7']['hot']) + '\n8.' + data['list']['8'][
|
res += f'\n{i + 1}.「{data["list"][i]["name"]}」 热度:{data["list"][i]["hot"]}'
|
||||||
'name'] + ' 热度:' + str(data['list']['8']['hot']) + '\n9.' + data['list']['9'][
|
|
||||||
'name'] + ' 热度:' + str(data['list']['9']['hot']) + '\n10.' + data['list']['10'][
|
|
||||||
'name'] + ' 热度:' + str(data['list']['10']['hot'])
|
|
||||||
await context.edit(res, parse_mode='html', link_preview=True)
|
await context.edit(res, parse_mode='html', link_preview=True)
|
||||||
else:
|
else:
|
||||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
||||||
@ -82,11 +69,15 @@ async def brank(context):
|
|||||||
await context.edit("获取中 . . .")
|
await context.edit("获取中 . . .")
|
||||||
req = get("https://api.imjad.cn/bilibili/v2/?get=rank&type=all")
|
req = get("https://api.imjad.cn/bilibili/v2/?get=rank&type=all")
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
data = json.loads(req.content)['rank']['list']
|
try:
|
||||||
res = []
|
data = json.loads(req.content)['rank']['list']
|
||||||
for num in range(0, 9):
|
except JSONDecodeError:
|
||||||
res.extend([str(num + 1) + '.「<a href="https://www.bilibili.com/video/' + data[num]['bvid'] + '">' +
|
await context.edit("出错了呜呜呜 ~ API 数据解析失败。")
|
||||||
data[num]['title'] + '</a>」 - ' + data[num]['author']])
|
return
|
||||||
await context.edit('B站实时排行榜:\n\n' + '\n'.join(res), parse_mode='html', link_preview=False)
|
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:
|
else:
|
||||||
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
|
||||||
|
Loading…
Reference in New Issue
Block a user