mirror of
				https://github.com/InsanusMokrassar/PlaguBot.git
				synced 2025-11-03 21:50:04 +00:00 
			
		
		
		
	fixes/fill of docs
This commit is contained in:
		@@ -1,10 +1,14 @@
 | 
			
		||||
package dev.inmo.plagubot
 | 
			
		||||
 | 
			
		||||
import dev.inmo.kslog.common.*
 | 
			
		||||
import dev.inmo.micro_utils.fsm.common.State
 | 
			
		||||
import dev.inmo.plagubot.HelloPlugin.setupBotPlugin
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.api.send.reply
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContextWithFSM
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onCommand
 | 
			
		||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.triggers_handling.onUnhandledCommand
 | 
			
		||||
import kotlinx.serialization.SerialName
 | 
			
		||||
import kotlinx.serialization.Serializable
 | 
			
		||||
import kotlinx.serialization.json.Json
 | 
			
		||||
 
 | 
			
		||||
@@ -62,7 +62,7 @@ data class PlaguBot(
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
 | 
			
		||||
    override suspend fun BehaviourContextWithFSM<State>.setupBotPlugin(koin: Koin) {
 | 
			
		||||
        config.plugins.map { plugin ->
 | 
			
		||||
            launch {
 | 
			
		||||
                runCatchingSafely {
 | 
			
		||||
@@ -113,7 +113,7 @@ data class PlaguBot(
 | 
			
		||||
            behaviourContext = this
 | 
			
		||||
            setupBotPlugin(koinApp.koin)
 | 
			
		||||
            deleteWebhook()
 | 
			
		||||
        }
 | 
			
		||||
        }.start()
 | 
			
		||||
        logger.i("Behaviour builder has been setup")
 | 
			
		||||
        return bot.startGettingOfUpdatesByLongPolling(scope = behaviourContext, updatesFilter = behaviourContext).also {
 | 
			
		||||
            logger.i("Long polling has been started")
 | 
			
		||||
 
 | 
			
		||||
@@ -25,9 +25,19 @@ interface Plugin {
 | 
			
		||||
        database: Database,
 | 
			
		||||
        params: JsonObject
 | 
			
		||||
    ) {}
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Override this method in cases when you want to declare common bot behaviour. In case you wish to use FSM, you
 | 
			
		||||
     * should override the method with receiver [BehaviourContextWithFSM]
 | 
			
		||||
     */
 | 
			
		||||
    suspend fun BehaviourContext.setupBotPlugin(
 | 
			
		||||
        koin: Koin
 | 
			
		||||
    ) {}
 | 
			
		||||
    /**
 | 
			
		||||
     * Override this method in cases when you want to declare full behaviour of the plugin. It is recommended to declare
 | 
			
		||||
     * common logic of plugin in the [setupBotPlugin] with [BehaviourContext] receiver and use override this one
 | 
			
		||||
     * for the FSM configuration
 | 
			
		||||
     */
 | 
			
		||||
    suspend fun BehaviourContextWithFSM<State>.setupBotPlugin(koin: Koin) {
 | 
			
		||||
        (this as BehaviourContext).setupBotPlugin(koin)
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user