mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-11 05:20:57 +00:00
feat: !plugin指令展示源码地址
This commit is contained in:
+10
-3
@@ -2,6 +2,7 @@
|
|||||||
import logging
|
import logging
|
||||||
import json
|
import json
|
||||||
import datetime
|
import datetime
|
||||||
|
import os
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
import pkg.openai.session
|
import pkg.openai.session
|
||||||
@@ -84,17 +85,23 @@ def plugin_operation(cmd, params, is_admin):
|
|||||||
reply = []
|
reply = []
|
||||||
|
|
||||||
import pkg.plugin.host as plugin_host
|
import pkg.plugin.host as plugin_host
|
||||||
|
import pkg.utils.updater as updater
|
||||||
|
|
||||||
plugin_list = plugin_host.__plugins__
|
plugin_list = plugin_host.__plugins__
|
||||||
|
|
||||||
if len(params) == 0:
|
if len(params) == 0:
|
||||||
reply_str = "[bot]所有插件{}:\n\n".format(len(plugin_list))
|
reply_str = "[bot]所有插件({}):\n\n".format(len(plugin_list))
|
||||||
idx = 0
|
idx = 0
|
||||||
for key in plugin_list:
|
for key in plugin_list:
|
||||||
plugin = plugin_list[key]
|
plugin = plugin_list[key]
|
||||||
print(plugin)
|
reply_str += "#{} {}:\n{}\nv{}\n作者: {}\n".format((idx+1), plugin['name'], plugin['description'],
|
||||||
reply_str += "#{} {}:\n{}\nv{}\n作者:{}\n\n".format((idx+1), plugin['name'], plugin['description'],
|
|
||||||
plugin['version'], plugin['author'])
|
plugin['version'], plugin['author'])
|
||||||
|
|
||||||
|
if updater.is_repo("/".join(plugin['path'].split('/')[:-1])):
|
||||||
|
reply_str += "源码: "+updater.get_remote_url("/".join(plugin['path'].split('/')[:-1]))+"\n"
|
||||||
|
|
||||||
|
reply_str += "\n"
|
||||||
|
|
||||||
idx += 1
|
idx += 1
|
||||||
|
|
||||||
reply = [reply_str]
|
reply = [reply_str]
|
||||||
|
|||||||
+33
-42
@@ -3,8 +3,7 @@ import datetime
|
|||||||
import pkg.utils.context
|
import pkg.utils.context
|
||||||
|
|
||||||
|
|
||||||
def update_all() -> bool:
|
def check_dulwich_closure():
|
||||||
"""使用dulwich更新源码"""
|
|
||||||
try:
|
try:
|
||||||
import pkg.utils.pkgmgr
|
import pkg.utils.pkgmgr
|
||||||
pkg.utils.pkgmgr.ensure_dulwich()
|
pkg.utils.pkgmgr.ensure_dulwich()
|
||||||
@@ -15,6 +14,12 @@ def update_all() -> bool:
|
|||||||
import dulwich
|
import dulwich
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
||||||
|
|
||||||
|
|
||||||
|
def update_all() -> bool:
|
||||||
|
"""使用dulwich更新源码"""
|
||||||
|
check_dulwich_closure()
|
||||||
|
import dulwich
|
||||||
try:
|
try:
|
||||||
before_commit_id = get_current_commit_id()
|
before_commit_id = get_current_commit_id()
|
||||||
from dulwich import porcelain
|
from dulwich import porcelain
|
||||||
@@ -41,18 +46,31 @@ def update_all() -> bool:
|
|||||||
raise Exception("分支不一致,自动更新仅支持master分支,请手动更新(https://github.com/RockChinQ/QChatGPT/issues/76)")
|
raise Exception("分支不一致,自动更新仅支持master分支,请手动更新(https://github.com/RockChinQ/QChatGPT/issues/76)")
|
||||||
|
|
||||||
|
|
||||||
|
def is_repo(path: str) -> bool:
|
||||||
|
"""检查是否是git仓库"""
|
||||||
|
check_dulwich_closure()
|
||||||
|
|
||||||
|
from dulwich import porcelain
|
||||||
|
try:
|
||||||
|
porcelain.open_repo(path)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def get_remote_url(repo_path: str) -> str:
|
||||||
|
"""获取远程仓库地址"""
|
||||||
|
check_dulwich_closure()
|
||||||
|
|
||||||
|
from dulwich import porcelain
|
||||||
|
repo = porcelain.open_repo(repo_path)
|
||||||
|
return str(porcelain.get_remote_repo(repo, "origin")[1])
|
||||||
|
|
||||||
|
|
||||||
def get_current_version_info() -> str:
|
def get_current_version_info() -> str:
|
||||||
"""获取当前版本信息"""
|
"""获取当前版本信息"""
|
||||||
try:
|
check_dulwich_closure()
|
||||||
import pkg.utils.pkgmgr
|
|
||||||
pkg.utils.pkgmgr.ensure_dulwich()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
import dulwich
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
|
||||||
|
|
||||||
from dulwich import porcelain
|
from dulwich import porcelain
|
||||||
|
|
||||||
@@ -74,16 +92,7 @@ def get_current_version_info() -> str:
|
|||||||
|
|
||||||
def get_commit_id_and_time_and_msg() -> str:
|
def get_commit_id_and_time_and_msg() -> str:
|
||||||
"""获取当前提交id和时间和提交信息"""
|
"""获取当前提交id和时间和提交信息"""
|
||||||
try:
|
check_dulwich_closure()
|
||||||
import pkg.utils.pkgmgr
|
|
||||||
pkg.utils.pkgmgr.ensure_dulwich()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
import dulwich
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
|
||||||
|
|
||||||
from dulwich import porcelain
|
from dulwich import porcelain
|
||||||
|
|
||||||
@@ -97,16 +106,7 @@ def get_commit_id_and_time_and_msg() -> str:
|
|||||||
|
|
||||||
def get_current_commit_id() -> str:
|
def get_current_commit_id() -> str:
|
||||||
"""检查是否有新版本"""
|
"""检查是否有新版本"""
|
||||||
try:
|
check_dulwich_closure()
|
||||||
import pkg.utils.pkgmgr
|
|
||||||
pkg.utils.pkgmgr.ensure_dulwich()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
import dulwich
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
|
||||||
|
|
||||||
from dulwich import porcelain
|
from dulwich import porcelain
|
||||||
|
|
||||||
@@ -121,16 +121,7 @@ def get_current_commit_id() -> str:
|
|||||||
|
|
||||||
def is_new_version_available() -> bool:
|
def is_new_version_available() -> bool:
|
||||||
"""检查是否有新版本"""
|
"""检查是否有新版本"""
|
||||||
try:
|
check_dulwich_closure()
|
||||||
import pkg.utils.pkgmgr
|
|
||||||
pkg.utils.pkgmgr.ensure_dulwich()
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
try:
|
|
||||||
import dulwich
|
|
||||||
except ModuleNotFoundError:
|
|
||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
|
||||||
|
|
||||||
from dulwich import porcelain
|
from dulwich import porcelain
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user