mirror of
https://github.com/langbot-app/LangBot.git
synced 2025-11-25 19:37:36 +08:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19a0572b5f | ||
|
|
6272e98474 | ||
|
|
45042fe7d4 | ||
|
|
d85e840126 | ||
|
|
804889f1de | ||
|
|
919c996434 | ||
|
|
00823b3d62 | ||
|
|
af54efd24a | ||
|
|
b1c9b121f6 | ||
|
|
7b5649d153 | ||
|
|
52bf716d84 | ||
|
|
c149dd7b66 | ||
|
|
65d5a1ed63 | ||
|
|
5516754bbb | ||
|
|
08082f2ee3 | ||
|
|
8489266080 | ||
|
|
51c7e0b235 | ||
|
|
628b6b0bb4 | ||
|
|
7e024d860d | ||
|
|
c2f6273f70 | ||
|
|
96e401ec7b | ||
|
|
ae8ac65447 | ||
|
|
2d4f59f36e |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,4 +22,5 @@ cmdpriv.json
|
|||||||
tips.py
|
tips.py
|
||||||
.venv
|
.venv
|
||||||
bin/
|
bin/
|
||||||
.vscode
|
.vscode
|
||||||
|
test_*
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
[](https://github.com/RockChinQ/QChatGPT/releases/latest)
|
[](https://github.com/RockChinQ/QChatGPT/releases/latest)
|
||||||
|
|
||||||
|
> 2023/4/27 正在对纯Python实现的QQ登录框架、YAML配置文件、异步编程等功能进行概念验证,欢迎体验[LightQChat](https://github.com/RockChinQ/LightQChat)项目
|
||||||
> 2023/4/24 支持使用go-cqhttp登录QQ,请查看[此文档](https://github.com/RockChinQ/QChatGPT/wiki/go-cqhttp%E9%85%8D%E7%BD%AE)
|
> 2023/4/24 支持使用go-cqhttp登录QQ,请查看[此文档](https://github.com/RockChinQ/QChatGPT/wiki/go-cqhttp%E9%85%8D%E7%BD%AE)
|
||||||
> 2023/3/18 现已支持GPT-4 API(内测),请查看`config-template.py`中的`completion_api_params`
|
> 2023/3/18 现已支持GPT-4 API(内测),请查看`config-template.py`中的`completion_api_params`
|
||||||
> 2023/3/15 逆向库已支持New Bing,使用方法查看[插件文档](https://github.com/RockChinQ/revLibs)
|
> 2023/3/15 逆向库已支持New Bing,使用方法查看[插件文档](https://github.com/RockChinQ/revLibs)
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
- ChatGPT网页版GPT-3.5模型, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
- ChatGPT网页版GPT-3.5模型, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
||||||
- ChatGPT网页版GPT-4模型, 目前需要ChatGPT Plus订阅, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
- ChatGPT网页版GPT-4模型, 目前需要ChatGPT Plus订阅, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
||||||
- New Bing逆向库, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
- New Bing逆向库, 由[插件](https://github.com/RockChinQ/revLibs)接入
|
||||||
|
- HuggingChat, 由[插件](https://github.com/RockChinQ/revLibs)接入, 无需账号,仅支持英文
|
||||||
|
|
||||||
### 故事续写
|
### 故事续写
|
||||||
|
|
||||||
@@ -176,6 +178,8 @@
|
|||||||
|
|
||||||
#### Docker方式
|
#### Docker方式
|
||||||
|
|
||||||
|
> docker方式目前仅支持使用mirai登录,若您不**熟悉**docker的操作及相关知识,强烈建议您使用其他方式部署,我们**不会且难以**解决您主机上多个容器的连接问题。
|
||||||
|
|
||||||
请查看[此文档](res/docs/docker_deploy.md)
|
请查看[此文档](res/docs/docker_deploy.md)
|
||||||
由[@mikumifa](https://github.com/mikumifa)贡献
|
由[@mikumifa](https://github.com/mikumifa)贡献
|
||||||
|
|
||||||
@@ -292,6 +296,7 @@ python3 main.py
|
|||||||
- [chordfish-k/QChartGPT_Emoticon_Plugin](https://github.com/chordfish-k/QChartGPT_Emoticon_Plugin) - 使机器人根据回复内容发送表情包
|
- [chordfish-k/QChartGPT_Emoticon_Plugin](https://github.com/chordfish-k/QChartGPT_Emoticon_Plugin) - 使机器人根据回复内容发送表情包
|
||||||
- [oliverkirk-sudo/ChatPoeBot](https://github.com/oliverkirk-sudo/ChatPoeBot) - 接入[Poe](https://poe.com/)上的机器人
|
- [oliverkirk-sudo/ChatPoeBot](https://github.com/oliverkirk-sudo/ChatPoeBot) - 接入[Poe](https://poe.com/)上的机器人
|
||||||
- [lieyanqzu/WeatherPlugin](https://github.com/lieyanqzu/WeatherPlugin) - 天气查询插件
|
- [lieyanqzu/WeatherPlugin](https://github.com/lieyanqzu/WeatherPlugin) - 天气查询插件
|
||||||
|
- [SysStatPlugin](https://github.com/RockChinQ/SysStatPlugin) - 查看系统状态
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## 😘致谢
|
## 😘致谢
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ English | [简体中文](README.md)
|
|||||||
- ChatGPT website edition (GPT-3.5), see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
- ChatGPT website edition (GPT-3.5), see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
||||||
- ChatGPT website edition (GPT-4), ChatGPT plus subscription required, see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
- ChatGPT website edition (GPT-4), ChatGPT plus subscription required, see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
||||||
- New Bing, see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
- New Bing, see [revLibs plugin](https://github.com/RockChinQ/revLibs)
|
||||||
|
- HuggingChat, see [revLibs plugin](https://github.com/RockChinQ/revLibs), no accounts required, English only
|
||||||
|
|
||||||
### Story
|
### Story
|
||||||
|
|
||||||
|
|||||||
6
main.py
6
main.py
@@ -48,8 +48,8 @@ def init_db():
|
|||||||
def ensure_dependencies():
|
def ensure_dependencies():
|
||||||
import pkg.utils.pkgmgr as pkgmgr
|
import pkg.utils.pkgmgr as pkgmgr
|
||||||
pkgmgr.run_pip(["install", "openai", "Pillow", "nakuru-project-idk", "--upgrade",
|
pkgmgr.run_pip(["install", "openai", "Pillow", "nakuru-project-idk", "--upgrade",
|
||||||
"-i", "https://pypi.douban.com/simple/",
|
"-i", "https://pypi.tuna.tsinghua.edu.cn/simple",
|
||||||
"--trusted-host", "pypi.douban.com"])
|
"--trusted-host", "pypi.tuna.tsinghua.edu.cn"])
|
||||||
|
|
||||||
|
|
||||||
known_exception_caught = False
|
known_exception_caught = False
|
||||||
@@ -268,7 +268,7 @@ def start(first_time_init=False):
|
|||||||
import config
|
import config
|
||||||
if config.msg_source_adapter == "yirimirai":
|
if config.msg_source_adapter == "yirimirai":
|
||||||
logging.info("QQ: {}, MAH: {}".format(config.mirai_http_api_config['qq'], config.mirai_http_api_config['host']+":"+str(config.mirai_http_api_config['port'])))
|
logging.info("QQ: {}, MAH: {}".format(config.mirai_http_api_config['qq'], config.mirai_http_api_config['host']+":"+str(config.mirai_http_api_config['port'])))
|
||||||
logging.critical('程序启动完成,如长时间未显示 "成功登录到账号xxxxx" ,并且不回复消息,请查看 '
|
logging.critical('程序启动完成,如长时间未显示 "成功登录到账号xxxxx" ,并且不回复消息,解决办法(请勿到群里问): '
|
||||||
'https://github.com/RockChinQ/QChatGPT/issues/37')
|
'https://github.com/RockChinQ/QChatGPT/issues/37')
|
||||||
elif config.msg_source_adapter == 'nakuru':
|
elif config.msg_source_adapter == 'nakuru':
|
||||||
logging.info("host: {}, port: {}, http_port: {}".format(config.nakuru_config['host'], config.nakuru_config['port'], config.nakuru_config['http_port']))
|
logging.info("host: {}, port: {}, http_port: {}".format(config.nakuru_config['host'], config.nakuru_config['port'], config.nakuru_config['http_port']))
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import sys
|
|||||||
import shutil
|
import shutil
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
import pkg.utils.updater as updater
|
||||||
import pkg.utils.context as context
|
import pkg.utils.context as context
|
||||||
import pkg.plugin.switch as switch
|
import pkg.plugin.switch as switch
|
||||||
import pkg.plugin.settings as settings
|
import pkg.plugin.settings as settings
|
||||||
@@ -79,7 +80,7 @@ def walk_plugin_path(module, prefix='', path_prefix=''):
|
|||||||
__current_module_path__ = "plugins/"+path_prefix + item.name + '.py'
|
__current_module_path__ = "plugins/"+path_prefix + item.name + '.py'
|
||||||
|
|
||||||
importlib.import_module(module.__name__ + '.' + item.name)
|
importlib.import_module(module.__name__ + '.' + item.name)
|
||||||
logging.info('加载模块: plugins/{} 成功'.format(path_prefix + item.name + '.py'))
|
logging.debug('加载模块: plugins/{} 成功'.format(path_prefix + item.name + '.py'))
|
||||||
except:
|
except:
|
||||||
logging.error('加载模块: plugins/{} 失败: {}'.format(path_prefix + item.name + '.py', sys.exc_info()))
|
logging.error('加载模块: plugins/{} 失败: {}'.format(path_prefix + item.name + '.py', sys.exc_info()))
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@@ -177,6 +178,43 @@ def uninstall_plugin(plugin_name: str) -> str:
|
|||||||
return "plugins/"+plugin_path
|
return "plugins/"+plugin_path
|
||||||
|
|
||||||
|
|
||||||
|
def update_plugin(plugin_name: str):
|
||||||
|
"""更新插件"""
|
||||||
|
# 检查是否有远程地址记录
|
||||||
|
target_plugin_dir = "plugins/" + __plugins__[plugin_name]['path'].replace("\\", "/").split("plugins/")[1].split("/")[0]
|
||||||
|
|
||||||
|
remote_url = updater.get_remote_url(target_plugin_dir)
|
||||||
|
if remote_url == "https://github.com/RockChinQ/QChatGPT" or remote_url == "https://gitee.com/RockChin/QChatGPT" \
|
||||||
|
or remote_url == "" or remote_url is None or remote_url == "http://github.com/RockChinQ/QChatGPT" or remote_url == "http://gitee.com/RockChin/QChatGPT":
|
||||||
|
raise Exception("插件没有远程地址记录,无法更新")
|
||||||
|
|
||||||
|
# 把远程clone到temp/plugins/update/插件名
|
||||||
|
logging.info("克隆插件储存库: {}".format(remote_url))
|
||||||
|
|
||||||
|
from dulwich import porcelain
|
||||||
|
clone_target_dir = "temp/plugins/update/"+target_plugin_dir.split("/")[-1]+"/"
|
||||||
|
|
||||||
|
if os.path.exists(clone_target_dir):
|
||||||
|
shutil.rmtree(clone_target_dir)
|
||||||
|
|
||||||
|
if not os.path.exists(clone_target_dir):
|
||||||
|
os.makedirs(clone_target_dir)
|
||||||
|
repo = porcelain.clone(remote_url, clone_target_dir, checkout=True)
|
||||||
|
|
||||||
|
# 检查此目录是否包含requirements.txt
|
||||||
|
if os.path.exists(clone_target_dir+"requirements.txt"):
|
||||||
|
logging.info("检测到requirements.txt,正在安装依赖")
|
||||||
|
import pkg.utils.pkgmgr
|
||||||
|
pkg.utils.pkgmgr.install_requirements(clone_target_dir+"requirements.txt")
|
||||||
|
|
||||||
|
import pkg.utils.log as log
|
||||||
|
log.reset_logging()
|
||||||
|
|
||||||
|
# 将temp/plugins/update/插件名 覆盖到 plugins/插件名
|
||||||
|
shutil.rmtree(target_plugin_dir)
|
||||||
|
|
||||||
|
shutil.copytree(clone_target_dir, target_plugin_dir)
|
||||||
|
|
||||||
class EventContext:
|
class EventContext:
|
||||||
"""事件上下文"""
|
"""事件上下文"""
|
||||||
eid = 0
|
eid = 0
|
||||||
@@ -344,3 +382,6 @@ class PluginHost:
|
|||||||
event_context.__return_value__))
|
event_context.__return_value__))
|
||||||
|
|
||||||
return event_context
|
return event_context
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
pass
|
||||||
|
|||||||
@@ -97,37 +97,34 @@ class PluginUpdateCommand(AbstractCommandNode):
|
|||||||
plugin_list = plugin_host.__plugins__
|
plugin_list = plugin_host.__plugins__
|
||||||
|
|
||||||
reply = []
|
reply = []
|
||||||
def closure():
|
|
||||||
try:
|
|
||||||
import pkg.utils.context
|
|
||||||
updated = []
|
|
||||||
for key in plugin_list:
|
|
||||||
plugin = plugin_list[key]
|
|
||||||
if updater.is_repo("/".join(plugin['path'].split('/')[:-1])):
|
|
||||||
success = updater.pull_latest("/".join(plugin['path'].split('/')[:-1]))
|
|
||||||
if success:
|
|
||||||
updated.append(plugin['name'])
|
|
||||||
|
|
||||||
# 检查是否有requirements.txt
|
if len(ctx.crt_params) > 0:
|
||||||
pkg.utils.context.get_qqbot_manager().notify_admin("正在安装依赖...")
|
def closure():
|
||||||
for key in plugin_list:
|
try:
|
||||||
plugin = plugin_list[key]
|
import pkg.utils.context
|
||||||
if os.path.exists("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt"):
|
|
||||||
logging.info("{}检测到requirements.txt,安装依赖".format(plugin['name']))
|
updated = []
|
||||||
import pkg.utils.pkgmgr
|
|
||||||
pkg.utils.pkgmgr.install_requirements("/".join(plugin['path'].split('/')[:-1])+"/requirements.txt")
|
|
||||||
|
|
||||||
import pkg.utils.log as log
|
if ctx.crt_params[0] == 'all':
|
||||||
log.reset_logging()
|
for key in plugin_list:
|
||||||
|
plugin_host.update_plugin(key)
|
||||||
|
updated.append(key)
|
||||||
|
else:
|
||||||
|
if ctx.crt_params[0] in plugin_list:
|
||||||
|
plugin_host.update_plugin(ctx.crt_params[0])
|
||||||
|
updated.append(ctx.crt_params[0])
|
||||||
|
else:
|
||||||
|
raise Exception("未找到插件: {}".format(ctx.crt_params[0]))
|
||||||
|
|
||||||
pkg.utils.context.get_qqbot_manager().notify_admin("已更新插件: {}".format(", ".join(updated)))
|
pkg.utils.context.get_qqbot_manager().notify_admin("已更新插件: {}, 请发送 !reload 重载插件".format(", ".join(updated)))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error("插件更新失败:{}".format(e))
|
logging.error("插件更新失败:{}".format(e))
|
||||||
pkg.utils.context.get_qqbot_manager().notify_admin("插件更新失败:{} 请尝试手动更新插件".format(e))
|
pkg.utils.context.get_qqbot_manager().notify_admin("插件更新失败:{} 请尝试手动更新插件".format(e))
|
||||||
|
|
||||||
|
reply = ["[bot]正在更新插件,请勿重复发起..."]
|
||||||
threading.Thread(target=closure).start()
|
threading.Thread(target=closure).start()
|
||||||
reply = ["[bot]正在更新所有插件,请勿重复发起..."]
|
else:
|
||||||
|
reply = ["[bot]请指定要更新的插件, 或使用 !plugin update all 更新所有插件"]
|
||||||
return True, reply
|
return True, reply
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class NakuruProjectMessageConverter(MessageConverter):
|
|||||||
elif type(message_chain) is list:
|
elif type(message_chain) is list:
|
||||||
msg_list = message_chain
|
msg_list = message_chain
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown message type: " + str(message_chain) + type(message_chain))
|
raise Exception("Unknown message type: " + str(message_chain) + str(type(message_chain)))
|
||||||
|
|
||||||
nakuru_msg_list = []
|
nakuru_msg_list = []
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
requests~=2.28.1
|
requests~=2.28.1
|
||||||
openai~=0.27.4
|
openai~=0.27.6
|
||||||
dulwich~=0.21.3
|
dulwich~=0.21.5
|
||||||
colorlog~=6.6.0
|
colorlog~=6.6.0
|
||||||
yiri-mirai~=0.2.6.1
|
yiri-mirai~=0.2.6.1
|
||||||
websockets
|
websockets
|
||||||
|
|||||||
@@ -5,20 +5,23 @@
|
|||||||
## 步骤
|
## 步骤
|
||||||
|
|
||||||
1. 从[go-cqhttp的Release](https://github.com/Mrs4s/go-cqhttp/releases/latest)下载最新的go-cqhttp可执行文件(建议直接下载可执行文件压缩包,而不是安装器)
|
1. 从[go-cqhttp的Release](https://github.com/Mrs4s/go-cqhttp/releases/latest)下载最新的go-cqhttp可执行文件(建议直接下载可执行文件压缩包,而不是安装器)
|
||||||
2. 解压并运行,首次运行会询问需要开放的网络协议,**请填入`02`并回车**
|
2. 解压并运行,首次运行会询问需要开放的网络协议,**请填入`02`并回车,必须输入`02`❗❗❗❗❗❗❗**
|
||||||
|
|
||||||
```
|
<h1> 你这里必须得输入`02`,你懂么,`0`必须得输入,看好了,看好下面输入什么了吗?别他妈的搁那就输个`2`完了启动连不上还跑群里问,问一个我踢一个。 </h1>
|
||||||
C:\Softwares\go-cqhttp.old> .\go-cqhttp.exe
|
|
||||||
未找到配置文件,正在为您生成配置文件中!
|
```
|
||||||
请选择你需要的通信方式:
|
C:\Softwares\go-cqhttp.old> .\go-cqhttp.exe
|
||||||
> 0: HTTP通信
|
未找到配置文件,正在为您生成配置文件中!
|
||||||
> 1: 云函数服务
|
请选择你需要的通信方式:
|
||||||
> 2: 正向 Websocket 通信
|
> 0: HTTP通信
|
||||||
> 3: 反向 Websocket 通信
|
> 1: 云函数服务
|
||||||
请输入你需要的编号(0-9),可输入多个,同一编号也可输入多个(如: 233)
|
> 2: 正向 Websocket 通信
|
||||||
您的选择是:02
|
> 3: 反向 Websocket 通信
|
||||||
```
|
请输入你需要的编号(0-9),可输入多个,同一编号也可输入多个(如: 233)
|
||||||
提示已生成`config.yml`文件,关闭go-cqhttp。
|
您的选择是:02
|
||||||
|
```
|
||||||
|
|
||||||
|
提示已生成`config.yml`文件,关闭go-cqhttp。
|
||||||
|
|
||||||
3. 打开go-cqhttp同目录的`config.yml`
|
3. 打开go-cqhttp同目录的`config.yml`
|
||||||
|
|
||||||
@@ -64,4 +67,4 @@
|
|||||||
|
|
||||||
4. 配置完成,重新启动go-cqhttp
|
4. 配置完成,重新启动go-cqhttp
|
||||||
|
|
||||||
> 若启动后登录不成功,请尝试根据[此文档](https://docs.go-cqhttp.org/guide/config.html#%E8%AE%BE%E5%A4%87%E4%BF%A1%E6%81%AF)修改`device.json`的协议编号。
|
> 若启动后登录不成功,请尝试根据[此文档](https://docs.go-cqhttp.org/guide/config.html#%E8%AE%BE%E5%A4%87%E4%BF%A1%E6%81%AF)修改`device.json`的协议编号。
|
||||||
|
|||||||
@@ -23,15 +23,16 @@ QChatGPT 插件使用Wiki
|
|||||||
|
|
||||||
## 管理
|
## 管理
|
||||||
|
|
||||||
### !plugin 指令
|
### !plugin 命令
|
||||||
|
|
||||||
```
|
```
|
||||||
!plugin 列出所有已安装的插件
|
!plugin 列出所有已安装的插件
|
||||||
!plugin get <储存库地址> 从Git储存库安装插件(需要管理员权限)
|
!plugin get <储存库地址> 从Git储存库安装插件(需要管理员权限)
|
||||||
!plugin update 更新所有插件(需要管理员权限,仅支持从储存库安装的插件)
|
!plugin update all 更新所有插件(需要管理员权限,仅支持从储存库安装的插件)
|
||||||
!plugin del <插件名> 删除插件(需要管理员权限)
|
!plugin update <插件名> 更新指定插件
|
||||||
!plugin on <插件名> 启用插件(需要管理员权限)
|
!plugin del <插件名> 删除插件(需要管理员权限)
|
||||||
!plugin off <插件名> 禁用插件(需要管理员权限)
|
!plugin on <插件名> 启用插件(需要管理员权限)
|
||||||
|
!plugin off <插件名> 禁用插件(需要管理员权限)
|
||||||
```
|
```
|
||||||
|
|
||||||
### 控制插件执行顺序
|
### 控制插件执行顺序
|
||||||
|
|||||||
Reference in New Issue
Block a user