From dfa748b1e7def79c57fd04975c2aa6d1913ebb39 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Wed, 14 Sep 2022 23:32:32 +0600 Subject: [PATCH] start add panel plugin --- posts/panel/build.gradle | 22 ++++++++++++++++ .../src/commonMain/kotlin/PackageInfo.kt | 1 + .../commonMain/kotlin/PanelButtonSettings.kt | 9 +++++++ posts/panel/src/jvmMain/kotlin/Plugin.kt | 26 +++++++++++++++++++ posts/panel/src/main/AndroidManifest.xml | 1 + posts_registrar/src/jvmMain/kotlin/Plugin.kt | 5 ---- settings.gradle | 1 + 7 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 posts/panel/build.gradle create mode 100644 posts/panel/src/commonMain/kotlin/PackageInfo.kt create mode 100644 posts/panel/src/commonMain/kotlin/PanelButtonSettings.kt create mode 100644 posts/panel/src/jvmMain/kotlin/Plugin.kt create mode 100644 posts/panel/src/main/AndroidManifest.xml diff --git a/posts/panel/build.gradle b/posts/panel/build.gradle new file mode 100644 index 0000000..779ca41 --- /dev/null +++ b/posts/panel/build.gradle @@ -0,0 +1,22 @@ +plugins { + id "org.jetbrains.kotlin.multiplatform" + id "org.jetbrains.kotlin.plugin.serialization" + id "com.android.library" +} + +apply from: "$mppProjectWithSerializationPresetPath" + +kotlin { + sourceSets { + commonMain { + dependencies { + api project(":plaguposter.common") + api project(":plaguposter.posts") + } + } + jvmMain { + dependencies { + } + } + } +} diff --git a/posts/panel/src/commonMain/kotlin/PackageInfo.kt b/posts/panel/src/commonMain/kotlin/PackageInfo.kt new file mode 100644 index 0000000..00707d7 --- /dev/null +++ b/posts/panel/src/commonMain/kotlin/PackageInfo.kt @@ -0,0 +1 @@ +package dev.inmo.plaguposter.posts.panel diff --git a/posts/panel/src/commonMain/kotlin/PanelButtonSettings.kt b/posts/panel/src/commonMain/kotlin/PanelButtonSettings.kt new file mode 100644 index 0000000..38b24e5 --- /dev/null +++ b/posts/panel/src/commonMain/kotlin/PanelButtonSettings.kt @@ -0,0 +1,9 @@ +package dev.inmo.plaguposter.posts.panel + +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton +import kotlinx.serialization.Serializable + +@Serializable +data class PanelButtonSettings( + val button: InlineKeyboardButton +) diff --git a/posts/panel/src/jvmMain/kotlin/Plugin.kt b/posts/panel/src/jvmMain/kotlin/Plugin.kt new file mode 100644 index 0000000..c4f449e --- /dev/null +++ b/posts/panel/src/jvmMain/kotlin/Plugin.kt @@ -0,0 +1,26 @@ +package dev.inmo.plaguposter.posts.panel + +import dev.inmo.plagubot.Plugin +import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext +import dev.inmo.tgbotapi.types.buttons.InlineKeyboardButtons.InlineKeyboardButton +import kotlinx.serialization.Serializable +import kotlinx.serialization.json.* +import org.jetbrains.exposed.sql.Database +import org.koin.core.Koin +import org.koin.core.module.Module + +object Plugin : Plugin { + @Serializable + internal data class Config ( + val text: String = "You have registered new post with %s posts", + val buttonsPrefix: String = ". Here the buttons available for management of post:", + val preset: List>? = null + ) + override fun Module.setupDI(database: Database, params: JsonObject) { + single { } + } + + override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) { + TODO("Not yet implemented") + } +} diff --git a/posts/panel/src/main/AndroidManifest.xml b/posts/panel/src/main/AndroidManifest.xml new file mode 100644 index 0000000..92f27c6 --- /dev/null +++ b/posts/panel/src/main/AndroidManifest.xml @@ -0,0 +1 @@ + diff --git a/posts_registrar/src/jvmMain/kotlin/Plugin.kt b/posts_registrar/src/jvmMain/kotlin/Plugin.kt index 65eecd3..fd950b8 100644 --- a/posts_registrar/src/jvmMain/kotlin/Plugin.kt +++ b/posts_registrar/src/jvmMain/kotlin/Plugin.kt @@ -103,11 +103,6 @@ object Plugin : Plugin { NewPost( state.messages ) - ).firstOrNull() ?.let { - send(state.context, "Ok, you have registered ${it.content.size} messages as new post") - } ?: send( - state.context, - "Sorry, for some reason I was unable to register your post" ) null } diff --git a/settings.gradle b/settings.gradle index b7a91b9..4cfbdc9 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,6 +3,7 @@ rootProject.name = 'plaguposter' String[] includes = [ ":common", ":posts", + ":posts:panel", ":posts_registrar", ":ratings", ":ratings:source",