Skip to content

Commit

Permalink
Event: improved support for Stranger
Browse files Browse the repository at this point in the history
  • Loading branch information
PeratX committed Jan 14, 2021
1 parent a1eef4c commit 72c5e24
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,7 @@ object MiraiBridge {
writeShortLVPacket {
writeLong(qq.id)
writeString(qq.nick)
//TODO: 备注
writeString("")
writeString(qq.remark)
}
}
}.encodeBase64()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ object CacheManager {
fun getRecord(name: String) = records[name.replace(".mnrec", "")]

fun findUser(id: Long): User? {
val member = MiraiNative.bot.getFriend(id) ?: senders[id]
var member = MiraiNative.bot.getFriend(id) ?: senders[id]
if (member == null) {
member = MiraiNative.bot.strangers[id]
}
if (member == null) {
MiraiNative.bot.groups.forEach {
if (it[id] != null) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/kotlin/org/itxtech/mirainative/manager/EventManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ object EventManager {
)
}
}
subscribeAlways<StrangerMessageEvent> {
launchEvent {
NativeBridge.eventPrivateMessage(
Bridge.PRI_MSG_SUBTYPE_ONLINE_STATE,
CacheManager.cacheMessage(message.source, chain = message),
sender.id,
ChainCodeConverter.chainToCode(message),
0
)
}
}

// 权限事件
subscribeAlways<MemberPermissionChangeEvent> {
Expand Down

0 comments on commit 72c5e24

Please sign in to comment.