This commit is contained in:
Andrey Parhomenko 2024-01-05 03:35:27 +03:00
parent e62ccf5780
commit 07a1f562c8
2 changed files with 11 additions and 11 deletions

View file

@ -6,7 +6,7 @@ import (
"strings"
"fmt"
"github.com/di4f/tg"
"vultras.su/core/tg"
)
type BotData struct {
@ -130,32 +130,32 @@ var beh = tg.NewBehaviour().
"panel",
tg.RenderFunc(func(c *tg.Context) tg.UI {
var (
n = 0
ln = 4
n = 0
ln = 4
panel *tg.PanelCompo
)
panel = tg.NewMessage(
"Some panel",
).Panel(c, tg.RowserFunc(func(c *tg.Context) []tg.ButtonRow{
).Panel(c, tg.RowserFunc(func(c *tg.Context) []tg.ButtonRow {
btns := []tg.ButtonRow{
tg.ButtonRow{tg.NewButton("Static shit")},
}
for i:=0 ; i<ln ; i++ {
num := 1 + n * ln + i
for i := 0; i < ln; i++ {
num := 1 + n*ln + i
btns = append(btns, tg.ButtonRow{
tg.NewButton("%d", num).WithAction(tg.Func(func(c *tg.Context){
tg.NewButton("%d", num).WithAction(tg.Func(func(c *tg.Context) {
c.Sendf("%d", num*num)
})),
tg.NewButton("%d", num*num),
})
}
btns = append(btns, tg.ButtonRow{
tg.NewButton("Prev").WithAction(tg.ActionFunc(func(c *tg.Context){
tg.NewButton("Prev").WithAction(tg.ActionFunc(func(c *tg.Context) {
n--
panel.Update(c)
})),
tg.NewButton("Next").WithAction(tg.ActionFunc(func(c *tg.Context){
tg.NewButton("Next").WithAction(tg.ActionFunc(func(c *tg.Context) {
n++
panel.Update(c)
})),

2
go.mod
View file

@ -1,4 +1,4 @@
module github.com/di4f/tg
module vultras.su/core/tg
go 1.20