news60s 修复 API

This commit is contained in:
xtaodada 2023-06-03 20:22:11 +08:00
parent 239476acba
commit 635df5cf40
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 54 additions and 10 deletions

42
index.html Normal file
View File

@ -0,0 +1,42 @@
<!DOCTYPE html>
<head>
<title>无法访问!</title>
<meta charset="UTF-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"/>
<meta name="robots" content="noindex, nofollow"/>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"/>
<link rel="stylesheet" id="cf_styles-css" href="https://cloudflare.com/cdn-cgi/styles/cf.errors.css" type="text/css"
media="screen,projection"/>
<link rel="stylesheet" id='cf_styles-ie-css' href="https://cloudflare.com/cdn-cgi/styles/cf.errors.ie.css"
type="text/css" media="screen,projection"/>
<style type="text/css">body {
margin: 0;
padding: 0
}</style>
<script type="text/javascript" src="https://cloudflare.com/cdn-cgi/scripts/zepto.min.js"></script>
<script type="text/javascript" src="https://cloudflare.com/cdn-cgi/scripts/cf.common.js"></script>
</head>
<body>
<div id="cf-wrapper">
<div class="cf-alert cf-alert-error cf-cookie-error" id="cookie-alert" data-translate="enable_cookies">
请启用cookie。
</div>
<div id="cf-error-details" class="cf-error-details-wrapper">
<div class="cf-wrapper cf-header cf-error-overview">
<h1 data-translate="block_headline">抱歉,您已被阻止</h1>
</div>
<div class="cf-section cf-highlight">
<div class="cf-wrapper">
<div class="cf-screenshot-container cf-screenshot-full">
<span class="cf-no-screenshot error"></span>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -3,7 +3,7 @@
from os import sep from os import sep
from os.path import isfile from os.path import isfile
from datetime import date from datetime import date
from typing import Optional, Dict from typing import Optional
from pyrogram.enums.parse_mode import ParseMode from pyrogram.enums.parse_mode import ParseMode
from pagermaid import scheduler from pagermaid import scheduler
@ -20,22 +20,22 @@ news60s_cache_time: Optional[date] = None
async def get_news60s() -> None: async def get_news60s() -> None:
global news60s_cache_time global news60s_cache_time
if news60s_cache_time == date.today() and isfile(f"data{sep}news60s.jpg"): if news60s_cache_time == date.today() and isfile(f"data{sep}news60s.png"):
return return
resp = await client.get("https://api.03c3.cn/zb/") resp = await client.get("https://api.emoao.com/api/60s")
if resp.is_error: if resp.is_error:
raise ValueError(f"获取失败,错误码:{resp.status_code}") raise ValueError(f"获取失败,错误码:{resp.status_code}")
news60s_cache_time = date.today() news60s_cache_time = date.today()
safe_remove(f"data{sep}news60s.jpg") safe_remove(f"data{sep}news60s.png")
with open(f"data{sep}news60s.jpg", "wb") as f: with open(f"data{sep}news60s.png", "wb") as f:
f.write(resp.content) f.write(resp.content)
async def push_news60s(gid: int) -> None: async def push_news60s(gid: int) -> None:
if isfile(f"data{sep}news60s.jpg"): if isfile(f"data{sep}news60s.png"):
await bot.send_photo( await bot.send_photo(
gid, gid,
f"data{sep}news60s.jpg" f"data{sep}news60s.png"
) )
@ -49,9 +49,11 @@ async def news60s_subscribe() -> None:
news60s_sub.del_id(gid) news60s_sub.del_id(gid)
@listener(command="news60s", @listener(
parameters="订阅/退订", command="news60s",
description="查看 60s 看世界新闻,支持订阅/退订每天上午八点定时发送") parameters="订阅/退订",
description="查看 60s 看世界新闻,支持订阅/退订每天上午八点定时发送"
)
async def news60s(message: Message): async def news60s(message: Message):
if not message.arguments: if not message.arguments:
try: try: