PagerMaid_Plugins/resou.py

93 lines
6.2 KiB
Python
Raw Normal View History

2020-08-12 10:55:52 +00:00
import json
from requests import get
from pagermaid.listener import listener
2021-06-16 07:09:40 +00:00
from pagermaid.utils import alias_command
2020-08-12 10:55:52 +00:00
2021-06-16 07:09:40 +00:00
@listener(is_plugin=True, outgoing=True, command=alias_command("zhrs"),
2020-08-12 10:55:52 +00:00
description="知乎热搜。")
async def netease(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/zhihuresou")
if req.status_code == 200:
data = json.loads(req.text)
2020-08-12 13:55:15 +00:00
res = '知乎实时热搜榜:' + '\n\n1.' + '「<a href=' + data['list']['1']['url'] + '>' + data['list']['1'][
'query'] + '</a>」' + '\n2.' + '「<a href=' + data['list']['2']['url'] + '>' + data['list']['2'][
'query'] + '</a>」' + '\n3.' + '「<a href=' + data['list']['3']['url'] + '>' + data['list']['3'][
'query'] + '</a>」' + '\n4.' + '「<a href=' + data['list']['4']['url'] + '>' + data['list']['4'][
'query'] + '</a>」' + '\n5.' + '「<a href=' + data['list']['5']['url'] + '>' + data['list']['5'][
'query'] + '</a>」' + '\n6.' + '「<a href=' + data['list']['6']['url'] + '>' + data['list']['6'][
'query'] + '</a>」' + '\n7.' + '「<a href=' + data['list']['7']['url'] + '>' + data['list']['7'][
'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>」'
2020-08-12 10:55:52 +00:00
await context.edit(res, parse_mode='html', link_preview=False)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
2021-06-16 07:09:40 +00:00
@listener(is_plugin=True, outgoing=True, command=alias_command("wbrs"),
2020-08-12 10:55:52 +00:00
description="微博热搜。")
async def netease(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/resou")
if req.status_code == 200:
data = json.loads(req.text)
2020-08-12 13:55:15 +00:00
res = '微博实时热搜榜:' + '\n\n1.' + '「<a href=' + data['list']['1']['url'] + '>' + data['list']['1'][
'name'] + '</a>」' + ' 热度:' + data['list']['1']['hot'] + '\n2.' + '「<a href=' + data['list']['2'][
'url'] + '>' + data['list']['2']['name'] + '</a>」' + ' 热度:' + data['list']['2'][
'hot'] + '\n3.' + '「<a href=' + data['list']['3']['url'] + '>' + data['list']['3'][
'name'] + '</a>」' + ' 热度:' + data['list']['3']['hot'] + '\n4.' + '「<a href=' + data['list']['4'][
'url'] + '>' + data['list']['4']['name'] + '</a>」' + ' 热度:' + data['list']['4'][
'hot'] + '\n5.' + '「<a href=' + data['list']['5']['url'] + '>' + data['list']['5'][
'name'] + '</a>」' + ' 热度:' + data['list']['5']['hot'] + '\n6.' + '「<a href=' + data['list']['6'][
'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']
2020-08-12 10:55:52 +00:00
await context.edit(res, parse_mode='html', link_preview=True)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
2021-06-16 07:09:40 +00:00
@listener(is_plugin=True, outgoing=True, command=alias_command("dyrs"),
2020-08-12 10:55:52 +00:00
description="抖音热搜。")
async def netease(context):
await context.edit("获取中 . . .")
req = get("https://tenapi.cn/douyinresou")
if req.status_code == 200:
data = json.loads(req.text)
2020-08-12 13:55:15 +00:00
res = '抖音实时热搜榜:' + '\n\n1.' + data['list']['1']['name'] + ' 热度:' + str(data['list']['1']['hot']) + '\n2.' + \
data['list']['2']['name'] + ' 热度:' + str(data['list']['2']['hot']) + '\n3.' + data['list']['3'][
'name'] + ' 热度:' + str(data['list']['3']['hot']) + '\n4.' + data['list']['4'][
'name'] + ' 热度:' + str(data['list']['4']['hot']) + '\n5.' + data['list']['5'][
'name'] + ' 热度:' + str(data['list']['5']['hot']) + '\n6.' + data['list']['6'][
'name'] + ' 热度:' + str(data['list']['6']['hot']) + '\n7.' + data['list']['7'][
'name'] + ' 热度:' + str(data['list']['7']['hot']) + '\n8.' + data['list']['8'][
'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'])
2020-08-12 10:55:52 +00:00
await context.edit(res, parse_mode='html', link_preview=True)
else:
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")
2020-08-12 13:55:15 +00:00
2021-06-16 07:09:40 +00:00
@listener(is_plugin=True, outgoing=True, command=alias_command("brank"),
2020-08-12 13:55:15 +00:00
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:
data = json.loads(req.content)['rank']['list']
res = []
for num in range(0, 9):
res.extend([str(num + 1) + '.「<a href="https://www.bilibili.com/video/' + data[num]['bvid'] + '">' +
data[num]['title'] + '</a>」 - ' + data[num]['author']])
await context.edit('B站实时排行榜\n\n' + '\n'.join(res), parse_mode='html', link_preview=False)
else:
2021-06-16 07:09:40 +00:00
await context.edit("出错了呜呜呜 ~ 无法访问到 API 服务器 。")