tg/cmd/test/start.go

46 lines
1.1 KiB
Go
Raw Permalink Normal View History

2024-03-29 14:30:48 +03:00
package main
import (
"surdeus.su/core/tg"
2024-03-29 14:30:48 +03:00
"fmt"
)
var StartWidget = tg.RenderFunc(func(c tg.Context) tg.UI {
return tg.UI{
tg.Messagef(
fmt.Sprint(
"Hello, %s!",
"The testing bot started!",
2024-03-29 14:30:48 +03:00
"You can see the basics of usage in the ",
"cmd/test/main.go file and other files in the cmd/test!",
2024-03-29 14:30:48 +03:00
),
c.CallbackUpdate().SentFrom().UserName,
).Inline(
tg.NewKeyboard().Row(
tg.Buttonf("TeleGopher surdeus.su page").
WithURL("https://surdeus.su/core/tg"),
2024-03-29 14:30:48 +03:00
).Inline(),
),
tg.Messagef("Choose your interest").Reply(
tg.NewKeyboard().List(
tg.Buttonf("Back").Go(BackWidget),
tg.Buttonf("Inc/Dec").Go(IncDecWidget),
tg.Buttonf("Mutate messages").Go(MutateMessagesWidget),
tg.Buttonf("Send location").Go(LocationWidget),
tg.Buttonf("Dynamic panel").Go(DynamicPanelWidget),
tg.Buttonf("Check panic").Go(nil),
2024-03-29 14:30:48 +03:00
).Reply(),
),
// Testing reaction to editing messages.
tg.Func(func(c tg.Context) {
for u := range c.Input() {
if u.EditedMessage != nil {
c.Sendf2("The new message is `%s`", u.EditedMessage.Text)
}
}
}),
}
})