Skip to content

Commit 70ff6e1

Browse files
committed
feat: implement friend nudge, profile like
1 parent 99bfc27 commit 70ff6e1

8 files changed

Lines changed: 132 additions & 7 deletions

File tree

acidify-core/src/commonMain/kotlin/org/ntqqrev/acidify/Bot.kt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,43 @@ class Bot(
10521052
)
10531053
}
10541054

1055+
/**
1056+
* 发送好友戳一戳
1057+
* @param friendUin 好友 QQ 号
1058+
* @param isSelf 是否戳自己(默认为 false)
1059+
*/
1060+
suspend fun sendFriendNudge(
1061+
friendUin: Long,
1062+
isSelf: Boolean = false
1063+
) {
1064+
client.callService(
1065+
SendFriendNudge,
1066+
SendFriendNudge.Req(
1067+
friendUin = friendUin,
1068+
isSelf = isSelf
1069+
)
1070+
)
1071+
}
1072+
1073+
/**
1074+
* 给好友点赞
1075+
* @param friendUin 好友 QQ 号
1076+
* @param count 点赞次数(默认为 1)
1077+
*/
1078+
suspend fun sendProfileLike(
1079+
friendUin: Long,
1080+
count: Int = 1
1081+
) {
1082+
val friendUid = getUidByUin(friendUin)
1083+
client.callService(
1084+
SendProfileLike,
1085+
SendProfileLike.Req(
1086+
targetUid = friendUid,
1087+
count = count
1088+
)
1089+
)
1090+
}
1091+
10551092
/**
10561093
* 上传群文件
10571094
* @param groupUin 群号
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.ntqqrev.acidify.internal.packet.oidb
2+
3+
import org.ntqqrev.acidify.pb.PbInt32
4+
import org.ntqqrev.acidify.pb.PbSchema
5+
import org.ntqqrev.acidify.pb.PbString
6+
7+
internal object ProfileLikeReq : PbSchema() {
8+
val targetUid = PbString[11]
9+
val field2 = PbInt32[12]
10+
val field3 = PbInt32[13]
11+
}

acidify-core/src/commonMain/kotlin/org/ntqqrev/acidify/internal/packet/oidb/Oidb.0xed3_1.kt

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import org.ntqqrev.acidify.pb.PbInt32
44
import org.ntqqrev.acidify.pb.PbInt64
55
import org.ntqqrev.acidify.pb.PbSchema
66

7-
internal object SendGroupPokeReq : PbSchema() {
8-
val uin = PbInt64[1]
9-
val groupCode = PbInt64[2]
10-
val friendUin = PbInt64[3]
11-
val ext = PbInt32[11]
12-
}
13-
7+
internal object PokeReq : PbSchema() {
8+
val targetUin = PbInt64[1]
9+
val groupUin = PbInt64[2]
10+
val friendUin = PbInt64[5]
11+
val ext = PbInt32[6]
12+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.ntqqrev.acidify.internal.service.message
2+
3+
import org.ntqqrev.acidify.internal.LagrangeClient
4+
import org.ntqqrev.acidify.internal.packet.oidb.PokeReq
5+
import org.ntqqrev.acidify.internal.service.NoOutputOidbService
6+
import org.ntqqrev.acidify.pb.invoke
7+
8+
internal object SendFriendNudge : NoOutputOidbService<SendFriendNudge.Req>(0xed3, 1) {
9+
class Req(
10+
val friendUin: Long,
11+
val isSelf: Boolean = false
12+
)
13+
14+
override fun buildOidb(client: LagrangeClient, payload: Req): ByteArray =
15+
PokeReq {
16+
it[targetUin] = if (payload.isSelf) client.sessionStore.uin else payload.friendUin
17+
it[groupUin] = 0
18+
it[friendUin] = payload.friendUin
19+
it[ext] = 0
20+
}.toByteArray()
21+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.ntqqrev.acidify.internal.service.system
2+
3+
import org.ntqqrev.acidify.internal.LagrangeClient
4+
import org.ntqqrev.acidify.internal.packet.oidb.ProfileLikeReq
5+
import org.ntqqrev.acidify.internal.service.NoOutputOidbService
6+
import org.ntqqrev.acidify.pb.invoke
7+
8+
internal object SendProfileLike : NoOutputOidbService<SendProfileLike.Req>(0x7e5, 104) {
9+
class Req(
10+
val targetUid: String,
11+
val count: Int
12+
)
13+
14+
override fun buildOidb(client: LagrangeClient, payload: Req): ByteArray =
15+
ProfileLikeReq {
16+
it[targetUid] = payload.targetUid
17+
it[field2] = 71
18+
it[field3] = payload.count
19+
}.toByteArray()
20+
}

yogurt/src/commonMain/kotlin/org/ntqqrev/yogurt/api/HttpRoutes.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import org.ntqqrev.acidify.util.log.Logger
1212
import org.ntqqrev.milky.ApiGeneralResponse
1313
import org.ntqqrev.milky.milkyJsonModule
1414
import org.ntqqrev.yogurt.api.file.UploadGroupFile
15+
import org.ntqqrev.yogurt.api.friend.SendFriendNudge
16+
import org.ntqqrev.yogurt.api.friend.SendProfileLike
1517
import org.ntqqrev.yogurt.api.group.*
1618
import org.ntqqrev.yogurt.api.message.*
1719
import org.ntqqrev.yogurt.api.system.*
@@ -117,6 +119,9 @@ fun Route.configureMilkyApiHttpRoutes() {
117119
serve(GetForwardedMessages)
118120
serve(MarkMessageAsRead)
119121

122+
serve(SendFriendNudge)
123+
serve(SendProfileLike)
124+
120125
serve(SetGroupName)
121126
serve(SetGroupAvatar)
122127
serve(SetGroupMemberCard)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.ntqqrev.yogurt.api.friend
2+
3+
import io.ktor.server.plugins.di.*
4+
import io.ktor.server.routing.*
5+
import org.ntqqrev.acidify.Bot
6+
import org.ntqqrev.milky.ApiEndpoint
7+
import org.ntqqrev.milky.SendFriendNudgeOutput
8+
import org.ntqqrev.yogurt.util.invoke
9+
10+
val SendFriendNudge = ApiEndpoint.SendFriendNudge {
11+
val bot = application.dependencies.resolve<Bot>()
12+
13+
bot.sendFriendNudge(it.userId, it.isSelf)
14+
15+
SendFriendNudgeOutput()
16+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.ntqqrev.yogurt.api.friend
2+
3+
import io.ktor.server.plugins.di.*
4+
import io.ktor.server.routing.*
5+
import org.ntqqrev.acidify.Bot
6+
import org.ntqqrev.milky.ApiEndpoint
7+
import org.ntqqrev.milky.SendProfileLikeOutput
8+
import org.ntqqrev.yogurt.util.invoke
9+
10+
val SendProfileLike = ApiEndpoint.SendProfileLike {
11+
val bot = application.dependencies.resolve<Bot>()
12+
13+
bot.sendProfileLike(it.userId, it.count)
14+
15+
SendProfileLikeOutput()
16+
}

0 commit comments

Comments
 (0)