From 6f498554b7147b4002955183f57fb5bf0bbe9bc1 Mon Sep 17 00:00:00 2001 From: Him188 <Him188@mamoe.net> Date: Sat, 2 Nov 2019 18:49:48 +0800 Subject: [PATCH] update README.md --- README.md | 20 ++++++++++++++++--- .../event/events/FriendEvents.kt | 8 +------- .../src/main/kotlin/demo/gentleman/Main.kt | 1 - 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index e0c3b3e49..831a4c00d 100644 --- a/README.md +++ b/README.md @@ -15,9 +15,22 @@ Mirai 在 JVM 平台采用插件模式运行,同时提供独立的跨平台核 现在您可以开始体验低付出高效率的 Mirai +```kotlin +val bot = Bot(qqId, password).apply{ login().requireSuccess() } // 创建一个机器人实例并登录 +bot.subscribeMessages { // 订阅消息事件 + "你好" reply "你好!" // 收到 "你好" 则回复 "你好!" + "profile" reply { sender.profile.await().toString() } // 收到 "profile" 则回复发送者的个人资料 + contains("图片"){ File(imagePath).send() } // 收到消息包含 "图片" 就回复一张本地的图片 +} +bot.subscribeAlways<MemberPermissionChangedEvent> { + if (it.kind == BECOME_OPERATOR) + it.group.sendMessage("${it.member.id} 成为了管理员") +} +``` + 1. Clone 2. Import as Gradle project -3. Run demo main [Demo 1 Main](mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt) +3. 运行 Demo 程序: [mirai-demo](#mirai-demo) 示例和演示程序 **转到[开发文档](#Development-Guide---Kotlin)** @@ -106,8 +119,9 @@ Mirai 的核心部分. - Jar 插件支持 #### mirai-demo -Samples and demos. -目前仅有 [SubscribeSamples](mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt) +Samples and demos. +监听事件示例 [SubscribeSamples](mirai-demos/mirai-demo-1/src/main/java/demo/subscribe/SubscribeSamples.kt) +随机图片发送 [Gentleman](mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt) #### mirai-debug 抓包工具和分析工具. 不会进行稳定性维护. diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/FriendEvents.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/FriendEvents.kt index e43f3ffa4..2e174783b 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/FriendEvents.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/events/FriendEvents.kt @@ -3,7 +3,6 @@ package net.mamoe.mirai.event.events import net.mamoe.mirai.Bot -import net.mamoe.mirai.contact.Profile import net.mamoe.mirai.contact.QQ import net.mamoe.mirai.message.Message import net.mamoe.mirai.message.MessageChain @@ -35,9 +34,4 @@ class FriendConversationInitializedEvent(bot: Bot, sender: QQ) : FriendEvent(bot /** * 好友在线状态改变事件 */ -class FriendOnlineStatusChangedEvent(bot: Bot, sender: QQ, val newStatus: OnlineStatus) : FriendEvent(bot, sender) - -/** - * 好友个人资料更新 - */ -class FriendProfileUpdatedEvent(bot: Bot, qq: QQ, val profile: Profile) : FriendEvent(bot, qq) \ No newline at end of file +class FriendOnlineStatusChangedEvent(bot: Bot, sender: QQ, val newStatus: OnlineStatus) : FriendEvent(bot, sender) \ No newline at end of file diff --git a/mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt b/mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt index 3a657dc5a..7d540bc60 100644 --- a/mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt +++ b/mirai-demos/mirai-demo-gentleman/src/main/kotlin/demo/gentleman/Main.kt @@ -44,7 +44,6 @@ suspend fun main() { subscribeAlways<Event> { //bot.logger.verbose("收到了一个事件: ${it::class.simpleName}") } - bot.subscribeMessages { "你好" reply "你好!" "profile" reply {