https://github.com/InsanusMokrassar/ktgbotapi

Type-safe library for work with Telegram Bot API

https://github.com/InsanusMokrassar/ktgbotapi

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (5.4%) to scientific vocabulary

Keywords

dev-inmo-tgbotapi hacktoberfest kotlin kotlin-js kotlin-jvm kotlin-library kotlin-multiplatform ktgbotapi telegram telegram-bot-api telegram-bots-api telegrambotapi tgbotapi

Keywords from Contributors

documents zsh-plugin communication reinforcement-learning stats
Last synced: 5 months ago · JSON representation

Repository

Type-safe library for work with Telegram Bot API

Basic Info
Statistics
  • Stars: 409
  • Watchers: 3
  • Forks: 33
  • Open Issues: 17
  • Releases: 204
Topics
dev-inmo-tgbotapi hacktoberfest kotlin kotlin-js kotlin-jvm kotlin-library kotlin-multiplatform ktgbotapi telegram telegram-bot-api telegram-bots-api telegrambotapi tgbotapi
Created about 7 years ago · Last pushed 6 months ago
Metadata Files
Readme Changelog Contributing Funding License

README.md

TelegramBotAPI Maven Central Version Supported version

| Docs | KDocs Mini tutorial | |:----------------------:|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:| | Useful repos | Create bot Examples | | Misc | Awesome Kotlin Badge Small survey | | Platforms | JVM Js | | Experimental Platforms | Linux x64 MinGW x64 |

Hello! This is a set of libraries for working with Telegram Bot API.

Examples

There are several things you need to do to launch examples below:

  • Add mavenCentral() to your project repositories
  • Add dependency implementation "dev.inmo:tgbotapi:$tgbotapi_version"
    • Replace tgbotapi_version with exact version (see last one in the table above) or put variable with this name in project
    • Alternative variant for maven here

More including instructions available here. Other configuration examples:

Most common example

```kotlin suspend fun main() { val bot = telegramBot(TOKEN)

bot.buildBehaviourWithLongPolling { println(getMe())

onCommand("start") {
  reply(it, "Hi:)")
}

}.join() } ```

In this example you will see information about this bot at the moment of starting and answer with Hi:) every time it gets message /start

Handling only last messages

```kotlin suspend fun main() { val bot = telegramBot(TOKEN)

val flowsUpdatesFilter = FlowsUpdatesFilter() bot.buildBehaviour(flowUpdatesFilter = flowsUpdatesFilter) { println(getMe())

onCommand("start") {
  reply(it, "Hi:)")
}

retrieveAccumulatedUpdates(this).join()

} } ```

The main difference with the previous example is that bot will get only last updates (accumulated before bot launch and maybe some updates it got after launch)

Build a little bit more complex behaviour

```kotlin suspend fun main() { val bot = telegramBot(TOKEN)

bot.buildBehaviourWithLongPolling { println(getMe())

val nameReplyMarkup = ReplyKeyboardMarkup(
  matrix {
    row {
      +SimpleKeyboardButton("nope")
    }
  }
)
onCommand("start") {
  val photo = waitPhoto(
    SendTextMessage(it.chat.id, "Send me your photo please")
  ).first()

  val name = waitText(
    SendTextMessage(
      it.chat.id,
      "Send me your name or choose \"nope\"",
      replyMarkup = nameReplyMarkup
    )
  ).first().text.takeIf { it != "nope" }

  sendPhoto(
    it.chat,
    photo.mediaCollection,
    entities = buildEntities {
      if (name != null) regular(name) // may be collapsed up to name ?.let(::regular)
    }
  )
}

}.join() } ```

More examples

You may find examples in this project. Besides, you are always welcome in our docs and chat.

Bot API Server Notice

