mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2026-05-01 06:12:26 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 279f728348 | |||
| a509e3a15a |
37
CHANGELOG.md
37
CHANGELOG.md
@@ -1,41 +1,6 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
## 11.1.0
|
## 10.7.1
|
||||||
|
|
||||||
* `Bot`:
|
|
||||||
* Add opportunity to setup proxy
|
|
||||||
|
|
||||||
## 11.0.0
|
|
||||||
|
|
||||||
* `Versions`:
|
|
||||||
* `kotlin`: `2.3.10`
|
|
||||||
* `serialization`: `1.10.0`
|
|
||||||
* `microutils`: `0.29.1`
|
|
||||||
* `tgbotapi`: `32.0.0`
|
|
||||||
* `exposed`: `1.1.1`
|
|
||||||
* `sqlite`: `3.51.2.0`
|
|
||||||
|
|
||||||
## 10.10.0
|
|
||||||
|
|
||||||
* `Versions`:
|
|
||||||
* `kotlin`: `2.2.21`
|
|
||||||
* `microutils`: `0.26.8`
|
|
||||||
* `tgbotapi`: `30.0.2`
|
|
||||||
|
|
||||||
## 10.9.0
|
|
||||||
|
|
||||||
* `Versions`:
|
|
||||||
* `kotlin`: `2.2.20`
|
|
||||||
* `microutils`: `0.26.6`
|
|
||||||
* `tgbotapi`: `30.0.0`
|
|
||||||
* `koin`: `4.1.1`
|
|
||||||
|
|
||||||
## 10.8.0
|
|
||||||
|
|
||||||
* `Versions`:
|
|
||||||
* `kotlin`: `2.2.10`
|
|
||||||
* `microutils`: `0.26.3`
|
|
||||||
* `tgbotapi`: `28.0.1`
|
|
||||||
|
|
||||||
## 10.7.0
|
## 10.7.0
|
||||||
|
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ dependencies {
|
|||||||
api libs.microutils.koin
|
api libs.microutils.koin
|
||||||
api libs.microutils.startup.launcher
|
api libs.microutils.startup.launcher
|
||||||
|
|
||||||
api libs.ktor.engine.okhttp
|
|
||||||
|
|
||||||
api libs.sqlite
|
api libs.sqlite
|
||||||
|
|
||||||
testImplementation libs.kt.test.junit
|
testImplementation libs.kt.test.junit
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package dev.inmo.plagubot
|
|||||||
import dev.inmo.kslog.common.*
|
import dev.inmo.kslog.common.*
|
||||||
import dev.inmo.micro_utils.common.Warning
|
import dev.inmo.micro_utils.common.Warning
|
||||||
import dev.inmo.micro_utils.coroutines.runCatchingLogging
|
import dev.inmo.micro_utils.coroutines.runCatchingLogging
|
||||||
|
import dev.inmo.micro_utils.coroutines.runCatchingSafely
|
||||||
import dev.inmo.micro_utils.fsm.common.State
|
import dev.inmo.micro_utils.fsm.common.State
|
||||||
import dev.inmo.micro_utils.fsm.common.StatesManager
|
import dev.inmo.micro_utils.fsm.common.StatesManager
|
||||||
import dev.inmo.micro_utils.fsm.common.managers.*
|
import dev.inmo.micro_utils.fsm.common.managers.*
|
||||||
@@ -15,10 +16,6 @@ import dev.inmo.tgbotapi.bot.ktor.telegramBot
|
|||||||
import dev.inmo.tgbotapi.extensions.api.webhook.deleteWebhook
|
import dev.inmo.tgbotapi.extensions.api.webhook.deleteWebhook
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.*
|
||||||
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
import dev.inmo.tgbotapi.extensions.utils.updates.retrieving.startGettingOfUpdatesByLongPolling
|
||||||
import io.ktor.client.HttpClient
|
|
||||||
import io.ktor.client.engine.HttpClientEngine
|
|
||||||
import io.ktor.client.engine.HttpClientEngineFactory
|
|
||||||
import io.ktor.client.engine.okhttp.OkHttp
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.json.*
|
import kotlinx.serialization.json.*
|
||||||
@@ -61,19 +58,6 @@ object PlaguBot : Plugin {
|
|||||||
* @param params Raw JSON params of the bot part of the configuration
|
* @param params Raw JSON params of the bot part of the configuration
|
||||||
*/
|
*/
|
||||||
override fun KtorRequestsExecutorBuilder.setupBotClient(scope: Scope, params: JsonObject) {
|
override fun KtorRequestsExecutorBuilder.setupBotClient(scope: Scope, params: JsonObject) {
|
||||||
val config = scope.get<Config>()
|
|
||||||
if (config.proxy != null) {
|
|
||||||
val initialClient = config.proxy.createDefaultClient()
|
|
||||||
val clientFromHttpClientEngine = scope.getOrNull<HttpClientEngine>() ?.let {
|
|
||||||
HttpClient(it)
|
|
||||||
}
|
|
||||||
val clientFromKoin = clientFromHttpClientEngine ?: (scope.getOrNull<HttpClientEngineFactory<*>>() ?: OkHttp).let {
|
|
||||||
HttpClient(it)
|
|
||||||
}
|
|
||||||
this@setupBotClient.client = initialClient.config {
|
|
||||||
install(clientFromKoin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
scope.plugins.filter { it !== this@PlaguBot }.forEach {
|
scope.plugins.filter { it !== this@PlaguBot }.forEach {
|
||||||
with(it) {
|
with(it) {
|
||||||
setupBotClient(scope, params)
|
setupBotClient(scope, params)
|
||||||
|
|||||||
@@ -14,6 +14,5 @@ data class Config(
|
|||||||
@SerialName("database")
|
@SerialName("database")
|
||||||
val databaseConfig: DatabaseConfig = DatabaseConfig(),
|
val databaseConfig: DatabaseConfig = DatabaseConfig(),
|
||||||
val botApiServer: String = telegramBotAPIDefaultUrl,
|
val botApiServer: String = telegramBotAPIDefaultUrl,
|
||||||
val testServer: Boolean = false,
|
val testServer: Boolean = false
|
||||||
val proxy: ProxyConfig? = null,
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import dev.inmo.kslog.common.logger
|
|||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
import org.jetbrains.exposed.v1.jdbc.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.jetbrains.exposed.v1.jdbc.transactions.transactionManager
|
import org.jetbrains.exposed.sql.transactions.transactionManager
|
||||||
import org.koin.core.scope.Scope
|
import org.koin.core.scope.Scope
|
||||||
import org.sqlite.JDBC
|
import org.sqlite.JDBC
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
package dev.inmo.plagubot.config
|
|
||||||
|
|
||||||
import io.ktor.client.*
|
|
||||||
import io.ktor.client.engine.okhttp.OkHttp
|
|
||||||
import io.ktor.client.plugins.*
|
|
||||||
import io.ktor.client.request.*
|
|
||||||
import io.ktor.http.*
|
|
||||||
import kotlinx.serialization.Serializable
|
|
||||||
import kotlinx.serialization.Transient
|
|
||||||
import java.net.Authenticator
|
|
||||||
import java.net.InetSocketAddress
|
|
||||||
import java.net.PasswordAuthentication
|
|
||||||
import java.net.Proxy
|
|
||||||
import kotlin.io.encoding.Base64
|
|
||||||
|
|
||||||
@Serializable
|
|
||||||
data class ProxyConfig(
|
|
||||||
val host: String,
|
|
||||||
val port: Int,
|
|
||||||
val username: String? = null,
|
|
||||||
val password: String? = null
|
|
||||||
) {
|
|
||||||
@Transient
|
|
||||||
private val proxy = Proxy(Proxy.Type.SOCKS, InetSocketAddress(host, port))
|
|
||||||
fun createDefaultClient() = HttpClient(OkHttp) {
|
|
||||||
engine {
|
|
||||||
config {
|
|
||||||
proxy(this@ProxyConfig.proxy)
|
|
||||||
if (username != null && password != null) {
|
|
||||||
val passwordAuthentication = PasswordAuthentication(
|
|
||||||
username,
|
|
||||||
password.toCharArray()
|
|
||||||
)
|
|
||||||
Authenticator.setDefault(object : Authenticator() {
|
|
||||||
override fun getPasswordAuthentication(): PasswordAuthentication? {
|
|
||||||
return if (requestingHost.lowercase() == host.lowercase()) {
|
|
||||||
passwordAuthentication
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -34,8 +34,8 @@ allprojects {
|
|||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
maven { url "https://nexus.inmo.dev/repository/maven-releases/" }
|
|
||||||
maven { url 'https://jitpack.io' }
|
maven { url 'https://jitpack.io' }
|
||||||
|
maven { url "https://nexus.inmo.dev/repository/maven-releases/" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
0
changelog_parser.sh
Executable file → Normal file
0
changelog_parser.sh
Executable file → Normal file
@@ -5,4 +5,4 @@ kotlin.js.generate.externals=true
|
|||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
|
|
||||||
group=dev.inmo
|
group=dev.inmo
|
||||||
version=11.1.0
|
version=10.7.1
|
||||||
|
|||||||
@@ -1,25 +1,24 @@
|
|||||||
[versions]
|
[versions]
|
||||||
|
|
||||||
kt = "2.3.10"
|
kt = "2.2.0"
|
||||||
kt-serialization = "1.10.0"
|
kt-serialization = "1.9.0"
|
||||||
kt-coroutines = "1.10.2"
|
kt-coroutines = "1.10.2"
|
||||||
|
|
||||||
microutils = "0.29.1"
|
microutils = "0.26.2"
|
||||||
tgbotapi = "32.0.0"
|
tgbotapi = "27.1.1"
|
||||||
ktor = "3.4.1"
|
|
||||||
|
|
||||||
ksp = "2.3.6"
|
ksp = "2.2.0-2.0.2"
|
||||||
|
|
||||||
jb-exposed = "1.1.1"
|
jb-exposed = "0.61.0"
|
||||||
jb-dokka = "2.1.0"
|
jb-dokka = "2.0.0"
|
||||||
|
|
||||||
sqlite = "3.51.2.0"
|
sqlite = "3.50.1.0"
|
||||||
|
|
||||||
gh-release = "2.5.2"
|
gh-release = "2.5.2"
|
||||||
|
|
||||||
koin = "4.1.1"
|
koin = "4.1.0"
|
||||||
|
|
||||||
nmcp = "1.4.4"
|
nmcp = "1.0.2"
|
||||||
|
|
||||||
[libraries]
|
[libraries]
|
||||||
|
|
||||||
@@ -36,8 +35,6 @@ microutils-koin-generator = { module = "dev.inmo:micro_utils.koin.generator", ve
|
|||||||
microutils-startup-launcher = { module = "dev.inmo:micro_utils.startup.launcher", version.ref = "microutils" }
|
microutils-startup-launcher = { module = "dev.inmo:micro_utils.startup.launcher", version.ref = "microutils" }
|
||||||
microutils-startup-plugin = { module = "dev.inmo:micro_utils.startup.plugin", version.ref = "microutils" }
|
microutils-startup-plugin = { module = "dev.inmo:micro_utils.startup.plugin", version.ref = "microutils" }
|
||||||
|
|
||||||
ktor-engine-okhttp = { module = "io.ktor:ktor-client-okhttp", version.ref = "ktor" }
|
|
||||||
|
|
||||||
koin = { module = "io.insert-koin:koin-core", version.ref = "koin" }
|
koin = { module = "io.insert-koin:koin-core", version.ref = "koin" }
|
||||||
|
|
||||||
jb-exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "jb-exposed" }
|
jb-exposed-jdbc = { module = "org.jetbrains.exposed:exposed-jdbc", version.ref = "jb-exposed" }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package dev.inmo.plagubot
|
package dev.inmo.plagubot
|
||||||
|
|
||||||
import org.jetbrains.exposed.v1.jdbc.Database
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.koin.core.Koin
|
import org.koin.core.Koin
|
||||||
import org.koin.core.scope.Scope
|
import org.koin.core.scope.Scope
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import kotlinx.serialization.KSerializer
|
|||||||
import kotlinx.serialization.json.Json
|
import kotlinx.serialization.json.Json
|
||||||
import kotlinx.serialization.json.JsonObject
|
import kotlinx.serialization.json.JsonObject
|
||||||
import kotlinx.serialization.serializer
|
import kotlinx.serialization.serializer
|
||||||
|
import org.jetbrains.exposed.sql.Database
|
||||||
import org.koin.core.Koin
|
import org.koin.core.Koin
|
||||||
import org.koin.core.module.Module
|
import org.koin.core.module.Module
|
||||||
import org.koin.core.scope.Scope
|
import org.koin.core.scope.Scope
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ interface Plugin : StartPlugin {
|
|||||||
* @param scope The scope of [org.koin.core.module.Module.single] of bot definition
|
* @param scope The scope of [org.koin.core.module.Module.single] of bot definition
|
||||||
* @param params Params (in fact, the whole bot config)
|
* @param params Params (in fact, the whole bot config)
|
||||||
*/
|
*/
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
fun KtorRequestsExecutorBuilder.setupBotClient(scope: Scope, params: JsonObject) = setupBotClient()
|
fun KtorRequestsExecutorBuilder.setupBotClient(scope: Scope, params: JsonObject) = setupBotClient()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import kotlinx.serialization.descriptors.SerialDescriptor
|
|||||||
import kotlinx.serialization.encoding.Decoder
|
import kotlinx.serialization.encoding.Decoder
|
||||||
import kotlinx.serialization.encoding.Encoder
|
import kotlinx.serialization.encoding.Encoder
|
||||||
|
|
||||||
|
@Serializer(Plugin::class)
|
||||||
class PluginSerializer : KSerializer<Plugin> {
|
class PluginSerializer : KSerializer<Plugin> {
|
||||||
override val descriptor: SerialDescriptor
|
override val descriptor: SerialDescriptor
|
||||||
get() = String.serializer().descriptor
|
get() = String.serializer().descriptor
|
||||||
|
|||||||
@@ -10,13 +10,6 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"botToken": "1234567890:ABCDEFGHIJKLMNOP_qrstuvwxyz12345678",
|
"botToken": "1234567890:ABCDEFGHIJKLMNOP_qrstuvwxyz12345678",
|
||||||
"proxy": {
|
|
||||||
"host": "127.0.0.1",
|
|
||||||
"port": 1080,
|
|
||||||
"username": "OPTIONAL username",
|
|
||||||
"password": "OPTIONAL password",
|
|
||||||
"_note": "THIS OBJECT IS OPTIONAL"
|
|
||||||
},
|
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"dev.inmo.plagubot.HelloPlugin"
|
"dev.inmo.plagubot.HelloPlugin"
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user