All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.dehuckakpyt.telegrambot.source.message.DatabaseTelegramMessageSource.kt Maven / Gradle / Ivy

There is a newer version: 0.11.2
Show newest version
package io.github.dehuckakpyt.telegrambot.source.message

import io.github.dehuckakpyt.telegrambot.model.message.DatabaseTelegramMessage
import io.github.dehuckakpyt.telegrambot.repository.message.DatabaseTelegramMessageRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

open class DatabaseTelegramMessageSource(
    private val repository: DatabaseTelegramMessageRepository,
) : MessageSource {

    override suspend fun save(chatId: Long, fromId: Long, fromBot: Boolean, messageId: Long, type: String, step: String?, stepContainerType: String?, text: String?, fileIds: List?): Unit = withContext(Dispatchers.IO) {
        repository.save(
            DatabaseTelegramMessage(
                chatId = chatId,
                fromId = fromId,
                fromBot = fromBot,
                messageId = messageId,
                type = type,
                step = step,
                stepContainerType = stepContainerType,
                text = text,
                fileIds = fileIds,
            )
        )
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy