-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
287 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/kotlin/me/kuku/telegram/entity/NetEaseSmallEntity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package me.kuku.telegram.entity | ||
|
||
import kotlinx.coroutines.flow.toList | ||
import org.springframework.data.annotation.Id | ||
import org.springframework.data.mongodb.core.mapping.Document | ||
import org.springframework.data.repository.kotlin.CoroutineCrudRepository | ||
import org.springframework.stereotype.Service | ||
|
||
@Document("net_ease_small") | ||
class NetEaseSmallEntity { | ||
@Id | ||
var id: String? = null | ||
var username: String = "" | ||
var password: String = "" | ||
var musicU: String = "" | ||
var csrf: String = "" | ||
|
||
fun cookie() = "channel=netease; __remember_me=true; MUSIC_U=$musicU; __csrf=$csrf; " | ||
} | ||
|
||
interface NetEaseSmallRepository: CoroutineCrudRepository<NetEaseSmallEntity, String> { | ||
suspend fun findByUsername(username: String): NetEaseSmallEntity? | ||
} | ||
|
||
@Service | ||
class NetEaseSmallService( | ||
private val netEaseSmallRepository: NetEaseSmallRepository | ||
) { | ||
suspend fun save(netEaseSmallEntity: NetEaseSmallEntity): NetEaseSmallEntity = netEaseSmallRepository.save(netEaseSmallEntity) | ||
|
||
suspend fun findByUsername(username: String): NetEaseSmallEntity? = netEaseSmallRepository.findByUsername(username) | ||
|
||
suspend fun findAll(): List<NetEaseSmallEntity> = netEaseSmallRepository.findAll().toList() | ||
|
||
suspend fun delete(entity: NetEaseSmallEntity) = netEaseSmallRepository.delete(entity) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/kotlin/me/kuku/telegram/extension/NetEaseSmallExtension.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package me.kuku.telegram.extension | ||
|
||
import me.kuku.telegram.context.AbilitySubscriber | ||
import me.kuku.telegram.context.nextMessage | ||
import me.kuku.telegram.entity.NetEaseSmallEntity | ||
import me.kuku.telegram.entity.NetEaseSmallService | ||
import org.springframework.stereotype.Service | ||
|
||
@Service | ||
class NetEaseSmallExtension( | ||
private val netEaseSmallService: NetEaseSmallService | ||
) { | ||
|
||
fun AbilitySubscriber.netEaseSmall() { | ||
sub(name = "netEaseSmall") { | ||
sendMessage(""" | ||
请发送网易云小号,格式为:用户名----密码,一行一个 | ||
""".trimIndent()) | ||
val text = nextMessage().text() | ||
val firstArr = text.split("\n") | ||
for (line in firstArr) { | ||
val lineSplit = line.split("----") | ||
val username = lineSplit[0] | ||
var password = lineSplit[1] | ||
password.indexOf('-').takeIf { it > 0 }?.let { | ||
password = password.substring(0, it) | ||
} | ||
val netEaseSmallEntity = netEaseSmallService.findByUsername(username) ?: NetEaseSmallEntity() | ||
netEaseSmallEntity.username = username | ||
netEaseSmallEntity.password = password | ||
netEaseSmallService.save(netEaseSmallEntity) | ||
} | ||
sendMessage("保存网易云小号成功") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.