1
0
mirror of https://github.com/Mrs4s/go-cqhttp.git synced 2025-05-04 19:17:37 +08:00

feat enable_self_message config.

This commit is contained in:
Mrs4s 2021-03-03 19:14:24 +08:00
parent 93da16897a
commit a90af94eda
3 changed files with 55 additions and 47 deletions

View File

@ -61,7 +61,9 @@ func NewQQBot(cli *client.QQClient, conf *global.JSONConfig) *CQBot {
} }
bot.Client.OnPrivateMessage(bot.privateMessageEvent) bot.Client.OnPrivateMessage(bot.privateMessageEvent)
bot.Client.OnGroupMessage(bot.groupMessageEvent) bot.Client.OnGroupMessage(bot.groupMessageEvent)
bot.Client.OnSelfGroupMessage(bot.groupMessageEvent) if conf.EnableSelfMessage {
bot.Client.OnSelfGroupMessage(bot.groupMessageEvent)
}
bot.Client.OnTempMessage(bot.tempMessageEvent) bot.Client.OnTempMessage(bot.tempMessageEvent)
bot.Client.OnGroupMuted(bot.groupMutedEvent) bot.Client.OnGroupMuted(bot.groupMutedEvent)
bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent) bot.Client.OnGroupMessageRecalled(bot.groupRecallEvent)

View File

@ -4,7 +4,7 @@ go-cqhttp 包含 `config.hjson` 和 `device.json` 两个配置文件, 其中 `co
## 从原CQHTTP导入配置 ## 从原CQHTTP导入配置
go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为: go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
1. 找到CQHTTP原配置文件 `{CQ工作目录}/app/io.github.richardchien.coolqhttpapi/config/{qq号}.json` 1. 找到CQHTTP原配置文件 `{CQ工作目录}/app/io.github.richardchien.coolqhttpapi/config/{qq号}.json`
2. 将文件复制到go-cqhttp根目录并重命名为 `cqhttp.json` 2. 将文件复制到go-cqhttp根目录并重命名为 `cqhttp.json`
@ -12,52 +12,55 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
## 配置信息 ## 配置信息
默认生成的配置文件如下所示: 默认生成的配置文件如下所示:
````json ````json
{ {
"uin": 0, "uin": 0,
"password": "", "password": "",
"encrypt_password": false, "encrypt_password": false,
"password_encrypted": "", "password_encrypted": "",
"enable_db": true, "enable_db": true,
"access_token": "", "enable_self_message": false,
"relogin": { "access_token": "",
"enabled": true, "relogin": {
"relogin_delay": 3, "enabled": true,
"max_relogin_times": 0 "relogin_delay": 3,
}, "max_relogin_times": 0
"_rate_limit": { },
"enabled": false, "_rate_limit": {
"frequency": 1, "enabled": false,
"bucket_size": 1 "frequency": 1,
}, "bucket_size": 1
"post_message_format": "string", },
"ignore_invalid_cqcode": false, "post_message_format": "string",
"force_fragmented": true, "ignore_invalid_cqcode": false,
"heartbeat_interval": 5, "force_fragmented": true,
"use_sso_address": false, "heartbeat_interval": 5,
"http_config": { "use_sso_address": false,
"enabled": true, "http_config": {
"host": "0.0.0.0", "enabled": true,
"port": 5700, "host": "0.0.0.0",
"timeout": 5, "port": 5700,
"post_urls": {"url:port": "secret"} "timeout": 5,
}, "post_urls": {
"ws_config": { "url:port": "secret"
"enabled": true, }
"host": "0.0.0.0", },
"port": 6700 "ws_config": {
}, "enabled": true,
"ws_reverse_servers": [ "host": "0.0.0.0",
{ "port": 6700
"enabled": false, },
"reverse_url": "ws://you_websocket_universal.server", "ws_reverse_servers": [
"reverse_api_url": "ws://you_websocket_api.server", {
"reverse_event_url": "ws://you_websocket_event.server", "enabled": false,
"reverse_reconnect_interval": 3000 "reverse_url": "ws://you_websocket_universal.server",
} "reverse_api_url": "ws://you_websocket_api.server",
] "reverse_event_url": "ws://you_websocket_event.server",
"reverse_reconnect_interval": 3000
}
]
} }
```` ````
@ -68,6 +71,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
| encrypt_password | bool | 是否对密码进行加密. | | encrypt_password | bool | 是否对密码进行加密. |
| password_encrypted | string | 加密后的密码(请勿修改) | | password_encrypted | string | 加密后的密码(请勿修改) |
| enable_db | bool | 是否开启内置数据库, 关闭后将无法使用 **回复/撤回** 等上下文相关接口 | | enable_db | bool | 是否开启内置数据库, 关闭后将无法使用 **回复/撤回** 等上下文相关接口 |
| enable_self_message | bool | 是否启用 `message_sent` 事件 |
| access_token | string | 同CQHTTP的 `access_token` 用于身份验证 | | access_token | string | 同CQHTTP的 `access_token` 用于身份验证 |
| relogin | bool | 是否自动重新登录 | | relogin | bool | 是否自动重新登录 |
| relogin_delay | int | 重登录延时(秒) | | relogin_delay | int | 重登录延时(秒) |
@ -96,7 +100,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
## 设备信息 ## 设备信息
默认生成的设备信息如下所示: 默认生成的设备信息如下所示:
``` json ``` json
{ {
@ -109,7 +113,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
} }
``` ```
在大部分情况下 我们只需要关心 `protocol` 字段: 在大部分情况下 我们只需要关心 `protocol` 字段:
| 值 | 类型 | 限制 | | 值 | 类型 | 限制 |
| --- | ------------- | ---------------------------------------------------------------- | | --- | ------------- | ---------------------------------------------------------------- |
@ -127,6 +131,7 @@ go-cqhttp 支持导入CQHTTP的配置文件, 具体步骤为:
将文件 `address.txt` 创建到 `go-cqhttp` 工作目录, 并键入 `IP:PORT` 以换行符为分割即可. 将文件 `address.txt` 创建到 `go-cqhttp` 工作目录, 并键入 `IP:PORT` 以换行符为分割即可.
示例: 示例:
```` ````
1.1.1.1:53 1.1.1.1:53
1.1.2.2:8899 1.1.2.2:8899

View File

@ -145,6 +145,7 @@ type JSONConfig struct {
EncryptPassword bool `json:"encrypt_password"` EncryptPassword bool `json:"encrypt_password"`
PasswordEncrypted string `json:"password_encrypted"` PasswordEncrypted string `json:"password_encrypted"`
EnableDB bool `json:"enable_db"` EnableDB bool `json:"enable_db"`
EnableSelfMessage bool `json:"enable_self_message"`
AccessToken string `json:"access_token"` AccessToken string `json:"access_token"`
ReLogin struct { ReLogin struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`