Skip to content

Commit 4dccdeb

Browse files
committed
modify password
1 parent 14dba8a commit 4dccdeb

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ plugins {
2828
}
2929

3030
group = "net.lz1998"
31-
version = "0.0.12"
31+
version = "0.0.13"
3232
java.sourceCompatibility = JavaVersion.VERSION_1_8
3333

3434
configurations {

src/main/kotlin/net/lz1998/mirai/entity/WebSocketBotClient.kt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,7 @@ import net.lz1998.mirai.service.MyLoginSolver
99
import net.lz1998.mirai.utils.*
1010
import net.mamoe.mirai.Bot
1111
import net.mamoe.mirai.BotFactory
12-
import net.mamoe.mirai.event.events.BotEvent
13-
import net.mamoe.mirai.event.events.BotInvitedJoinGroupRequestEvent
14-
import net.mamoe.mirai.event.events.MemberJoinRequestEvent
15-
import net.mamoe.mirai.event.events.NewFriendRequestEvent
12+
import net.mamoe.mirai.event.events.*
1613
import okhttp3.*
1714
import okio.ByteString
1815
import okio.ByteString.Companion.toByteString
@@ -34,7 +31,7 @@ class WebsocketBotClient(override var botId: Long, override var password: String
3431
private var lastWsConnectTime: Long = 0
3532
var connecting: Boolean = false
3633

37-
private var wsClient: WebSocket? = null
34+
var wsClient: WebSocket? = null
3835
private var httpClient: OkHttpClient = OkHttpClient.Builder()
3936
.callTimeout(20, TimeUnit.SECONDS)
4037
.connectTimeout(20, TimeUnit.SECONDS)

src/main/kotlin/net/lz1998/mirai/service/BotService.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
package net.lz1998.mirai.service
22

33
import dto.HttpDto
4-
import net.lz1998.mirai.entity.RemoteBot
54
import net.lz1998.mirai.entity.WebsocketBotClient
65
import net.lz1998.mirai.properties.ClientProperties
76
import org.springframework.beans.factory.annotation.Autowired
87
import org.springframework.stereotype.Service
98

109
@Service
1110
class BotService {
12-
val botMap = mutableMapOf<Long, RemoteBot>()
11+
val botMap = mutableMapOf<Long, WebsocketBotClient>()
1312

1413
@Autowired
1514
lateinit var clientProperties: ClientProperties
1615

1716
@Synchronized
1817
suspend fun createBot(botId: Long, password: String) {
1918
var bot = botMap[botId]
20-
if (bot == null) {
21-
bot = WebsocketBotClient(botId, password, wsUrl = clientProperties.wsUrl)
22-
botMap[botId] = bot
23-
bot.initBot()
24-
}
19+
// 如果有旧的,关掉旧的
20+
bot?.bot?.close()
21+
bot?.wsClient?.close(1001, "")
22+
23+
// 开新的
24+
bot = WebsocketBotClient(botId, password, wsUrl = clientProperties.wsUrl)
25+
botMap[botId] = bot
26+
bot.initBot()
2527
}
2628

2729
fun listBot(): Collection<HttpDto.Bot> {

src/main/kotlin/net/lz1998/mirai/service/MyLoginSolver.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import org.springframework.stereotype.Service
1111
object MyLoginSolver : LoginSolver() {
1212
// TODO 通过轮询查询 loginMap
1313
val loginMap = mutableMapOf<Long, LoginData>()
14+
override val isSliderCaptchaSupported: Boolean
15+
get() = true
1416

1517
// 图片验证码登陆
1618
override suspend fun onSolvePicCaptcha(bot: Bot, data: ByteArray): String? {

0 commit comments

Comments
 (0)