Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
koishi-wrapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
koishi-wrapper
Commits
39fadbd3
Commit
39fadbd3
authored
May 04, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto read gocq config
parent
68f9c392
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
111 additions
and
1 deletion
+111
-1
config.yml
config.yml
+92
-0
index.ts
index.ts
+19
-1
No files found.
config.yml
0 → 100644
View file @
39fadbd3
# go-cqhttp 默认配置文件
account
:
# 账号相关
uin
:
2222222222
# QQ账号
password
:
'
'
# 密码为空时使用扫码登录
encrypt
:
false
# 是否开启密码加密
status
:
0
# 在线状态 请参考 https://docs.go-cqhttp.org/guide/config.html#在线状态
relogin
:
# 重连设置
delay
:
3
# 首次重连延迟, 单位秒
interval
:
3
# 重连间隔
max-times
:
0
# 最大重连次数, 0为无限制
# 是否使用服务器下发的新地址进行重连
# 注意, 此设置可能导致在海外服务器上连接情况更差
use-sso-address
:
true
heartbeat
:
# 心跳频率, 单位秒
# -1 为关闭心跳
interval
:
5
message
:
# 上报数据类型
# 可选: string,array
post-format
:
string
# 是否忽略无效的CQ码, 如果为假将原样发送
ignore-invalid-cqcode
:
true
# 是否强制分片发送消息
# 分片发送将会带来更快的速度
# 但是兼容性会有些问题
force-fragment
:
false
# 是否将url分片发送
fix-url
:
false
# 下载图片等请求网络代理
proxy-rewrite
:
'
'
# 是否上报自身消息
report-self-message
:
false
# 移除服务端的Reply附带的At
remove-reply-at
:
false
# 为Reply附加更多信息
extra-reply-data
:
false
# 跳过 Mime 扫描, 忽略错误数据
skip-mime-scan
:
false
output
:
# 日志等级 trace,debug,info,warn,error
log-level
:
warn
# 日志时效 单位天. 超过这个时间之前的日志将会被自动删除. 设置为 0 表示永久保留.
log-aging
:
15
# 是否在每次启动时强制创建全新的文件储存日志. 为 false 的情况下将会在上次启动时创建的日志文件续写
log-force-new
:
true
# 是否启用 DEBUG
debug
:
false
# 开启调试模式
# 默认中间件锚点
default-middlewares
:
&default
# 访问密钥, 强烈推荐在公网的服务器设置
access-token
:
'
JdkTapiX8sjKmeYeIT4qt0DIhtCa0fdxa'
# 事件过滤器文件目录
filter
:
'
'
# API限速设置
# 该设置为全局生效
# 原 cqhttp 虽然启用了 rate_limit 后缀, 但是基本没插件适配
# 目前该限速设置为令牌桶算法, 请参考:
# https://baike.baidu.com/item/%E4%BB%A4%E7%89%8C%E6%A1%B6%E7%AE%97%E6%B3%95/6597000?fr=aladdin
rate-limit
:
enabled
:
false
# 是否启用限速
frequency
:
1
# 令牌回复频率, 单位秒
bucket
:
1
# 令牌桶大小
database
:
# 数据库相关设置
leveldb
:
# 是否启用内置leveldb数据库
# 启用将会增加10-20MB的内存占用和一定的磁盘空间
# 关闭将无法使用 撤回 回复 get_msg 等上下文相关功能
enable
:
true
# 连接服务列表
servers
:
# 添加方式,同一连接方式可添加多个,具体配置说明请查看文档
#- http: # http 通信
#- ws: # 正向 Websocket
#- ws-reverse: # 反向 Websocket
#- pprof: #性能分析服务器
# 正向WS设置
-
ws
:
# 正向WS服务器监听地址
host
:
127.0.0.1
# 正向WS服务器监听端口
port
:
6700
middlewares
:
<<
:
*default
# 引用默认中间件
index.ts
View file @
39fadbd3
import
{
App
,
Session
}
from
'
koishi
'
;
import
{
App
,
Logger
,
Session
}
from
'
koishi
'
;
import
koishiPluginOnebot
,
{
BotConfig
}
from
'
@koishijs/plugin-adapter-onebot
'
;
import
koishiPluginOnebot
,
{
BotConfig
}
from
'
@koishijs/plugin-adapter-onebot
'
;
import
*
as
koishiPluginVerifier
from
'
@koishijs/plugin-verifier
'
;
import
*
as
koishiPluginVerifier
from
'
@koishijs/plugin-verifier
'
;
import
{
Adapter
}
from
'
koishi
'
;
import
{
Adapter
}
from
'
koishi
'
;
...
@@ -16,6 +16,22 @@ interface Config {
...
@@ -16,6 +16,22 @@ interface Config {
app
:
any
;
app
:
any
;
}
}
const
logger
=
new
Logger
(
'
wrapper
'
);
async
function
readCqConfig
():
Promise
<
BotConfig
>
{
try
{
const
config
=
yaml
.
parse
(
await
fs
.
readFile
(
'
./config.yml
'
,
'
utf-8
'
));
return
{
protocol
:
'
ws
'
,
endpoint
:
`ws://
${
config
.
servers
[
0
].
ws
.
host
}
:
${
config
.
servers
[
0
].
ws
.
port
}
`
,
selfId
:
`
${
config
.
account
.
uin
}
`
,
token
:
config
[
'
default-middlewares
'
][
'
access-token
'
],
};
}
catch
(
e
)
{
logger
.
error
(
`Failed to read cq config:
${
e
.
message
}
`
);
}
}
const
defaultConfig
:
Config
=
{
const
defaultConfig
:
Config
=
{
adapter
:
{
adapter
:
{
bots
:
[
bots
:
[
...
@@ -35,8 +51,10 @@ const defaultConfig: Config = {
...
@@ -35,8 +51,10 @@ const defaultConfig: Config = {
};
};
async
function
main
()
{
async
function
main
()
{
const
configFromGoCq
=
await
readCqConfig
();
const
config
:
Config
=
{
const
config
:
Config
=
{
...
defaultConfig
,
...
defaultConfig
,
...(
configFromGoCq
?
{
adapter
:
{
bots
:
[
configFromGoCq
]
}
}
:
{}),
...
yaml
.
parse
(
await
fs
.
readFile
(
'
./app-config.yaml
'
,
'
utf-8
'
)),
...
yaml
.
parse
(
await
fs
.
readFile
(
'
./app-config.yaml
'
,
'
utf-8
'
)),
};
};
const
app
=
new
App
({
const
app
=
new
App
({
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment