mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-24 14:30:09 +08:00
Get friendList, GroupList and MemberList
This commit is contained in:
parent
14a2df03d6
commit
5d7273d2f1
@ -27,6 +27,7 @@ fun Application.mirai() {
|
||||
|
||||
authModule()
|
||||
messageModule()
|
||||
infoModule()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,30 @@
|
||||
package net.mamoe.mirai.api.http.route
|
||||
|
||||
import io.ktor.application.Application
|
||||
import io.ktor.application.call
|
||||
import io.ktor.routing.routing
|
||||
import net.mamoe.mirai.api.http.dto.GroupDTO
|
||||
import net.mamoe.mirai.api.http.dto.MemberDTO
|
||||
import net.mamoe.mirai.api.http.dto.QQDTO
|
||||
import net.mamoe.mirai.api.http.dto.toJson
|
||||
import net.mamoe.mirai.contact.toMutableList
|
||||
|
||||
fun Application.infoModule() {
|
||||
routing {
|
||||
|
||||
miraiGet("/friendList") {
|
||||
val ls = it.bot.qqs.toMutableList().map { qq -> QQDTO(qq) }
|
||||
call.respondJson(ls.toJson())
|
||||
}
|
||||
|
||||
miraiGet("/groupList") {
|
||||
val ls = it.bot.groups.toMutableList().map { group -> GroupDTO(group) }
|
||||
call.respondJson(ls.toJson())
|
||||
}
|
||||
|
||||
miraiGet("/memberList") {
|
||||
val ls = it.bot.getGroup(paramOrNull("target")).members.toMutableList().map { member -> MemberDTO(member) }
|
||||
call.respondJson(ls.toJson())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user