Files
YaeMikoBot/plugins/service.go
2026-03-12 18:11:27 +03:00

47 lines
1.3 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package plugins
import (
"fmt"
"runtime"
"strings"
"ymgb/database"
"ymgb/utils"
"git.nix13.pw/scuroneko/laniakea"
)
func RegisterService() *laniakea.Plugin[database.Context] {
p := laniakea.NewPlugin[database.Context]("service")
p.AddPayload(p.NewCommand(generalClose, "general.close"))
p.NewCommand(about, "about")
p.NewCommand(about, "о боте")
return p
}
func about(ctx *laniakea.MsgContext, _ *database.Context) {
formatVersion := func() string {
v := fmt.Sprintf("%d.%d.%d", laniakea.VersionMajor, laniakea.VersionMinor, laniakea.VersionPatch)
if laniakea.VersionBeta > 0 {
v += fmt.Sprintf(" Beta %d", laniakea.VersionBeta)
}
return v
}
out := []string{
fmt.Sprintf("*Версия Go*: %s", runtime.Version()[2:]),
fmt.Sprintf("*Версия Laniakea*: %s", formatVersion()),
fmt.Sprintf("*Время сборки*: %s", utils.BuildTime),
fmt.Sprintf("*Git хеш*: %s", utils.GitCommit),
}
kb := laniakea.NewInlineKeyboard(2)
kb.AddUrlButtonStyle("Канал", laniakea.ButtonStylePrimary, "https://t.me/ym_gbot_news")
kb.AddUrlButtonStyle("Чат", laniakea.ButtonStylePrimary, "https://t.me/ym_gbot_chat")
ctx.KeyboardMarkdown(laniakea.EscapePunctuation(strings.Join(out, "\n")), kb)
}
func generalClose(ctx *laniakea.MsgContext, _ *database.Context) {
ctx.CallbackDelete()
ctx.AnswerCbQuery()
}