Merge remote-tracking branch 'upstream/master' into feat-webui-add-double-confirm
This commit is contained in:
@@ -133,7 +133,11 @@ class TelegramPlatformAdapter(Platform):
|
||||
message.message_str = ""
|
||||
message.message = []
|
||||
|
||||
if update.message.reply_to_message:
|
||||
if update.message.reply_to_message and not (
|
||||
update.message.is_topic_message
|
||||
and update.message.message_thread_id
|
||||
== update.message.reply_to_message.message_id
|
||||
):
|
||||
# 获取回复消息
|
||||
reply_update = Update(
|
||||
update_id=1,
|
||||
@@ -199,6 +203,15 @@ class TelegramPlatformAdapter(Platform):
|
||||
]
|
||||
message.message.append(Comp.At(qq=name, name=name))
|
||||
|
||||
elif update.message.sticker:
|
||||
# 将sticker当作图片处理
|
||||
file = await update.message.sticker.get_file()
|
||||
message.message.append(Comp.Image(file=file.file_path, url=file.file_path))
|
||||
if update.message.sticker.emoji:
|
||||
sticker_text = f"Sticker: {update.message.sticker.emoji}"
|
||||
message.message_str = sticker_text
|
||||
message.message.append(Comp.Plain(sticker_text))
|
||||
|
||||
elif update.message.document:
|
||||
file = await update.message.document.get_file()
|
||||
message.message = [
|
||||
|
||||
@@ -8,6 +8,9 @@ import base64
|
||||
import zipfile
|
||||
import uuid
|
||||
import psutil
|
||||
|
||||
import certifi
|
||||
|
||||
from typing import Union
|
||||
|
||||
from PIL import Image
|
||||
@@ -81,7 +84,13 @@ async def download_image_by_url(
|
||||
下载图片, 返回 path
|
||||
"""
|
||||
try:
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
ssl_context = ssl.create_default_context(
|
||||
cafile=certifi.where()
|
||||
) # 使用 certifi 提供的 CA 证书
|
||||
connector = aiohttp.TCPConnector(ssl=ssl_context) # 使用 certifi 的根证书
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=connector
|
||||
) as session:
|
||||
if post:
|
||||
async with session.post(url, json=post_data) as resp:
|
||||
if not path:
|
||||
@@ -118,7 +127,13 @@ async def download_file(url: str, path: str, show_progress: bool = False):
|
||||
从指定 url 下载文件到指定路径 path
|
||||
"""
|
||||
try:
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
ssl_context = ssl.create_default_context(
|
||||
cafile=certifi.where()
|
||||
) # 使用 certifi 提供的 CA 证书
|
||||
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=connector
|
||||
) as session:
|
||||
async with session.get(url, timeout=1800) as resp:
|
||||
if resp.status != 200:
|
||||
raise Exception(f"下载文件失败: {resp.status}")
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import re
|
||||
import aiohttp
|
||||
import ssl
|
||||
import certifi
|
||||
from io import BytesIO
|
||||
|
||||
from . import RenderStrategy
|
||||
@@ -91,7 +93,9 @@ class LocalRenderStrategy(RenderStrategy):
|
||||
try:
|
||||
image_url = re.findall(IMAGE_REGEX, line)[0]
|
||||
print(image_url)
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
||||
async with aiohttp.ClientSession(trust_env=True, connector=connector) as session:
|
||||
async with session.get(image_url) as resp:
|
||||
image_res = Image.open(BytesIO(await resp.read()))
|
||||
images[i] = image_res
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import aiohttp
|
||||
import os
|
||||
import ssl
|
||||
import certifi
|
||||
|
||||
from . import RenderStrategy
|
||||
from astrbot.core.config import VERSION
|
||||
@@ -46,7 +48,11 @@ class NetworkRenderStrategy(RenderStrategy):
|
||||
},
|
||||
}
|
||||
if return_url:
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=connector
|
||||
) as session:
|
||||
async with session.post(
|
||||
f"{self.BASE_RENDER_URL}/generate", json=post_data
|
||||
) as resp:
|
||||
|
||||
@@ -2,6 +2,10 @@ import aiohttp
|
||||
import os
|
||||
import zipfile
|
||||
import shutil
|
||||
|
||||
import ssl
|
||||
import certifi
|
||||
|
||||
from astrbot.core.utils.io import on_error, download_file
|
||||
from astrbot.core import logger
|
||||
|
||||
@@ -33,10 +37,26 @@ class RepoZipUpdator:
|
||||
返回一个列表,每个元素是一个字典,包含版本号、发布时间、更新内容、commit hash等信息。
|
||||
"""
|
||||
try:
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
ssl_context = ssl.create_default_context(
|
||||
cafile=certifi.where()
|
||||
) # 新增:创建基于 certifi 的 SSL 上下文
|
||||
connector = aiohttp.TCPConnector(
|
||||
ssl=ssl_context
|
||||
) # 新增:使用 TCPConnector 指定 SSL 上下文
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=connector
|
||||
) as session:
|
||||
async with session.get(url) as response:
|
||||
# 检查 HTTP 状态码
|
||||
if response.status != 200:
|
||||
text = await response.text()
|
||||
logger.error(
|
||||
f"请求 {url} 失败,状态码: {response.status}, 内容: {text}"
|
||||
)
|
||||
raise Exception(f"请求失败,状态码: {response.status}")
|
||||
result = await response.json()
|
||||
if not result:
|
||||
logger.error("返回空的结果")
|
||||
return []
|
||||
# if latest:
|
||||
# ret = self.github_api_release_parser([result[0]])
|
||||
@@ -53,7 +73,8 @@ class RepoZipUpdator:
|
||||
"zipball_url": release["zipball_url"],
|
||||
}
|
||||
)
|
||||
except BaseException:
|
||||
except Exception as e:
|
||||
logger.error(f"解析版本信息时发生异常: {e}")
|
||||
raise Exception("解析版本信息失败")
|
||||
return ret
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import traceback
|
||||
import aiohttp
|
||||
|
||||
import ssl
|
||||
import certifi
|
||||
|
||||
from .route import Route, Response, RouteContext
|
||||
from astrbot.core import logger
|
||||
from quart import request
|
||||
@@ -65,9 +69,14 @@ class PluginRoute(Route):
|
||||
else:
|
||||
urls = ["https://api.soulter.top/astrbot/plugins"]
|
||||
|
||||
# 新增:创建 SSL 上下文,使用 certifi 提供的根证书
|
||||
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||
connector = aiohttp.TCPConnector(ssl=ssl_context)
|
||||
for url in urls:
|
||||
try:
|
||||
async with aiohttp.ClientSession(trust_env=True) as session:
|
||||
async with aiohttp.ClientSession(
|
||||
trust_env=True, connector=connector
|
||||
) as session:
|
||||
async with session.get(url) as response:
|
||||
if response.status == 200:
|
||||
result = await response.json()
|
||||
|
||||
@@ -65,14 +65,9 @@ class StatRoute(Route):
|
||||
|
||||
stat_dict = stat.__dict__
|
||||
|
||||
# 获取CPU使用率 - 修复CPU始终为0的问题
|
||||
process = psutil.Process()
|
||||
# 获取系统CPU使用率而不是进程CPU使用率
|
||||
cpu_percent = psutil.cpu_percent(interval=0.5)
|
||||
|
||||
# 获取线程数
|
||||
thread_count = threading.active_count()
|
||||
|
||||
|
||||
# 获取插件信息
|
||||
plugins = self.core_lifecycle.star_context.get_all_stars()
|
||||
plugin_info = []
|
||||
@@ -80,7 +75,7 @@ class StatRoute(Route):
|
||||
info = {
|
||||
"name": getattr(plugin, "name", plugin.__class__.__name__),
|
||||
"version": getattr(plugin, "version", "1.0.0"),
|
||||
"is_enabled": True
|
||||
"is_enabled": True,
|
||||
}
|
||||
plugin_info.append(info)
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</v-container>
|
||||
|
||||
<!-- 配置对话框 -->
|
||||
<v-dialog v-model="showPlatformCfg" width="900" persistent>
|
||||
<v-dialog v-model="showPlatformCfg" persistent>
|
||||
<v-card>
|
||||
<v-card-title class="bg-primary text-white py-3">
|
||||
<v-icon color="white" class="me-2">{{ updatingMode ? 'mdi-pencil' : 'mdi-plus' }}</v-icon>
|
||||
@@ -105,12 +105,12 @@
|
||||
|
||||
<v-card-text class="py-4">
|
||||
<v-row>
|
||||
<v-col cols="12" md="6">
|
||||
<v-col cols="12" md="8">
|
||||
<AstrBotConfig :iterable="newSelectedPlatformConfig"
|
||||
:metadata="metadata['platform_group']?.metadata"
|
||||
metadataKey="platform" />
|
||||
</v-col>
|
||||
<v-col cols="12" md="6">
|
||||
<v-col cols="12" md="4">
|
||||
<v-btn :loading="iframeLoading" @click="refreshIframe" variant="tonal" color="primary" style="float: right;">
|
||||
<v-icon>mdi-refresh</v-icon>
|
||||
刷新
|
||||
|
||||
+2
-1
@@ -25,4 +25,5 @@ dashscope
|
||||
python-telegram-bot
|
||||
wechatpy
|
||||
dingtalk-stream
|
||||
mcp
|
||||
mcp
|
||||
certifi
|
||||
Reference in New Issue
Block a user