mirror of
https://github.com/InsanusMokrassar/PlaguPoster.git
synced 2024-11-25 08:58:45 +00:00
preview version of registrar
This commit is contained in:
parent
36bedff5f3
commit
941505df42
23
common/build.gradle
Normal file
23
common/build.gradle
Normal file
@ -0,0 +1,23 @@
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id "com.android.library"
|
||||
}
|
||||
|
||||
apply from: "$mppProjectWithSerializationPresetPath"
|
||||
|
||||
kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api libs.tgbotapi
|
||||
api libs.microutils.repos.common
|
||||
api libs.kslog
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
dependencies {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
14
common/src/commonMain/kotlin/CommonMessagesCommandsFilter.kt
Normal file
14
common/src/commonMain/kotlin/CommonMessagesCommandsFilter.kt
Normal file
@ -0,0 +1,14 @@
|
||||
package dev.inmo.plaguposter.common
|
||||
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.filters.CommonMessageFilterExcludeMediaGroups
|
||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.utils.SimpleFilter
|
||||
import dev.inmo.tgbotapi.extensions.utils.textContentOrNull
|
||||
import dev.inmo.tgbotapi.types.BotCommand
|
||||
import dev.inmo.tgbotapi.types.message.abstracts.*
|
||||
import dev.inmo.tgbotapi.types.message.textsources.BotCommandTextSource
|
||||
|
||||
val FirstSourceIsCommandsFilter = SimpleFilter<Message> {
|
||||
it is ContentMessage<*> && it.content.textContentOrNull() ?.textSources ?.firstOrNull {
|
||||
it is BotCommandTextSource
|
||||
} != null
|
||||
}
|
1
common/src/commonMain/kotlin/PackageInfo.kt
Normal file
1
common/src/commonMain/kotlin/PackageInfo.kt
Normal file
@ -0,0 +1 @@
|
||||
package dev.inmo.plaguposter.common
|
1
common/src/main/AndroidManifest.xml
Normal file
1
common/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1 @@
|
||||
<manifest package="dev.inmo.plaguposter.common"/>
|
@ -31,6 +31,7 @@ android-test-espresso-core = { module = "androidx.test.espresso:espresso-core",
|
||||
|
||||
tgbotapi = { module = "dev.inmo:tgbotapi", version.ref = "tgbotapi" }
|
||||
plagubot-plugin = { module = "dev.inmo:plagubot.plugin", version.ref = "plagubot" }
|
||||
plagubot-bot = { module = "dev.inmo:plagubot.bot", version.ref = "plagubot" }
|
||||
microutils-repos-common = { module = "dev.inmo:micro_utils.repos.common", version.ref = "microutils" }
|
||||
microutils-repos-exposed = { module = "dev.inmo:micro_utils.repos.exposed", version.ref = "microutils" }
|
||||
kslog = { module = "dev.inmo:kslog", version.ref = "kslog" }
|
||||
|
@ -10,9 +10,7 @@ kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api libs.tgbotapi
|
||||
api libs.microutils.repos.common
|
||||
api libs.kslog
|
||||
api project(":plaguposter.common")
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
|
@ -3,6 +3,7 @@ package dev.inmo.plaguposter.posts.exposed
|
||||
import com.benasher44.uuid.uuid4
|
||||
import dev.inmo.micro_utils.repos.KeyValuesRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.AbstractExposedCRUDRepo
|
||||
import dev.inmo.micro_utils.repos.exposed.initTable
|
||||
import dev.inmo.plaguposter.posts.models.*
|
||||
import dev.inmo.plaguposter.posts.repo.PostsRepo
|
||||
import kotlinx.serialization.json.Json
|
||||
@ -25,7 +26,7 @@ class ExposedPostsRepo(
|
||||
)
|
||||
}
|
||||
|
||||
override val primaryKey: PrimaryKey? = PrimaryKey(idColumn)
|
||||
override val primaryKey: PrimaryKey = PrimaryKey(idColumn)
|
||||
|
||||
override val selectById: SqlExpressionBuilder.(PostId) -> Op<Boolean> = { idColumn.eq(it.string) }
|
||||
override val selectByIds: SqlExpressionBuilder.(List<PostId>) -> Op<Boolean> = { idColumn.inList(it.map { it.string }) }
|
||||
@ -42,6 +43,10 @@ class ExposedPostsRepo(
|
||||
)
|
||||
}
|
||||
|
||||
init {
|
||||
initTable()
|
||||
}
|
||||
|
||||
override fun InsertStatement<Number>.asObject(value: NewPost): RegisteredPost {
|
||||
val id = PostId(get(idColumn))
|
||||
|
||||
|
@ -8,6 +8,7 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.fsm.common.State
|
||||
import dev.inmo.micro_utils.repos.create
|
||||
import dev.inmo.plagubot.Plugin
|
||||
import dev.inmo.plaguposter.common.FirstSourceIsCommandsFilter
|
||||
import dev.inmo.plaguposter.posts.models.NewPost
|
||||
import dev.inmo.plaguposter.posts.models.PostContentInfo
|
||||
import dev.inmo.plaguposter.posts.registrar.state.RegistrationState
|
||||
@ -142,7 +143,7 @@ object Plugin : Plugin {
|
||||
}
|
||||
|
||||
onContentMessage(
|
||||
initialFilter = { it.chat.id == config.sourceChatId && it.mediaGroupMessageOrNull() ?.mediaGroupId == null }
|
||||
initialFilter = { it.chat.id == config.sourceChatId && it.mediaGroupMessageOrNull() ?.mediaGroupId == null && !FirstSourceIsCommandsFilter(it) }
|
||||
) {
|
||||
startChain(RegistrationState.Finish(it.chat.id, listOf(PostContentInfo.fromMessage(it, 0))))
|
||||
}
|
||||
|
22
runner/build.gradle
Normal file
22
runner/build.gradle
Normal file
@ -0,0 +1,22 @@
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
id "org.jetbrains.kotlin.plugin.serialization"
|
||||
id 'application'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation libs.kotlin
|
||||
api libs.plagubot.bot
|
||||
|
||||
api project(":plaguposter.posts")
|
||||
api project(":plaguposter.posts_registrar")
|
||||
}
|
||||
|
||||
application {
|
||||
mainClassName = 'dev.inmo.plagubot.AppKt'
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
}
|
21
runner/config.json
Normal file
21
runner/config.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"database": {
|
||||
"url": "jdbc:sqlite:file:test?mode=memory&cache=shared IT IS JUST EXAMPLE",
|
||||
"driver": "org.sqlite.JDBC",
|
||||
"username": "OPTIONAL username",
|
||||
"password": "OPTIONAL password",
|
||||
"initAutomatically": false
|
||||
},
|
||||
"botToken": "1234567890:ABCDEFGHIJKLMNOP_qrstuvwxyz12345678",
|
||||
"plugins": [
|
||||
"dev.inmo.plaguposter.posts.Plugin",
|
||||
"dev.inmo.plaguposter.posts.registrar.Plugin"
|
||||
],
|
||||
"posts": {
|
||||
"targetChat": 12345678,
|
||||
"cacheChat": 12345678
|
||||
},
|
||||
"registrar": {
|
||||
"sourceChat": 12345678
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
rootProject.name = 'plaguposter'
|
||||
|
||||
String[] includes = [
|
||||
":common",
|
||||
":posts",
|
||||
":posts_registrar"
|
||||
":posts_registrar",
|
||||
":runner"
|
||||
]
|
||||
|
||||
|
||||
|
@ -10,9 +10,7 @@ kotlin {
|
||||
sourceSets {
|
||||
commonMain {
|
||||
dependencies {
|
||||
api libs.tgbotapi
|
||||
api libs.microutils.repos.common
|
||||
api libs.kslog
|
||||
api project(":plaguposter.common")
|
||||
}
|
||||
}
|
||||
jvmMain {
|
||||
|
Loading…
Reference in New Issue
Block a user