diff --git a/onebot/src/main/kotlin/client/core/Bot.kt b/onebot/src/main/kotlin/client/core/Bot.kt index d96771e5..192a45ab 100644 --- a/onebot/src/main/kotlin/client/core/Bot.kt +++ b/onebot/src/main/kotlin/client/core/Bot.kt @@ -1494,4 +1494,38 @@ class Bot( val result = actionHandler.action(this, action, params) return result.withToken() } + + /** + * 好友戳一戳 + * + * LLOnebot、NapCat + * @param userId 好友QQ号 + * @return [ActionRaw] + */ + suspend fun extFriendPoke(userId: Long): ActionRaw { + val action = ActionPathEnum.EXT_FRIEND_POKE + val params = JsonObject().apply { + addProperty("user_id", userId) + } + val result = actionHandler.action(this, action, params) + return result.withClass() + } + + /** + * 群聊戳一戳 + * + * LLOnebot、NapCat + * @param groupId 群号 + * @param userId 好友QQ号 + * @return [ActionRaw] + */ + suspend fun extGroupPoke(groupId: Long, userId: Long): ActionRaw { + val action = ActionPathEnum.EXT_GROUP_POKE + val params = JsonObject().apply { + addProperty("group_id", groupId) + addProperty("user_id", userId) + } + val result = actionHandler.action(this, action, params) + return result.withClass() + } } diff --git a/onebot/src/main/kotlin/sdk/enums/ActionPathEnum.kt b/onebot/src/main/kotlin/sdk/enums/ActionPathEnum.kt index 300cfb78..ed46306d 100644 --- a/onebot/src/main/kotlin/sdk/enums/ActionPathEnum.kt +++ b/onebot/src/main/kotlin/sdk/enums/ActionPathEnum.kt @@ -311,6 +311,20 @@ enum class ActionPathEnum( */ EXT_GET_AVATAR("get_avatar"), + /** + * 好友戳一戳 + * + * 属于 LLOnebot, NapCat 扩展 API + */ + EXT_FRIEND_POKE("friend_poke"), + + /** + * 群聊戳一戳 + * + * 属于 LLOnebot, NapCat 扩展 API + */ + EXT_GROUP_POKE("group_poke"), + /** * 创建群文件夹 */ diff --git a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/Overflow.kt b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/Overflow.kt index 3f5163cb..d0bfd149 100644 --- a/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/Overflow.kt +++ b/overflow-core/src/main/kotlin/top/mrxiaom/overflow/internal/Overflow.kt @@ -541,11 +541,23 @@ class Overflow : IMirai, CoroutineScope, LowLevelApiAccessor, OverflowAPI { } override suspend fun sendNudge(bot: Bot, nudge: Nudge, receiver: Contact): Boolean { - val msg = "[{\"type\":\"touch\",\"data\":{\"id\":${nudge.target.id}}}]" + val onebot = bot.asOnebot + when (onebot.appName.lowercase()) { + "llonebot", "napcat" -> { + if (receiver is Group) { + onebot.impl.extGroupPoke(receiver.id, nudge.target.id) + } else { + onebot.impl.extFriendPoke(receiver.id) + } + return true + } + } + // go-cqhttp + val msg = "[{\"type\":\"poke\",\"data\":{\"id\":${nudge.target.id}}}]" if (receiver is Group) { - bot.asOnebot.impl.sendGroupMsg(receiver.id, msg, false) + onebot.impl.sendGroupMsg(receiver.id, msg, false) } else { - bot.asOnebot.impl.sendPrivateMsg(receiver.id, msg, false) + onebot.impl.sendPrivateMsg(receiver.id, msg, false) } return true }