Skip to content

demidko/telegram-storage

Repository files navigation

Telegram Storage

This library is your Map<K, V> in the Telegram channel. To try it, your bot needs a channel (name or ID) with full admin rights.

Warnings

  • You can save only 20 entries per minute with a single token. If the limit is exceeded, waiting will occur.
  • Don't change the description—the bot stores the keystore file ID there
  • After the first setup, you can't change the dictionary's key/value types

Download

You need Gradle, Maven, or another build tool

Also, you need to add Kotlin serialization plugin, for example, in build.gradle.kts

plugins {
    kotlin("plugin.serialization") version "2.1.20-Beta2"
}

Usage example

import com.github.demidko.telegram.TelegramStorage.Constructors.TelegramStorage

@Serializable data class Person(val name: String, val address: String)

fun main() {
    val token = "Bot API token here"
    val channel = "Telegram channel name here" // or long id
    val storage = TelegramStorage<String, Person>(token, channel)

    // saved to Telegram channel
    storage["Special Government Employee"] = Person("Elon Musk", "Texas")

    // restored Person("Elon Musk", "Texas") from channel
    val p = storage["Special Government Employee"]!!
}

About

A free, 1M records NoSQL cloud database in your Telegram channel

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages