Compare commits

..

4 Commits

Author SHA1 Message Date
Soulter
53dbebb503 fix: 修复文转图模式下短文本报错的问题 #215 2024-10-14 18:01:51 +08:00
Soulter
52df91eb60 fix: 修复插件配置更新失败 2024-10-11 16:45:08 +08:00
Soulter
a9a758d715 perf: 更换更新插件依赖的方式 2024-10-10 22:53:00 +08:00
Soulter
0226fa7a25 Update README.md 2024-10-10 14:07:15 +08:00
13 changed files with 60 additions and 46 deletions

View File

@@ -9,6 +9,7 @@
<img src="https://img.shields.io/badge/python-3.9+-blue.svg" alt="python">
<a href="https://hub.docker.com/r/soulter/astrbot"><img alt="Docker pull" src="https://img.shields.io/docker/pulls/soulter/astrbot.svg"/></a>
[![codecov](https://codecov.io/gh/Soulter/AstrBot/graph/badge.svg?token=FF3P5967B8)](https://codecov.io/gh/Soulter/AstrBot)
![过去3天消息数](https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fapi.soulter.top%2Fastrbot%2Fstats&query=results.A.frames%5B0%5D.data.values%5B0%5D%5B0%5D&suffix=%E6%9D%A1&label=%E8%BF%87%E5%8E%BB%203%20%E5%A4%A9%E6%B6%88%E6%81%AF%E6%95%B0)
<a href="https://qm.qq.com/cgi-bin/qm/qr?k=EYGsuUTfe00_iOu9JTXS7_TEpMkXOvwv&jump_from=webapi&authKey=uUEMKCROfsseS+8IzqPjzV3y1tzy4AkykwTib2jNkOFdzezF9s9XknqnIaf3CDft">
<img alt="Static Badge" src="https://img.shields.io/badge/QQ群-322154837-purple">
</a>

View File

@@ -1 +1 @@
import{q as e,o as a,c as t,w as o,d as s,x as n,U as r,X as c}from"./index-b50bcc8e.js";const f=e({__name:"BlankLayout",setup(p){return(u,_)=>(a(),t(r,null,{default:o(()=>[s(n(c))]),_:1}))}});export{f as default};
import{q as e,o as a,c as t,w as o,d as s,x as n,U as r,X as c}from"./index-a2f0b905.js";const f=e({__name:"BlankLayout",setup(p){return(u,_)=>(a(),t(r,null,{default:o(()=>[s(n(c))]),_:1}))}});export{f as default};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import{a as _t,_ as Ot}from"./md5-e2d94ab4.js";import{q as Me,a8 as we,r as Vt,a9 as St,B,aa as Be,Z as F,x as I,ab as Z,ac as Et,L as Ne,ad as Ie,ae as At,af as jt,ag as wt,ah as q,s as Ft,o as Re,c as tt,w as P,d as A,K as He,a as qe,D as Pt,l as Tt,t as Ct,ai as Bt,g as Nt,u as ge,R as It,J as Rt,O as Fe,P as Pe,G as Ke,I as Mt}from"./index-b50bcc8e.js";/**
import{a as _t,_ as Ot}from"./md5-f95c7b53.js";import{q as Me,a8 as we,r as Vt,a9 as St,B,aa as Be,Z as F,x as I,ab as Z,ac as Et,L as Ne,ad as Ie,ae as At,af as jt,ag as wt,ah as q,s as Ft,o as Re,c as tt,w as P,d as A,K as He,a as qe,D as Pt,l as Tt,t as Ct,ai as Bt,g as Nt,u as ge,R as It,J as Rt,O as Fe,P as Pe,G as Ke,I as Mt}from"./index-a2f0b905.js";/**
* vee-validate v4.11.3
* (c) 2023 Abdelrahman Awad
* @license MIT

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
import{aj as L,q as $,B as J,o as q,l as X,d as G,w as Z,a0 as O,a1 as R,x as S,u as m,ak as Q,al as t0,am as r0,an as e0}from"./index-b50bcc8e.js";const E={Sidebar_drawer:!0,Customizer_drawer:!1,mini_sidebar:!1,fontTheme:"Roboto",inputBg:!1},i0=L({id:"customizer",state:()=>({Sidebar_drawer:E.Sidebar_drawer,Customizer_drawer:E.Customizer_drawer,mini_sidebar:E.mini_sidebar,fontTheme:"Poppins",inputBg:E.inputBg}),getters:{},actions:{SET_SIDEBAR_DRAWER(){this.Sidebar_drawer=!this.Sidebar_drawer},SET_MINI_SIDEBAR(p){this.mini_sidebar=p},SET_FONT(p){this.fontTheme=p}}}),s0={class:"logo",style:{display:"flex","align-items":"center"}},a0={style:{"font-size":"24px","font-weight":"1000"}},f0={style:{"font-size":"20px","font-weight":"1000"}},o0={style:{"font-size":"20px"}},l0=$({__name:"LogoDark",setup(p){J("rgb(var(--v-theme-primary))"),J("rgb(var(--v-theme-secondary))");const d=i0();return(M,y)=>(q(),X("div",s0,[G(S(Q),{to:"/",style:{"text-decoration":"none",color:"black"}},{default:Z(()=>[O(m("span",a0,"AstrBot 仪表盘",512),[[R,!S(d).mini_sidebar]]),O(m("span",f0,"Astr",512),[[R,S(d).mini_sidebar]]),O(m("span",o0,"Bot",512),[[R,S(d).mini_sidebar]])]),_:1})]))}});var P={exports:{}};const n0={},h0=Object.freeze(Object.defineProperty({__proto__:null,default:n0},Symbol.toStringTag,{value:"Module"})),H=t0(h0);/**
import{aj as L,q as $,B as J,o as q,l as X,d as G,w as Z,a0 as O,a1 as R,x as S,u as m,ak as Q,al as t0,am as r0,an as e0}from"./index-a2f0b905.js";const E={Sidebar_drawer:!0,Customizer_drawer:!1,mini_sidebar:!1,fontTheme:"Roboto",inputBg:!1},i0=L({id:"customizer",state:()=>({Sidebar_drawer:E.Sidebar_drawer,Customizer_drawer:E.Customizer_drawer,mini_sidebar:E.mini_sidebar,fontTheme:"Poppins",inputBg:E.inputBg}),getters:{},actions:{SET_SIDEBAR_DRAWER(){this.Sidebar_drawer=!this.Sidebar_drawer},SET_MINI_SIDEBAR(p){this.mini_sidebar=p},SET_FONT(p){this.fontTheme=p}}}),s0={class:"logo",style:{display:"flex","align-items":"center"}},a0={style:{"font-size":"24px","font-weight":"1000"}},f0={style:{"font-size":"20px","font-weight":"1000"}},o0={style:{"font-size":"20px"}},l0=$({__name:"LogoDark",setup(p){J("rgb(var(--v-theme-primary))"),J("rgb(var(--v-theme-secondary))");const d=i0();return(M,y)=>(q(),X("div",s0,[G(S(Q),{to:"/",style:{"text-decoration":"none",color:"black"}},{default:Z(()=>[O(m("span",a0,"AstrBot 仪表盘",512),[[R,!S(d).mini_sidebar]]),O(m("span",f0,"Astr",512),[[R,S(d).mini_sidebar]]),O(m("span",o0,"Bot",512),[[R,S(d).mini_sidebar]])]),_:1})]))}});var P={exports:{}};const n0={},h0=Object.freeze(Object.defineProperty({__proto__:null,default:n0},Symbol.toStringTag,{value:"Module"})),H=t0(h0);/**
* [js-md5]{@link https://github.com/emn178/js-md5}
*
* @namespace md5

View File

@@ -11,7 +11,7 @@
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&family=Roboto:wght@400;500;700&display=swap"
/>
<title>AstrBot - 仪表盘</title>
<script type="module" crossorigin src="/assets/index-b50bcc8e.js"></script>
<script type="module" crossorigin src="/assets/index-a2f0b905.js"></script>
<link rel="stylesheet" href="/assets/index-86dd25ba.css">
</head>
<body>

View File

@@ -75,7 +75,7 @@ class Platform():
return True
return False
async def convert_to_t2i_chain(self, message_result: list) -> list:
async def convert_to_t2i_chain(self, message_result: list) -> Union[List[Image], None]:
plain_str = ""
rendered_images = []
for i in message_result:
@@ -88,7 +88,6 @@ class Platform():
else:
rendered_images.append(Image.fromFileSystem(p))
return rendered_images
return message_result
async def record_metrics(self):
self.context.metrics_uploader.increment_platform_stat(self.PLATFORM_NAME)

View File

@@ -5,7 +5,7 @@ import traceback
import uuid
import shutil
import yaml
import subprocess
import logging
from util.updator.plugin_updator import PluginUpdator
from util.io import remove_dir, download_file
@@ -15,6 +15,7 @@ from type.plugin import *
from type.register import *
from util.log import LogManager
from logging import Logger
from pip import main as pip_main
logger: Logger = LogManager.GetLogger(log_name='astrbot')
@@ -82,36 +83,37 @@ class PluginManager():
logger.info(f"正在检查更新插件 {p} 的依赖: {pth}")
self.update_plugin_dept(os.path.join(plugin_path, "requirements.txt"))
def update_plugin_dept(self, path, break_system_package=True):
mirror = "https://mirrors.aliyun.com/pypi/simple/"
py = sys.executable
cmd = f"{py} -m pip install -r {path} -i {mirror} --trusted-host mirrors.aliyun.com"
if break_system_package:
cmd += " --break-system-package"
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
def update_plugin_dept(self, path):
pip_main(['install', '-r', path, '--trusted-host', 'mirrors.aliyun.com', '-i', 'https://mirrors.aliyun.com/pypi/simple/'])
# mirror = "https://mirrors.aliyun.com/pypi/simple/"
# py = sys.executable
# cmd = f"{py} -m pip install -r {path} -i {mirror} --trusted-host mirrors.aliyun.com"
# if break_system_package:
# cmd += " --break-system-package"
# process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, universal_newlines=True)
while True:
output = process.stdout.readline()
err = process.stderr.readline()
if err:
err = err.strip()
logger.error(err)
if "no such option: --break-system-package" in err:
self.update_plugin_dept(path, break_system_package=False)
break
if output == '' and process.poll() is not None:
break
if output:
output = output.strip()
if output.startswith("Requirement already satisfied"):
continue
if output.startswith("Using cached"):
continue
if output.startswith("Looking in indexes"):
continue
logger.info(output)
# while True:
# output = process.stdout.readline()
# err = process.stderr.readline()
# if err:
# err = err.strip()
# logger.error(err)
# if "no such option: --break-system-package" in err:
# self.update_plugin_dept(path, break_system_package=False)
# break
# if output == '' and process.poll() is not None:
# break
# if output:
# output = output.strip()
# if output.startswith("Requirement already satisfied"):
# continue
# if output.startswith("Using cached"):
# continue
# if output.startswith("Looking in indexes"):
# continue
# logger.info(output)
rc = process.poll()
# rc = process.poll()
async def install_plugin(self, repo_url: str):
@@ -124,7 +126,7 @@ class PluginManager():
with open(os.path.join(plugin_path, "REPO"), "w", encoding='utf-8') as f:
f.write(repo_url)
self.check_plugin_dept_update()
# self.check_plugin_dept_update()
return plugin_path
# ok, err = self.plugin_reload()
@@ -189,9 +191,16 @@ class PluginManager():
logger.info(f"正在加载插件 {root_dir_name} ...")
self.check_plugin_dept_update(target_plugin=root_dir_name)
module = __import__("data.plugins." +
# self.check_plugin_dept_update(target_plugin=root_dir_name)
try:
module = __import__("data.plugins." +
root_dir_name + "." + p, fromlist=[p])
except (ModuleNotFoundError, ImportError) as e:
# 尝试安装插件依赖
logger.error(f"尝试安装插件依赖。")
self.check_plugin_dept_update(target_plugin=root_dir_name)
module = __import__("data.plugins." +
root_dir_name + "." + p, fromlist=[p])
cls = self.get_classes(module)
@@ -223,6 +232,11 @@ class PluginManager():
traceback.print_exc()
fail_rec += f"加载{p}插件出现问题,原因 {str(e)}\n"
# 清除 pip.main 导致的多余的 logging handlers
for handler in logging.root.handlers[:]:
logging.root.removeHandler(handler)
if not fail_rec:
return True, None
else:
@@ -259,7 +273,7 @@ class PluginManager():
# remove the temp dir
remove_dir(temp_dir)
self.check_plugin_dept_update()
# self.check_plugin_dept_update()
# ok, err = self.plugin_reload()
# if not ok: