Skip to content

Commit

Permalink
Expand star imports
Browse files Browse the repository at this point in the history
  • Loading branch information
alllex committed Jan 2, 2024
1 parent b0b86f3 commit 2e45808
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 12 deletions.
8 changes: 7 additions & 1 deletion buildSrc/src/main/kotlin/GenerateTelegramBotApiTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import org.gradle.api.DefaultTask
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.*
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.PathSensitive
import org.gradle.api.tasks.PathSensitivity
import org.gradle.api.tasks.TaskAction

@CacheableTask
abstract class GenerateTelegramBotApiTask : DefaultTask() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
package me.alllex.tbot.apigen

import me.alllex.parsus.parser.*
import me.alllex.parsus.parser.Grammar
import me.alllex.parsus.parser.ParseException
import me.alllex.parsus.parser.getOrElse
import me.alllex.parsus.parser.map
import me.alllex.parsus.parser.or
import me.alllex.parsus.parser.parser
import me.alllex.parsus.parser.repeatOneOrMore
import me.alllex.parsus.token.regexToken
import org.jsoup.Jsoup
import org.jsoup.nodes.Element
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/me/alllex/tbot/apigen/util.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.alllex.tbot.apigen

import java.util.*
import java.util.Locale


/**
Expand Down
21 changes: 15 additions & 6 deletions src/main/kotlin/me/alllex/tbot/api/client/TelegramBotApiClient.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package me.alllex.tbot.api.client

import io.ktor.client.*
import io.ktor.client.engine.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.http.*
import io.ktor.serialization.kotlinx.json.*
import io.ktor.client.HttpClient
import io.ktor.client.HttpClientConfig
import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.HttpClientEngineConfig
import io.ktor.client.engine.HttpClientEngineFactory
import io.ktor.client.plugins.contentnegotiation.ContentNegotiation
import io.ktor.http.DEFAULT_PORT
import io.ktor.http.URLProtocol
import io.ktor.serialization.kotlinx.json.json
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonNamingStrategy
Expand All @@ -22,7 +26,12 @@ class TelegramBotApiClient private constructor(
private val onResponse: (TelegramBotApiClient.(requestMethod: String, requestBody: Any?, responseBody: TelegramResponse<*>) -> Unit)? = null,
) {

internal inline fun <T> executeRequest(requestMethod: String, requestBody: Any?, request: () -> TelegramResponse<T>): TelegramResponse<T> {
internal inline fun <T> executeRequest(
requestMethod: String,
requestBody: Any?,
request: () -> TelegramResponse<T>
): TelegramResponse<T> {

onRequest?.invoke(this, requestMethod, requestBody)
val responseBody = request()
onResponse?.invoke(this, requestMethod, requestBody, responseBody)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
package me.alllex.tbot.api.client

import kotlinx.coroutines.*
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.cancelAndJoin
import kotlinx.coroutines.channels.BufferOverflow
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.takeWhile
import kotlinx.coroutines.isActive
import kotlinx.coroutines.job
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import me.alllex.tbot.api.model.Update
import me.alllex.tbot.api.model.asSeconds
import me.alllex.tbot.api.model.tryGetUpdates
Expand All @@ -13,6 +24,7 @@ import org.slf4j.LoggerFactory
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicLong
import kotlin.coroutines.CoroutineContext
import kotlin.coroutines.cancellation.CancellationException
import kotlin.coroutines.coroutineContext
import kotlin.time.Duration
import kotlin.time.Duration.Companion.milliseconds
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
package me.alllex.tbot.api.client

import me.alllex.tbot.api.model.*
import me.alllex.tbot.api.model.CallbackQuery
import me.alllex.tbot.api.model.CallbackQueryUpdate
import me.alllex.tbot.api.model.ChannelPostUpdate
import me.alllex.tbot.api.model.ChatJoinRequest
import me.alllex.tbot.api.model.ChatJoinRequestUpdate
import me.alllex.tbot.api.model.ChatMemberUpdate
import me.alllex.tbot.api.model.ChatMemberUpdated
import me.alllex.tbot.api.model.ChosenInlineResult
import me.alllex.tbot.api.model.ChosenInlineResultUpdate
import me.alllex.tbot.api.model.EditedChannelPostUpdate
import me.alllex.tbot.api.model.EditedMessageUpdate
import me.alllex.tbot.api.model.InlineQuery
import me.alllex.tbot.api.model.InlineQueryUpdate
import me.alllex.tbot.api.model.Message
import me.alllex.tbot.api.model.MessageUpdate
import me.alllex.tbot.api.model.MyChatMemberUpdate
import me.alllex.tbot.api.model.Poll
import me.alllex.tbot.api.model.PollAnswer
import me.alllex.tbot.api.model.PollAnswerUpdate
import me.alllex.tbot.api.model.PollUpdate
import me.alllex.tbot.api.model.PreCheckoutQuery
import me.alllex.tbot.api.model.PreCheckoutQueryUpdate
import me.alllex.tbot.api.model.ShippingQuery
import me.alllex.tbot.api.model.ShippingQueryUpdate
import me.alllex.tbot.api.model.Update


interface TelegramBotUpdateListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package me.alllex.tbot.api.client

import kotlinx.serialization.Serializable
import me.alllex.tbot.api.model.ResponseParameters
import kotlin.jvm.Throws

@Serializable
data class TelegramResponse<out T>(
Expand Down

0 comments on commit 2e45808

Please sign in to comment.