Under the hood, default bots realizations will try to use links (PathedFile#filePath) as files each time you are trying to download file from telegram in any way - via saving to file, use stream or download as byte array. To let bot correctly download files from bot api server, you must:

  • Run bot api server locally to proxy requests for files to the server where bot api server has been hosted
    • In case of local bot api server (shared one host machine) you must ensure that access to bot api server has been granted for your bot. For example, aiogram/telegram-bot-api image use 101 UID/GID in linux for user and group as owners. So, your bot must run under user included in 101 group (like systemd-journal) or be 101 UID user (like systemd-resolve)
  • OR Use some reverse proxy (like nginx). It will allow you to broadcast your bots files without linux rights problems
    • Set TelegramAPIUrlsKeeper#fileLinkUrlMapper to map urls to let bot execute requests to your nginx proxy

Owner

  • Login: InsanusMokrassar
  • Kind: user

Kotlin Developer

GitHub Events

Total
  • Create event: 91
  • Issues event: 15
  • Release event: 24
  • Watch event: 43
  • Delete event: 47
  • Issue comment event: 27
  • Push event: 312
  • Pull request review event: 17
  • Pull request review comment event: 24
  • Pull request event: 155
  • Fork event: 6
Last Year
  • Create event: 91
  • Issues event: 15
  • Release event: 24
  • Watch event: 43
  • Delete event: 47
  • Issue comment event: 27
  • Push event: 312
  • Pull request review event: 17
  • Pull request review comment event: 24
  • Pull request event: 155
  • Fork event: 6

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 2,854
  • Total Committers: 19
  • Avg Commits per committer: 150.211
  • Development Distribution Score (DDS): 0.034
Past Year
  • Commits: 331
  • Committers: 8
  • Avg Commits per committer: 41.375
  • Development Distribution Score (DDS): 0.124
Top Committers
Name Email Commits
InsanusMokrassar o****5@g****m 2,756
bpavuk b****y@g****m 29
madhead s****u@g****m 11
renovate[bot] 2****] 9
vasya t****a@l****u 9
d1snin me@d****v 8
Gabryel Monteiro g****m@g****m 5
Kirill Romanov d****1@g****m 5
McModder me@m****w 4
Renovate Bot b****t@r****m 4
slesh s****3@g****m 4
Alex x****a@r****u 2
SuLG-k n****v@g****m 2
Alex b****k@e****g 1
Mefilt m****t@g****m 1
Michael Rittmeister dr@s****i 1
Pavel Klimatov m****z@y****u 1
Sergey Tolmachev t****u@g****m 1
lbia l****o@o****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 23
  • Total pull requests: 372
  • Average time to close issues: 6 months
  • Average time to close pull requests: 19 days
  • Total issue authors: 11
  • Total pull request authors: 12
  • Average comments per issue: 1.04
  • Average comments per pull request: 0.09
  • Merged pull requests: 139
  • Bot issues: 2
  • Bot pull requests: 207
Past Year
  • Issues: 8
  • Pull requests: 172
  • Average time to close issues: 3 days
  • Average time to close pull requests: 12 days
  • Issue authors: 6
  • Pull request authors: 7
  • Average comments per issue: 1.13
  • Average comments per pull request: 0.13
  • Merged pull requests: 62
  • Bot issues: 0
  • Bot pull requests: 95
Top Authors
Issue Authors
  • InsanusMokrassar (9)
  • bpavuk (3)
  • BlackBaroness (2)
  • renovate[bot] (2)
  • ath31st (1)
  • Slenkis (1)
  • centralhardware (1)
  • Towich (1)
  • sjmf (1)
  • youchenga (1)
  • Nik-mmzd (1)
Pull Request Authors
  • renovate[bot] (207)
  • InsanusMokrassar (132)
  • bpavuk (15)
  • centralhardware (3)
  • d1snin (2)
  • DRSchlaubi (2)
  • byteduck-exploit (2)
  • Nik-mmzd (2)
  • SuLG-ik (2)
  • mefilt (2)
  • BlackBaroness (2)
  • klimatov (1)
Top Labels
Issue Labels
api (2) core (2) utils (1) Hacktoberfest (1) enhancement (1) code (1) testing (1)
Pull Request Labels
markdown (121) versions (116) code (105) gradle (29)

Packages

  • Total packages: 2
  • Total downloads: unknown
  • Total dependent packages: 0
    (may contain duplicates)
  • Total dependent repositories: 0
    (may contain duplicates)
  • Total versions: 226
proxy.golang.org: github.com/insanusmokrassar/ktgbotapi
  • Versions: 113
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.1%
Average: 6.3%
Dependent repos count: 6.5%
Last synced: 6 months ago
proxy.golang.org: github.com/InsanusMokrassar/ktgbotapi
  • Versions: 113
  • Dependent Packages: 0
  • Dependent Repositories: 0
Rankings
Dependent packages count: 6.1%
Average: 6.3%
Dependent repos count: 6.5%
Last synced: 6 months ago

Dependencies

.github/workflows/greetings.yml actions
  • actions/first-interaction v1 composite
.github/workflows/kdocs.yml actions
  • actions/checkout v2 composite
  • actions/setup-java v1 composite
  • peaceiris/actions-gh-pages v3 composite
.github/workflows/label.yml actions
  • actions/labeler v2 composite
.github/workflows/packages_publishing.yml actions
  • actions/checkout v2 composite
  • actions/setup-java v1 composite
build.gradle maven
docs/build.gradle maven
tgbotapi/build.gradle maven
tgbotapi.api/build.gradle maven
tgbotapi.behaviour_builder/build.gradle maven
tgbotapi.behaviour_builder.fsm/build.gradle maven
tgbotapi.core/build.gradle maven
tgbotapi.ksp/build.gradle maven
tgbotapi.utils/build.gradle maven
tgbotapi.webapps/build.gradle maven