Skip to content

Commit

Permalink
Merge pull request #152 from simple-robot/dev/main
Browse files Browse the repository at this point in the history
Release: v4.0.0-beta4
  • Loading branch information
ForteScarlet authored Jun 15, 2024
2 parents 32bb7fb + 749474d commit 3f3d138
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .changelog/v4.0.0-beta4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> 对应核心版本: [**v4.0.0-RC3**](https://github.com/simple-robot/simpler-robot/releases/tag/v4.0.0-RC3)

我们欢迎并期望着您的的[反馈](https://github.com/simple-robot/simbot-component-qq-guild/issues)[协助](https://github.com/simple-robot/simbot-component-qq-guild/pulls)
感谢您的贡献与支持!

也欢迎您为我们献上一颗 `star`,这是对我们最大的鼓励与认可!
4 changes: 2 additions & 2 deletions Writerside/v.list
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
<var name="api-doc" value="https://docs.simbot.forte.love"/>
<var name="jb" value="阻塞"/>
<var name="ja" value="异步"/>
<var name="version" value="4.0.0-beta3"/>
<var name="minimum-core-version" value="4.0.0-RC3"/>
<var name="version" value="4.0.0-beta4"/>
<var name="minimum-core-version" value="4.0.0"/>
</vars>
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/P.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object P {
override val homepage: String get() = HOMEPAGE


private val baseVersion = v(4, 0, 0) - v("beta3")
private val baseVersion = v(4, 0, 0) - v("beta4")

val snapshotVersion = baseVersion - Version.SNAPSHOT
override val version = if (isSnapshot()) snapshotVersion else baseVersion
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ ktor = "2.3.8"
openjdk-jmh = "1.37"
log4j = "2.23.1"
# simbot
simbot = "4.0.0-RC3"
suspendTransform = "0.8.0-beta1"
simbot = "4.0.0"
suspendTransform = "0.9.0"
gradleCommon = "0.4.0"
# ksp
ksp = "2.0.0-1.0.22"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class MuteMemberApi private constructor(guildId: String, userId: String,
return when {
seconds == 0L -> MuteMemberApi(guildId, userId, MuteBody.Unmute)
seconds > 0L -> MuteMemberApi(guildId, userId, MuteBody(muteSeconds = seconds.toString()))
else -> throw IllegalStateException("mute seconds must >= 0, but $seconds")
else -> throw IllegalArgumentException("mute seconds must >= 0, but $seconds")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,11 @@ public abstract interface class love/forte/simbot/component/qguild/guild/QGMembe
public fun getJoinTime ()Llove/forte/simbot/common/time/Timestamp;
public fun getName ()Ljava/lang/String;
public fun getNick ()Ljava/lang/String;
public abstract fun mute (JLjava/util/concurrent/TimeUnit;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract synthetic fun mute-VtjQ1oo (JLkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun muteAsync (JLjava/util/concurrent/TimeUnit;)Ljava/util/concurrent/CompletableFuture;
public abstract fun muteBlocking (JLjava/util/concurrent/TimeUnit;)V
public abstract fun muteReserve (JLjava/util/concurrent/TimeUnit;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public abstract synthetic fun send (Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract synthetic fun send (Llove/forte/simbot/message/Message;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract synthetic fun send (Llove/forte/simbot/message/MessageContent;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand All @@ -1255,6 +1260,10 @@ public abstract interface class love/forte/simbot/component/qguild/guild/QGMembe
public fun sendReserve (Ljava/lang/String;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public fun sendReserve (Llove/forte/simbot/message/Message;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public fun sendReserve (Llove/forte/simbot/message/MessageContent;)Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
public abstract synthetic fun unmute (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun unmuteAsync ()Ljava/util/concurrent/CompletableFuture;
public fun unmuteBlocking ()V
public fun unmuteReserve ()Llove/forte/simbot/suspendrunner/reserve/SuspendReserve;
}

public final class love/forte/simbot/component/qguild/internal/bot/QGBotImpl$inlined$sam$i$java_util_function_Function$0 : java/util/function/Function {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import kotlinx.coroutines.CoroutineScope
import love.forte.simbot.common.collectable.Collectable
import love.forte.simbot.common.id.ID
import love.forte.simbot.common.id.StringID.Companion.ID
import love.forte.simbot.common.time.TimeUnit
import love.forte.simbot.common.time.Timestamp
import love.forte.simbot.component.qguild.ExperimentalQGApi
import love.forte.simbot.component.qguild.QGObjectiveContainer
Expand All @@ -36,7 +37,10 @@ import love.forte.simbot.message.MessageContent
import love.forte.simbot.message.Text
import love.forte.simbot.qguild.QQGuildApiException
import love.forte.simbot.qguild.api.MessageAuditedException
import love.forte.simbot.qguild.api.guild.mute.MuteMemberApi
import love.forte.simbot.suspendrunner.ST
import kotlin.jvm.JvmSynthetic
import kotlin.time.Duration
import love.forte.simbot.qguild.model.Member as QGSourceMember

/**
Expand Down Expand Up @@ -75,6 +79,7 @@ public interface QGMember : Member, CoroutineScope, QGObjectiveContainer<QGSourc
@OptIn(ExperimentalQGApi::class)
public val joinTime: Timestamp
get() = source.joinedAt.toTimestamp()

/**
* 成员拥有的角色
*/
Expand Down Expand Up @@ -120,4 +125,49 @@ public interface QGMember : Member, CoroutineScope, QGObjectiveContainer<QGSourc
*/
@ST
override suspend fun send(messageContent: MessageContent): QGMessageReceipt

/**
* 禁言频道服务器中的此成员。
*
* 如果 [duration] 所代表的秒值为 `0`
* 则代表取消禁言,同 [unmute]。
*
* 如果 [duration] 小于0则会抛出 [IllegalArgumentException]。
*
* @param duration 持续时间
*
* @see MuteMemberApi
*
* @throws QQGuildApiException 请求产生的异常
* @throws IllegalArgumentException 如果 [duration] 小于0
*/
@JvmSynthetic
public suspend fun mute(duration: Duration)

/**
* 禁言频道服务器中的此成员。
*
* 如果 [duration] 在单位 [unit]
* 下所代表的秒值为 `0` 则代表取消禁言,同 [unmute]。
*
* 如果 [duration] 小于0则会抛出 [IllegalArgumentException]。
*
* @param duration 持续时间
* @param unit [duration] 的时间单位
*
* @see MuteMemberApi
*
* @throws QQGuildApiException 请求产生的异常
* @throws IllegalArgumentException 如果 [duration] 小于0
*/
@ST
public suspend fun mute(duration: Long, unit: TimeUnit)

/**
* 取消此成员在频道服务器中的禁言状态。
*
* @throws QQGuildApiException 请求产生的异常
*/
@ST
public suspend fun unmute()
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import love.forte.simbot.common.collectable.asCollectable
import love.forte.simbot.common.id.ID
import love.forte.simbot.common.id.StringID.Companion.ID
import love.forte.simbot.common.id.literal
import love.forte.simbot.common.time.TimeUnit
import love.forte.simbot.component.qguild.ExperimentalQGApi
import love.forte.simbot.component.qguild.guild.QGMember
import love.forte.simbot.component.qguild.internal.bot.QGBotImpl
Expand All @@ -38,6 +39,7 @@ import love.forte.simbot.message.Message
import love.forte.simbot.message.MessageContent
import love.forte.simbot.qguild.QQGuildApiException
import love.forte.simbot.qguild.addStackTrace
import love.forte.simbot.qguild.api.guild.mute.MuteMemberApi
import love.forte.simbot.qguild.api.message.MessageSendApi
import love.forte.simbot.qguild.api.message.direct.CreateDmsApi
import love.forte.simbot.qguild.api.message.direct.DmsSendApi
Expand All @@ -46,6 +48,7 @@ import love.forte.simbot.qguild.stdlib.requestDataBy
import kotlin.concurrent.Volatile
import kotlin.coroutines.CoroutineContext
import kotlin.jvm.JvmSynthetic
import kotlin.time.Duration
import love.forte.simbot.qguild.model.Member as QGSourceMember

/**
Expand Down Expand Up @@ -137,6 +140,31 @@ internal class QGMemberImpl(
}
}

override suspend fun mute(duration: Duration) {
MuteMemberApi.create(
guildId.literal,
user.id,
duration
).requestDataBy(bot.source)
}

override suspend fun mute(duration: Long, unit: TimeUnit) {
MuteMemberApi.create(
guildId.literal,
user.id,
duration,
unit
).requestDataBy(bot.source)
}

override suspend fun unmute() {
MuteMemberApi.createUnmute(
guildId.literal,
user.id,
).requestDataBy(bot.source)
}


override fun toString(): String {
return "QGMember(id=$id, name=$name, nick=$nick, guildId=$guildId)"
}
Expand Down

0 comments on commit 3f3d138

Please sign in to comment.