first try

This commit is contained in:
InsanusMokrassar 2021-02-22 21:01:08 +06:00
parent 141cdc2625
commit d1c96ee2b9
7 changed files with 75 additions and 16 deletions

View File

@ -7,7 +7,8 @@ import dev.inmo.tgbotapi.bot.TelegramBot
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
import dev.inmo.tgbotapi.libraries.cache.admins.micro_utils.DefaultAdminsCacheAPIRepo
import dev.inmo.tgbotapi.libraries.cache.admins.micro_utils.DynamicAdminsCacheSettingsAPI
import dev.inmo.tgbotapi.types.toChatId
import dev.inmo.tgbotapi.types.*
import dev.inmo.tgbotapi.types.ChatMember.abstracts.AdministratorChatMember
import kotlinx.coroutines.CoroutineScope
import kotlinx.serialization.cbor.Cbor
import kotlinx.serialization.decodeFromByteArray
@ -20,14 +21,16 @@ private val serializationFormat = Cbor
fun AdminsCacheAPI(
bot: TelegramBot,
database: Database,
scope: CoroutineScope,
repo: dev.inmo.tgbotapi.libraries.cache.admins.DefaultAdminsCacheAPIRepo = DefaultAdminsCacheAPIRepo(
scope: CoroutineScope
) : AdminsCacheAPI = DefaultAdminsCacheAPI(
bot,
DefaultAdminsCacheAPIRepo(
ExposedOneToManyKeyValueRepo(
database,
{ long("chatId") },
{ blob("member") },
"AdminsTable"
).withMapper(
).withMapper<ChatId, AdministratorChatMember, Identifier, ExposedBlob>(
keyFromToTo = { chatId },
valueFromToTo = { ExposedBlob(serializationFormat.encodeToByteArray(this)) },
keyToToFrom = { toChatId() },
@ -38,19 +41,21 @@ fun AdminsCacheAPI(
{ long("chatId") },
{ long("datetime") },
"AdminsUpdatesTimesTable"
).withMapper(
).withMapper<ChatId, Long, Identifier, Long>(
keyFromToTo = { chatId },
keyToToFrom = { toChatId() }
valueFromToTo = { this },
keyToToFrom = { toChatId() },
valueToToFrom = { this }
),
scope
),
settingsAPI: AdminsCacheSettingsAPI = DynamicAdminsCacheSettingsAPI(
DynamicAdminsCacheSettingsAPI(
ExposedKeyValueRepo(
database,
{ long("chatId") },
{ blob("settings") },
"DynamicAdminsCacheSettingsAPI"
).withMapper(
).withMapper<ChatId, AdminsCacheSettings, Identifier, ExposedBlob>(
keyFromToTo = { chatId },
valueFromToTo = { ExposedBlob(serializationFormat.encodeToByteArray(this)) },
keyToToFrom = { toChatId() },
@ -58,10 +63,6 @@ fun AdminsCacheAPI(
),
scope
)
) : AdminsCacheAPI = DefaultAdminsCacheAPI(
bot,
repo,
settingsAPI
)
fun BehaviourContext.AdminsCacheAPI(database: Database) = AdminsCacheAPI(this, database, this)

View File

@ -19,6 +19,6 @@ allprojects {
defaultAndroidSettingsPresetPath = "${rootProject.projectDir.absolutePath}/defaultAndroidSettings.gradle"
// publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
publishGradlePath = "${rootProject.projectDir.absolutePath}/publish.gradle"
}
}

View File

@ -1,7 +1,7 @@
project.version = "$version"
project.group = "$group"
// apply from: "$publishGradlePath"
apply from: "$publishGradlePath"
kotlin {
android {

View File

@ -1,7 +1,7 @@
project.version = "$version"
project.group = "$group"
// apply from: "$publishGradlePath"
apply from: "$publishGradlePath"
kotlin {
jvm {

View File

@ -1,7 +1,7 @@
project.version = "$version"
project.group = "$group"
// apply from: "$publishGradlePath"
apply from: "$publishGradlePath"
kotlin {
jvm {

57
publish.gradle Normal file
View File

@ -0,0 +1,57 @@
apply plugin: 'maven-publish'
apply plugin: 'signing'
task javadocsJar(type: Jar) {
classifier = 'javadoc'
}
publishing {
publications.all {
artifact javadocsJar
pom {
description = "${project.name}"
name = "${project.name}"
url = "https://github.com/InsanusMokrassar/TelegramBotApiLibraries"
scm {
developerConnection = "scm:git:[fetch=]https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git[push=]https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git"
url = "https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git"
}
developers {
developer {
id = "InsanusMokrassar"
name = "Ovsiannikov Aleksei"
email = "ovsyannikov.alexey95@gmail.com"
}
}
licenses {
license {
name = "MIT License"
url = "https://opensource.org/licenses/MIT"
}
}
}
repositories {
maven {
name = "sonatype"
url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = project.hasProperty('SONATYPE_USER') ? project.property('SONATYPE_USER') : System.getenv('SONATYPE_USER')
password = project.hasProperty('SONATYPE_PASSWORD') ? project.property('SONATYPE_PASSWORD') : System.getenv('SONATYPE_PASSWORD')
}
}
}
}
}
signing {
useGpgCmd()
sign publishing.publications
}

1
publish_config.kpsb Normal file
View File

@ -0,0 +1 @@
{"licenses":[{"id":"MIT","title":"MIT License","url":"https://opensource.org/licenses/MIT"}],"mavenConfig":{"name":"${project.name}","description":"${project.name}","url":"https://github.com/InsanusMokrassar/TelegramBotApiLibraries","vcsUrl":"https://github.com/InsanusMokrassar/TelegramBotApiLibraries.git","includeGpgSigning":true,"publishToMavenCentral":true,"developers":[{"id":"InsanusMokrassar","name":"Ovsiannikov Aleksei","eMail":"ovsyannikov.alexey95@gmail.com"}]}}