
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
com.github.lamba92:kotlingram-core-metadata
Advanced tools
Telegram Bot APIs for Kotlin Multiplatform
Looking for a Kotlin first Telegram APIs? You are in the right place! This project offers Kotlin/Multiplatform APIs for Telegram bots based on Kotlinx.serialization and Ktor client and coroutines.
The APIs are generated by parsing the official Telegram documentation. For sure there are errors since no testing is in place, but message retrieval works!
For basic API usage you can use the client:
val client = TelegramBotApiClient("botToken")
val user: TelegramResponse<User> = client.getMe()
val user: TelegramResponse<List<Update>> = client.getUpdates()
For building a polling bot with you can use the builder:
fun main(): Unit = runBlocking {
buildPollingBot {
options {
botApiToken = System.getenv("DRAGALIA_BOT_TOKEN")
botUsername = "DragaliaBot"
}
handlers {
messages {
respondText(text = message.text, replyToMessageId = message.messageId)
}
inlineQueries {
respond(
listOf(
InlineQueryResultArticle(
id = "ciao mamma",
title = "Hello!",
inputMessageContent = InputTextMessageContent(
messageText = "ciao mamma guarda come mi diverto",
parseMode = "markdown"
),
type = "article"
)
)
)
}
}
}
}
The above are suspending calls!
To install add in your Gradle build:
repositories {
maven("https://dl.bintray.com/lamba92/com.github.lamba92")
}
// ...
dependenceis {
implementation("com.github.lamba92:kotlingram:{latest_version}")
}
For Kotlin/Multiplatform:
repositories {
maven("https://dl.bintray.com/lamba92/com.github.lamba92")
}
// ...
kotlin {
// ...
sourceSets {
commonMain {
dependencies {
implementation("com.github.lamba92:kotlingram-core:{latest_version}")
implementation("com.github.lamba92:kotlingram-bot-builder:{latest_version}")
}
}
}
}
Add a Ktor Client engine for your platform of choice in your Gradle build.
Versions used:
Platforms available are:
jvm
: JVM target 1.8js
: NodeJS with old compilation backendmingwx64
, macosx64
and linuxx64
platform are have some building issues I will work on later.
Unfortunately I had troubles publishing on Maven Central. I will look on the issue soon. The packages are published on GitHub Package Registry as well here but a login is required with a GitHub personal access token (PAT).
The implementation of each call is fairly simple, and it is possible to extend missing (or maybe wrongly generated) calls using extension functions:
@Serializable
data class GetUpdatesRequest(
val offset: Int? = null,
val limit: Int? = null,
val timeout: Int? = null,
@SerialName("allowed_updates") val allowedUpdates: List<String> = emptyList()
)
suspend fun TelegramBotApiClient.getUpdates(
requestBody: GetUpdatesRequest
): TelegramResponse<List<Update>> =
httpClient.post<TelegramResponse<List<Update>>> {
url {
protocol = apiProtocol
host = apiHost
port = apiPort
path("bot$apiToken", "getUpdates")
}
header(HttpHeaders.ContentType, ContentType.Application.Json)
body = requestBody
}
suspend fun TelegramBotApiClient.getUpdates(
offset: Int? = null,
limit: Int? = null,
timeout: Int? = null,
allowedUpdates: List<String> = emptyList(),
): TelegramResponse<List<Update>> =
getUpdates(
GetUpdatesRequest(
offset,
limit,
timeout,
allowedUpdates
)
)
If you find any issue please report them in the issue section!
FAQs
Unknown package
We found that com.github.lamba92:kotlingram-core-metadata demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.