Skip to content

Commit

Permalink
add sending CQCode into configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXiaoM committed Jul 8, 2024
1 parent 8316cd6 commit 653f023
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Overflow 支持且**仅支持**连接到大多数标准的 Onebot 或 go-cqhttp
+ [x] 使用正向(主动)或反向(被动) WebSocket 连接
+ [x] 在连接时使用 token 鉴权
+ [x] 在代码中调用自定义的 action
+ [ ] 在消息中使用 CQ 码 *不支持*
+ [x] 在消息中使用 CQ 码 *测试中*
+ [x] 将 mirai 消息段序列化/反序列化为 json
+ [ ] 使用 MiraiCode (Mirai 码) 处理消息 *不支持*

Expand Down
1 change: 1 addition & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
| `reversed_ws_port` | `-1` | 反向WebSocket服务器端口,`-1` 为不开启反向WS。开启反向WS将会禁用正向WS连接 |
| `token` | | 鉴权令牌,留空则不进行鉴权 |
| `no_platform` | `false` | 是否禁止 Overflow 调用需要账号凭证的网络接口,如获取分享Key、群活跃等。在**非QQ平台****无法获取账号凭证**的平台 (如 Gensokyo) 使用 Overflow 请开启该选项 |
| `use_cq_code` | `false` | 发送消息时,是否使用 CQ 码格式 |
| `retry_times` | `5` | 正向WS断开连接后重连尝试次数,设为 `-1` 禁用自动重连 |
| `retry_wait_mills` | `5000` | 每次重连之间的间隔时间 (毫秒) |
| `retry_rest_mills` | `60000` | 重连次数用完后,等待多长时间 (毫秒) 后,重置次数再进行重连。设为 `-1` 禁用此功能 |
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class BotBuilder private constructor(
private var retryRestMills: Long = 60000L,
private var printInfo: Boolean = true,
private var noPlatform: Boolean = false,
private var useCQCode: Boolean = false,
private var logger: Logger? = null,
private var parentJob: Job? = null
) {
Expand Down Expand Up @@ -82,6 +83,15 @@ public class BotBuilder private constructor(
this.noPlatform = true
}

/**
* 发送消息时使用 CQ 码
*
* 即使不开启该选项,也可使用 CQ 码接收消息
*/
public fun useCQCode(): BotBuilder = apply {
this.useCQCode = true
}

/**
* 覆写用于 Onebot 的日志记录器
*/
Expand Down Expand Up @@ -112,6 +122,7 @@ public class BotBuilder private constructor(
retryRestMills = retryRestMills,
printInfo = printInfo,
noPlatform = noPlatform,
useCQCode = useCQCode,
logger = logger,
parentJob = parentJob
)
Expand Down Expand Up @@ -145,6 +156,7 @@ public interface IBotStarter {
retryRestMills: Long,
printInfo: Boolean,
noPlatform: Boolean,
useCQCode: Boolean,
logger: Logger?,
parentJob: Job?
): Bot?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ data class Config(
var token: String = "",
@SerialName("no_platform")
val noPlatform: Boolean = false,
@SerialName("use_cq_code")
val useCQCode: Boolean = false,
@SerialName("retry_times")
var retryTimes: Int = 5,
@SerialName("retry_wait_mills")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI {
token = config.token,
isAccessToken = config.token.isNotBlank(),
noPlatform = config.noPlatform,
useCQCode = config.useCQCode,
retryTimes = config.retryTimes,
retryWaitMills = config.retryWaitMills,
retryRestMills = config.retryRestMills,
Expand Down Expand Up @@ -273,6 +274,7 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI {
retryRestMills: Long,
printInfo: Boolean,
noPlatform: Boolean,
useCQCode: Boolean,
logger: Logger?,
parentJob: Job?
): Bot? {
Expand All @@ -282,6 +284,7 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI {
token = token,
isAccessToken = token.isNotBlank(),
noPlatform = noPlatform,
useCQCode = useCQCode,
retryTimes = retryTimes,
retryWaitMills = retryWaitMills,
retryRestMills = retryRestMills,
Expand Down

0 comments on commit 653f023

Please sign in to comment.