-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sender actionable methods and fix some bugs
- Loading branch information
Showing
13 changed files
with
169 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
kotlin.code.style=official | ||
|
||
libVersion=1.7.2 | ||
libVersion=1.8.0 |
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
81 changes: 81 additions & 0 deletions
81
src/main/kotlin/cn/rtast/rob/entity/internal/UserActionable.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,81 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/9/18 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.entity.internal | ||
|
||
import cn.rtast.rob.exceptions.IllegalDurationException | ||
import cn.rtast.rob.exceptions.IllegalLikeTimesException | ||
import cn.rtast.rob.util.ob.MessageChain | ||
|
||
|
||
interface UserActionable { | ||
|
||
/** | ||
* 赞用户的名片 | ||
*/ | ||
suspend fun sendLike(times: Int) { | ||
if (times !in 1..10) { | ||
throw IllegalLikeTimesException("Like times must in 1 ~ 10 >>> $times") | ||
} | ||
} | ||
|
||
/** | ||
* 发送纯文本消息 | ||
*/ | ||
suspend fun sendMessage(content: String) | ||
|
||
/** | ||
* 发送数组消息链消息 | ||
*/ | ||
suspend fun sendMessage(content: MessageChain) | ||
} | ||
|
||
interface GroupUserActionable : UserActionable { | ||
|
||
/** | ||
* 将用户踢出群聊可以设置是否拒绝加群请求 | ||
*/ | ||
suspend fun kick(rejectJoinRequest: Boolean) | ||
|
||
/** | ||
* 带有默认值的踢出群员(允许加群请求) | ||
*/ | ||
suspend fun kick() { | ||
this.kick(false) | ||
} | ||
|
||
/** | ||
* 设置群员禁言,时长单位为秒(s) | ||
*/ | ||
suspend fun ban(duration: Int) { | ||
if (duration <= 0) { | ||
throw IllegalDurationException("Duration must great than 0(>0) >>> $duration") | ||
} | ||
} | ||
|
||
/** | ||
* 带有默认值的禁言(30分钟 30 * 60s) | ||
*/ | ||
suspend fun ban() { | ||
this.ban(30 * 60) | ||
} | ||
|
||
/** | ||
* 设置群员的群昵称 | ||
*/ | ||
suspend fun setGroupCard(card: String?) | ||
|
||
/** | ||
* 设置群员管理员, enable为true则为设置为false则取消设置 | ||
*/ | ||
suspend fun setGroupAdmin(enable: Boolean) | ||
} | ||
|
||
/** | ||
* 私聊消息的可执行操作 | ||
*/ | ||
interface PrivateUserActionable : UserActionable |
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
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/cn/rtast/rob/exceptions/IllegalDurationException.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,10 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/9/18 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.exceptions | ||
|
||
class IllegalDurationException(override val message: String): Exception(message) |
10 changes: 10 additions & 0 deletions
10
src/main/kotlin/cn/rtast/rob/exceptions/IllegalLikeTimesException.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,10 @@ | ||
/* | ||
* Copyright © 2024 RTAkland | ||
* Author: RTAkland | ||
* Date: 2024/9/18 | ||
*/ | ||
|
||
|
||
package cn.rtast.rob.exceptions | ||
|
||
class IllegalLikeTimesException(override val message: String) : Exception(message) |
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