Skip to content

Commit

Permalink
build: 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Dec 20, 2022
1 parent 2a7037f commit b0d6c8a
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 18 deletions.
Binary file added .github/afdian.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Release](https://img.shields.io/github/v/release/cssxsh/mirai-administrator)](https://github.com/cssxsh/mirai-administrator/releases)
[![Downloads](https://img.shields.io/github/downloads/cssxsh/mirai-administrator/total)](https://repo1.maven.org/maven2/xyz/cssxsh/mirai/mirai-administrator/)
[![maven-central](https://img.shields.io/maven-central/v/xyz.cssxsh.mirai/mirai-administrator)](https://search.maven.org/artifact/xyz.cssxsh.mirai/mirai-administrator)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/8be173fe96c74059bfedd6268b8e6f0c)](https://www.codacy.com/gh/cssxsh/mirai-administrator/dashboard?utm_source=github.com&utm_medium=referral&utm_content=cssxsh/mirai-administrator&utm_campaign=Badge_Grade)

**使用前应该查阅的相关文档或项目**

Expand All @@ -19,7 +20,8 @@
* 群管理相关 群消息审核,自动宵禁,自动清理不发言,禁言自动退群

本插件提供[服务接口](#服务接口)以供其他插件拓展功能
例如使用 [Mirai Content Censor](https://github.com/gnuf0rce/mirai-content-censor) 依靠百度API审查群消息
例如使用 [Mirai Content Censor](https://github.com/gnuf0rce/mirai-content-censor) 依靠百度API审查群消息
例如使用 [Mirai Authenticator](https://github.com/cssxsh/mirai-authenticator) 验证加群请求

## MCL 指令安装

Expand Down Expand Up @@ -102,10 +104,12 @@
| `/<send> <friends> [bot]? [second]?` | 发送给所有好友 |
| `/<send> <to> [contact] [at]?` | 发送给指定联系人 |
| `/<send> <nudge> [user]` | 戳一戳指定联系人 |
| `/<send> <log> {addresses}` | 备份日志到邮箱 |

1. `bot` 参数在命令行模式下需要指定
2. `at` 参数为 `true`, `yes`, `enabled`, `on`, `1` 时表示 `true`, 将附加一个At
3. `second` 参数为 延迟的秒数 例如 `/send groups 123456 false 10`
4. `addresses` 参数为 邮箱地址

### AdminTimerCommand

Expand Down Expand Up @@ -161,9 +165,31 @@
2. `censor_types` 可选值 `IMAGE, FLASH, SERVICE, APP, AUDIO, FORWARD, VIP, MARKET, MUSIC, POKE`
3. 正则词库, 须手动添加,将会加载 censor 文件夹中的 txt 文件,每一行对应一个正则匹配,会监听文件改动,无需重启

### 邮件配置

1. `AdminMailConfig.yml` 配置一些默认的发送对象
2. `admin.mail.properties` 配置邮箱账号等

格式参考
```properties
mail.host=smtp.mail.qq.com
mail.auth=true
mail.user=xxx
mail.password=***
mail.from[email protected]
mail.store.protocol=smtp
mail.transport.protocol=smtp
# smtp
mail.smtp.starttls.enable=true
mail.smtp.auth=true
mail.smtp.timeout=15000
```

QQ邮箱帮助: https://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256

## [爱发电](https://afdian.net/@cssxsh)

![afdian](https://mirai.mamoe.net/assets/uploads/files/1670551864384-8ab9fe4e-37ff-440f-bd1e-c7bda4e1a85e-image.png)
![afdian](.github/afdian.jpg)

## 服务接口

Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
}

group = "xyz.cssxsh.mirai"
version = "1.3.0"
version = "1.3.1"

mavenCentralPublish {
useCentralS01()
Expand Down Expand Up @@ -43,7 +43,7 @@ dependencies {
implementation("io.ktor:ktor-client-okhttp")
implementation("io.ktor:ktor-client-encoding")
//
implementation(platform("org.slf4j:slf4j-parent:2.0.5"))
implementation(platform("org.slf4j:slf4j-parent:2.0.6"))
testImplementation("org.slf4j:slf4j-simple")
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/xyz/cssxsh/mirai/admin/MiraiAdminPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ internal object MiraiAdminPlugin : KotlinPlugin(
JvmPluginDescription(
id = "xyz.cssxsh.mirai.plugin.mirai-administrator",
name = "mirai-administrator",
version = "1.3.0",
version = "1.3.1",
) {
author("cssxsh")
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/kotlin/xyz/cssxsh/mirai/admin/MiraiAdministrator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ public object MiraiAdministrator : SimpleListenerHost() {
/**
* 启动一个群定时服务
*/
@PublishedApi
internal fun GroupTimerService<*>.start(target: Group, reset: Boolean = false) {
if (!reset && target.id in records) return
records.remove(target.id)?.cancel()
Expand Down Expand Up @@ -277,6 +278,7 @@ public object MiraiAdministrator : SimpleListenerHost() {
/**
* 启动一个定时消息服务
*/
@PublishedApi
internal fun BotTimingMessage.start(from: Bot, reset: Boolean = false) {
if (!reset && from.id in records) return
records.remove(from.id)?.cancel()
Expand Down Expand Up @@ -304,6 +306,7 @@ public object MiraiAdministrator : SimpleListenerHost() {
/**
* 启动一个初始化服务
*/
@PublishedApi
internal fun BotOnlineAction.start(from: Bot) {
launch(from.coroutineContext) {
run(bot = from)
Expand Down Expand Up @@ -396,9 +399,9 @@ public object MiraiAdministrator : SimpleListenerHost() {
when {
sender.id == AdminSetting.owner -> return
this is UserMessageEvent && AdminCommentConfig.user &&
message.findIsInstance<PlainText>()?.content?.getOrNull(0) != '/' -> {}
message.findIsInstance<QuoteReply>()?.source?.fromId == bot.id && AdminCommentConfig.quote -> {}
message.findIsInstance<At>()?.target == bot.id && AdminCommentConfig.at -> {}
message.findIsInstance<PlainText>()?.content?.getOrNull(0) != '/' -> Unit
message.findIsInstance<QuoteReply>()?.source?.fromId == bot.id && AdminCommentConfig.quote -> Unit
message.findIsInstance<At>()?.target == bot.id && AdminCommentConfig.at -> Unit
else -> return
}

Expand Down
4 changes: 1 addition & 3 deletions src/main/kotlin/xyz/cssxsh/mirai/admin/MiraiMessageTimer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ internal object MiraiMessageTimer : BotTimingMessage {
val uuid = "${group.id}/${cron.asString().toByteArray().toUHexString("")}.json"
val file = folder.resolve(uuid)
if (file.exists().not()) continue
val message = with(MessageChain) {
deserializeFromJsonString(file.readText())
}
val message = MessageChain.deserializeFromJsonString(file.readText())
mutex.withLock {
if (cache.add(uuid).not()) return@withLock
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ public object AdminSendCommand : CompositeCommand(
}

/**
* 发送消息给所有群
* @param bot 操作的机器人
* @param at 是否At全体
* @param second 发送的间隔
* 戳一戳指定用户
* @param user 要戳的用户
*/
@SubCommand
@Description("戳一戳指定联系人")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public object AdminTimerCommand : CompositeCommand(
/**
* 定时发送机器人状态到所有者
* @param cron 启用的时间点
* @param bot 目标机器人
* @param from 目标机器人
*/
@SubCommand
@Description("定时发送机器人状态")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import xyz.cssxsh.mirai.admin.*
@PublishedApi
internal object AdminCommentConfig : ReadOnlyPluginConfig("AdminCommentConfig") {

public var permission: Permission = Permission.getRootPermission()
var permission: Permission = Permission.getRootPermission()
private set

@OptIn(ConsoleExperimentalApi::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import xyz.cssxsh.mirai.admin.*
@PublishedApi
internal object AdminOnlineMessageConfig : ReadOnlyPluginConfig("AdminOnlineMessageConfig"), MiraiOnlineMessageConfig {

public override var permission: Permission = Permission.getRootPermission()
override var permission: Permission = Permission.getRootPermission()
private set

@OptIn(ConsoleExperimentalApi::class)
Expand Down

0 comments on commit b0d6c8a

Please sign in to comment.