tgbotapi/TelegramBotAPI-extensions-u...
InsanusMokrassar 08d9d183f4 add filterCommandsWithArgs 2020-04-08 15:23:12 +06:00
..
src/commonMain/kotlin/com/github/insanusmokrassar/TelegramBotAPI/extensions/utils add filterCommandsWithArgs 2020-04-08 15:23:12 +06:00
README.md update readmes 2020-04-08 14:34:55 +06:00
build.gradle add TelegramBotAPI-extensions-utils 2020-04-08 11:05:48 +06:00
maven.publish.gradle add TelegramBotAPI-extensions-utils 2020-04-08 11:05:48 +06:00
mpp_publish_template.json add TelegramBotAPI-extensions-utils 2020-04-08 11:05:48 +06:00
publish.gradle add TelegramBotAPI-extensions-utils 2020-04-08 11:05:48 +06:00

README.md

TelegramBotAPI Util Extensions

Download Maven Central

What is it?

It is wrapper library for TelegramBotAPI. Currently, this library contains some usefull filters for commands, updates types and different others.

How to implement library?

Common ways to implement this library are presented here. In some cases it will require additional steps like inserting of additional libraries (like kotlin stdlib). In the examples will be used variable telegrambotapi-extensions-utils_version, which must be set up by developer. Available versions are presented on bintray, next version is last published:

Download

Maven

Dependency config presented here:

<dependency>
  <groupId>com.github.insanusmokrassar</groupId>
  <artifactId>TelegramBotAPI-extensions-utils</artifactId>
  <version>${telegrambotapi-extensions-utils_version}</version>
</dependency>

Gradle

To use last versions you will need to add one line in repositories block of your build.gradle:

jcenter() or mavenCentral()

And add next line to your dependencies block:

implementation "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$telegrambotapi-extensions-utils_version"

or for old gradle:

compile "com.github.insanusmokrassar:TelegramBotAPI-extensions-utils:$telegrambotapi-extensions-utils_version"

How to use?

Here will be presented several examples of usage. In all cases it is expected that you have created your bot and filter:

val bot: RequestsExecutor = KtorRequestsExecutor(
    TelegramAPIUrlsKeeper(BOT_TOKEN)
)
val filter = FlowsUpdatesFilter(64)

Alternative way to use the things below:

val filter = bot.startGettingUpdates(
    scope = CoroutineScope(Dispatchers.Default)
) {
    // place code from examples here with replacing of `filter` by `this`
}

Getting of only text incoming messages

filter.asContentMessagesFlow().onlyTextContentMessages().onEach {
    println(it.content)
    println(it.fullEntitiesList())
}.launchIn(
    CoroutineScope(Dispatchers.Default)
)

As a result, each received message which will be just text message will be printed out with full list of its internal entities