generated from project-mirai/mirai-console-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add commands cooldown - add random reply delay - add an option for disabling At message - simplify time format Signed-off-by: Samarium <[email protected]> Co-authored-by: Samarium <[email protected]>
- Loading branch information
1 parent
61586ea
commit 04c996d
Showing
10 changed files
with
121 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
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
11 changes: 11 additions & 0 deletions
11
src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/config/AdvancedConfig.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,11 @@ | ||
package io.github.samarium150.mirai.plugin.driftbottle.config | ||
|
||
import net.mamoe.mirai.console.data.AutoSavePluginConfig | ||
import net.mamoe.mirai.console.data.ValueDescription | ||
import net.mamoe.mirai.console.data.value | ||
|
||
object AdvancedConfig : AutoSavePluginConfig("Advanced") { | ||
|
||
@ValueDescription("At显示为纯文本") | ||
val disableDirectAt by value(false) | ||
} |
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
17 changes: 17 additions & 0 deletions
17
src/main/kotlin/io/github/samarium150/mirai/plugin/driftbottle/util/Throttle.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,17 @@ | ||
package io.github.samarium150.mirai.plugin.driftbottle.util | ||
|
||
import kotlinx.coroutines.sync.Mutex | ||
|
||
private val throttleMap = mutableMapOf<Long, Mutex>() | ||
|
||
private fun getLock(id: Long): Mutex { | ||
return throttleMap.getOrPut(id) { Mutex() } | ||
} | ||
|
||
fun lock(id: Long): Boolean { | ||
return getLock(id).tryLock() | ||
} | ||
|
||
fun unlock(id: Long) { | ||
throttleMap.remove(id)?.unlock() | ||
} |