package com.github.bumblebee.command.start

import org.apache.commons.io.IOUtils
import org.springframework.stereotype.Component
import telegram.api.BotApi
import telegram.domain.Update
import telegram.domain.request.ParseMode
import telegram.polling.UpdateHandler
import java.io.IOException
import java.io.StringWriter

@Component
class StartCommand(val botApi: BotApi) : UpdateHandler {
    private val helpText: String by lazy {
        try {
            StartCommand::class.java.classLoader.getResourceAsStream("start.md").use { stream ->
                val sw = StringWriter()
                IOUtils.copy(stream, sw)
                return@lazy sw.toString()
            }
        } catch (e: IOException) {
            throw RuntimeException(e)
        }
    }

    override fun onUpdate(update: Update): Boolean {
        botApi.sendMessage(update.message.chat.id, helpText, ParseMode.MARKDOWN, null,
                update.message.messageId, null)
        return true
    }

}
package com.github.bumblebee.command.start

import org.apache.commons.io.FileUtils
import org.springframework.core.io.ClassPathResource
import org.springframework.stereotype.Component
import telegram.api.BotApi
import telegram.domain.Update
import telegram.domain.request.ParseMode
import telegram.polling.UpdateHandler

@Component
class StartCommand(val botApi: BotApi) : UpdateHandler {
    private val helpText: String by lazy {
        FileUtils.readFileToString(ClassPathResource("start.md").file)
    }

    override fun onUpdate(update: Update): Boolean {
        botApi.sendMessage(update.message.chat.id, helpText, ParseMode.MARKDOWN, null,
                update.message.messageId, null)
        return true
    }

}
Simplify reading of start.md file for /start command.
Simplify reading of start.md file for /start command.

fare1990/telegram-bot-bumblebee,fare1990/telegram-bot-bumblebee,denzelby/telegram-bot-bumblebee,fare1990/telegram-bot-bumblebee