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

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

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

import io.github.dehuckakpyt.telegrambot.model.message.JpaTelegramMessage
import io.github.dehuckakpyt.telegrambot.model.telegram.Message
import io.github.dehuckakpyt.telegrambot.repository.message.JpaTelegramMessageRepository
import io.github.dehuckakpyt.telegrambot.transaction.action.TransactionAction

open class JpaTelegramMessageSource(
    private val transactional: TransactionAction,
    private val repository: JpaTelegramMessageRepository,
) : MessageSource {

    override suspend fun save(message: Message, fromBot: Boolean, type: String, step: String?, stepContainerType: String?, text: String?, fileIds: List?): Unit = transactional {
        repository.save(
            JpaTelegramMessage(
                chatId = message.chat.id,
                fromId = message.from!!.id,
                fromBot = fromBot,
                messageId = message.messageId,
                type = type,
                step = step,
                stepContainerType = stepContainerType,
                text = text,
                fileIds = fileIds,
            )
        )
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy