mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-04 04:54:36 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d9964bcb1 | ||
|
|
15cb8016d3 | ||
|
|
895cc0a2c5 | ||
|
|
20bf349e4e | ||
|
|
e297763da1 | ||
|
|
e471970654 | ||
|
|
12faaaced8 |
8
.github/workflows/sync-wiki.yml
vendored
8
.github/workflows/sync-wiki.yml
vendored
@@ -26,6 +26,8 @@ jobs:
|
|||||||
- name: Commit and Push Changes
|
- name: Commit and Push Changes
|
||||||
run: |
|
run: |
|
||||||
cd wiki
|
cd wiki
|
||||||
git add .
|
if git diff --name-only; then
|
||||||
git commit -m "Update wiki"
|
git add .
|
||||||
git push
|
git commit -m "Update wiki"
|
||||||
|
git push
|
||||||
|
fi
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ jobs:
|
|||||||
- name: Check for changes in cmdpriv-template.json
|
- name: Check for changes in cmdpriv-template.json
|
||||||
id: check_changes
|
id: check_changes
|
||||||
run: |
|
run: |
|
||||||
if git diff --name-only | grep -q "cmdpriv-template.json"; then
|
if git diff --name-only | grep -q "res/templates/cmdpriv-template.json"; then
|
||||||
echo "::set-output name=changes_detected::true"
|
echo "::set-output name=changes_detected::true"
|
||||||
else
|
else
|
||||||
echo "::set-output name=changes_detected::false"
|
echo "::set-output name=changes_detected::false"
|
||||||
@@ -53,6 +53,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
git config --global user.name "GitHub Actions Bot"
|
git config --global user.name "GitHub Actions Bot"
|
||||||
git config --global user.email "<github-actions@github.com>"
|
git config --global user.email "<github-actions@github.com>"
|
||||||
git add cmdpriv-template.json
|
git add res/templates/cmdpriv-template.json
|
||||||
git commit -m "Update cmdpriv-template.json"
|
git commit -m "Update cmdpriv-template.json"
|
||||||
git push
|
git push
|
||||||
|
|||||||
84
pkg/qqbot/cmds/system/cconfig.py
Normal file
84
pkg/qqbot/cmds/system/cconfig.py
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
from ..aamgr import AbstractCommandNode, Context
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
def config_operation(cmd, params):
|
||||||
|
reply = []
|
||||||
|
import pkg.utils.context
|
||||||
|
config = pkg.utils.context.get_config()
|
||||||
|
reply_str = ""
|
||||||
|
if len(params) == 0:
|
||||||
|
reply = ["[bot]err:请输入配置项"]
|
||||||
|
else:
|
||||||
|
cfg_name = params[0]
|
||||||
|
if cfg_name == 'all':
|
||||||
|
reply_str = "[bot]所有配置项:\n\n"
|
||||||
|
for cfg in dir(config):
|
||||||
|
if not cfg.startswith('__') and not cfg == 'logging':
|
||||||
|
# 根据配置项类型进行格式化,如果是字典则转换为json并格式化
|
||||||
|
if isinstance(getattr(config, cfg), str):
|
||||||
|
reply_str += "{}: \"{}\"\n".format(cfg, getattr(config, cfg))
|
||||||
|
elif isinstance(getattr(config, cfg), dict):
|
||||||
|
# 不进行unicode转义,并格式化
|
||||||
|
reply_str += "{}: {}\n".format(cfg,
|
||||||
|
json.dumps(getattr(config, cfg),
|
||||||
|
ensure_ascii=False, indent=4))
|
||||||
|
else:
|
||||||
|
reply_str += "{}: {}\n".format(cfg, getattr(config, cfg))
|
||||||
|
reply = [reply_str]
|
||||||
|
elif cfg_name in dir(config):
|
||||||
|
if len(params) == 1:
|
||||||
|
# 按照配置项类型进行格式化
|
||||||
|
if isinstance(getattr(config, cfg_name), str):
|
||||||
|
reply_str = "[bot]配置项{}: \"{}\"\n".format(cfg_name, getattr(config, cfg_name))
|
||||||
|
elif isinstance(getattr(config, cfg_name), dict):
|
||||||
|
reply_str = "[bot]配置项{}: {}\n".format(cfg_name,
|
||||||
|
json.dumps(getattr(config, cfg_name),
|
||||||
|
ensure_ascii=False, indent=4))
|
||||||
|
else:
|
||||||
|
reply_str = "[bot]配置项{}: {}\n".format(cfg_name, getattr(config, cfg_name))
|
||||||
|
reply = [reply_str]
|
||||||
|
else:
|
||||||
|
cfg_value = " ".join(params[1:])
|
||||||
|
# 类型转换,如果是json则转换为字典
|
||||||
|
if cfg_value == 'true':
|
||||||
|
cfg_value = True
|
||||||
|
elif cfg_value == 'false':
|
||||||
|
cfg_value = False
|
||||||
|
elif cfg_value.isdigit():
|
||||||
|
cfg_value = int(cfg_value)
|
||||||
|
elif cfg_value.startswith('{') and cfg_value.endswith('}'):
|
||||||
|
cfg_value = json.loads(cfg_value)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
cfg_value = float(cfg_value)
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# 检查类型是否匹配
|
||||||
|
if isinstance(getattr(config, cfg_name), type(cfg_value)):
|
||||||
|
setattr(config, cfg_name, cfg_value)
|
||||||
|
pkg.utils.context.set_config(config)
|
||||||
|
reply = ["[bot]配置项{}修改成功".format(cfg_name)]
|
||||||
|
else:
|
||||||
|
reply = ["[bot]err:配置项{}类型不匹配".format(cfg_name)]
|
||||||
|
|
||||||
|
else:
|
||||||
|
reply = ["[bot]err:未找到配置项 {}".format(cfg_name)]
|
||||||
|
|
||||||
|
return reply
|
||||||
|
|
||||||
|
|
||||||
|
@AbstractCommandNode.register(
|
||||||
|
parent=None,
|
||||||
|
name="cfg",
|
||||||
|
description="配置项管理",
|
||||||
|
usage="!cfg <配置项> [配置值]\n!cfg all",
|
||||||
|
aliases=[],
|
||||||
|
privilege=2
|
||||||
|
)
|
||||||
|
class CfgCommand(AbstractCommandNode):
|
||||||
|
@classmethod
|
||||||
|
def process(cls, ctx: Context) -> tuple[bool, list]:
|
||||||
|
return True, config_operation(ctx.command, ctx.params)
|
||||||
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -13,5 +13,5 @@ for key in cmdsmgr.__command_list__:
|
|||||||
template[key] = cmdsmgr.__command_list__[key]['privilege']
|
template[key] = cmdsmgr.__command_list__[key]['privilege']
|
||||||
|
|
||||||
# 写入cmdpriv-template.json
|
# 写入cmdpriv-template.json
|
||||||
with open('cmdpriv-template.json', 'w') as f:
|
with open('res/templates/cmdpriv-template.json', 'w') as f:
|
||||||
f.write(json.dumps(template, indent=4, ensure_ascii=False))
|
f.write(json.dumps(template, indent=4, ensure_ascii=False))
|
||||||
@@ -19,6 +19,7 @@
|
|||||||
"prompt": 1,
|
"prompt": 1,
|
||||||
"resend": 1,
|
"resend": 1,
|
||||||
"reset": 1,
|
"reset": 1,
|
||||||
|
"cfg": 2,
|
||||||
"cmd": 1,
|
"cmd": 1,
|
||||||
"help": 1,
|
"help": 1,
|
||||||
"reload": 2,
|
"reload": 2,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## 简介
|
## 简介
|
||||||
|
|
||||||
调用OpenAI官方提供的API接口,结合mirai和YiriMirai框架,将QQ消息与语言模型连接,实现更加智能的对话机器人。
|
调用OpenAI官方提供的API接口,结合mirai和YiriMirai框架,将QQ消息与语言模型连接,实现更加智能的对话机器人
|
||||||
|
|
||||||
## 技术栈
|
## 技术栈
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user