provide support of inlines

This commit is contained in:
InsanusMokrassar 2022-09-09 19:46:32 +06:00
parent bf68fc58f4
commit 23be7cac81
4 changed files with 50 additions and 1 deletions

View File

@ -94,7 +94,8 @@ object Plugin : Plugin {
"Delete post", "Delete post",
listOf( listOf(
Format("/delete_post") Format("/delete_post")
) ),
"Should be used with a reply on any post message"
) )
) )
} }

View File

@ -5,6 +5,9 @@ import dev.inmo.micro_utils.fsm.common.State
import dev.inmo.micro_utils.repos.create import dev.inmo.micro_utils.repos.create
import dev.inmo.plagubot.Plugin import dev.inmo.plagubot.Plugin
import dev.inmo.plaguposter.common.* import dev.inmo.plaguposter.common.*
import dev.inmo.plaguposter.inlines.models.Format
import dev.inmo.plaguposter.inlines.models.OfferTemplate
import dev.inmo.plaguposter.inlines.repos.InlineTemplatesRepo
import dev.inmo.plaguposter.posts.models.* import dev.inmo.plaguposter.posts.models.*
import dev.inmo.plaguposter.posts.registrar.state.RegistrationState import dev.inmo.plaguposter.posts.registrar.state.RegistrationState
import dev.inmo.plaguposter.posts.repo.PostsRepo import dev.inmo.plaguposter.posts.repo.PostsRepo
@ -134,5 +137,13 @@ object Plugin : Plugin {
) )
) )
} }
koin.getOrNull<InlineTemplatesRepo>() ?.apply {
addTemplate(
OfferTemplate(
"Start post",
listOf(Format("start_post"))
)
)
}
} }
} }

View File

@ -10,6 +10,9 @@ import dev.inmo.micro_utils.repos.pagination.getAll
import dev.inmo.micro_utils.repos.set import dev.inmo.micro_utils.repos.set
import dev.inmo.plagubot.Plugin import dev.inmo.plagubot.Plugin
import dev.inmo.plaguposter.common.* import dev.inmo.plaguposter.common.*
import dev.inmo.plaguposter.inlines.models.Format
import dev.inmo.plaguposter.inlines.models.OfferTemplate
import dev.inmo.plaguposter.inlines.repos.InlineTemplatesRepo
import dev.inmo.plaguposter.posts.models.PostId import dev.inmo.plaguposter.posts.models.PostId
import dev.inmo.plaguposter.posts.repo.PostsRepo import dev.inmo.plaguposter.posts.repo.PostsRepo
import dev.inmo.plaguposter.ratings.models.Rating import dev.inmo.plaguposter.ratings.models.Rating
@ -189,5 +192,22 @@ object Plugin : Plugin {
} }
} }
} }
koin.getOrNull<InlineTemplatesRepo>() ?.apply {
addTemplate(
OfferTemplate(
"Enable ratings for post",
listOf(Format("attach_ratings")),
"Require reply on post message"
)
)
addTemplate(
OfferTemplate(
"Disable ratings for post",
listOf(Format("detach_ratings")),
"Require reply on post message"
)
)
}
} }
} }

View File

@ -4,6 +4,9 @@ import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
import dev.inmo.micro_utils.fsm.common.State import dev.inmo.micro_utils.fsm.common.State
import dev.inmo.plagubot.Plugin import dev.inmo.plagubot.Plugin
import dev.inmo.plaguposter.common.SuccessfulSymbol import dev.inmo.plaguposter.common.SuccessfulSymbol
import dev.inmo.plaguposter.inlines.models.Format
import dev.inmo.plaguposter.inlines.models.OfferTemplate
import dev.inmo.plaguposter.inlines.repos.InlineTemplatesRepo
import dev.inmo.plaguposter.posts.repo.PostsRepo import dev.inmo.plaguposter.posts.repo.PostsRepo
import dev.inmo.plaguposter.posts.sending.PostPublisher import dev.inmo.plaguposter.posts.sending.PostPublisher
import dev.inmo.plaguposter.ratings.selector.Selector import dev.inmo.plaguposter.ratings.selector.Selector
@ -64,5 +67,19 @@ object Plugin : Plugin {
it.content.textSources + regular(SuccessfulSymbol) it.content.textSources + regular(SuccessfulSymbol)
) )
} }
koin.getOrNull<InlineTemplatesRepo>() ?.apply {
addTemplate(
OfferTemplate(
"Publish post",
listOf(Format("publish_post")),
if (selector == null) {
"Require reply on post message"
} else {
"Publish post according to selector in system or post with message from reply"
}
)
)
}
} }
} }