Long polling

Long polling is a technology of getting updates for cases you do not have some dedicated server or you have no opportunity to receive updates via webhooks. More about this you can read in wiki.

Long polling in this library

There are a lot of ways to include work with long polling:

longPolling

longPolling is a simple way to start getting updates and work with bot:

val bot = telegramBot(token)
bot.longPolling(
  textMessages().subscribe(scope) { // here "scope" is a CoroutineScope
    println(it) // will be printed each update from chats with messages
  }
)

startGettingOfUpdatesByLongPolling

The main aim of startGettingOfUpdatesByLongPolling extension was to provide more simple way to get updates in automatic mode:

val bot = telegramBot(token)
bot.startGettingOfUpdatesByLongPolling(
  {
    println(it) // will be printed each update from chats with messages
  }
)

The other way is to use the most basic startGettingOfUpdatesByLongPolling extension:

val bot = telegramBot(token)
bot.startGettingOfUpdatesByLongPolling {
  println(it) // will be printed each update
}

See also


Revision #12
Created 13 August 2020 05:48:33 by InsanusMokrassar
Updated 22 May 2022 16:38:33 by InsanusMokrassar