2023-07-03 17:22:45 +03:00
|
|
|
package main
|
|
|
|
|
2023-07-08 22:26:21 +03:00
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"os"
|
|
|
|
|
2023-07-12 00:33:51 +03:00
|
|
|
//tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
|
|
"boteval/src/behx"
|
2023-07-09 01:28:59 +03:00
|
|
|
)
|
|
|
|
|
2023-07-12 02:02:33 +03:00
|
|
|
var rootKbd = behx.NewKeyboard(
|
|
|
|
behx.NewButtonRow(
|
|
|
|
behx.NewButton(
|
2023-07-12 14:06:05 +03:00
|
|
|
"1",
|
2023-07-12 02:02:33 +03:00
|
|
|
behx.NewCustomAction(func(c *behx.Context){
|
|
|
|
log.Println("pressed the button!")
|
|
|
|
}),
|
2023-07-09 01:28:59 +03:00
|
|
|
),
|
2023-07-12 02:02:33 +03:00
|
|
|
behx.NewButton("PRESS ME 2", behx.NewCustomAction(func(c *behx.Context){
|
|
|
|
log.Println("pressed another button!")
|
|
|
|
})),
|
|
|
|
),
|
|
|
|
behx.NewButtonRow(
|
2023-07-12 14:06:05 +03:00
|
|
|
behx.NewButton("To second screen", behx.NewScreenChange("second")),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
var secondKbd = behx.NewKeyboard(
|
|
|
|
behx.NewButtonRow(
|
|
|
|
behx.NewButton(
|
|
|
|
"❤",
|
2023-07-12 14:20:52 +03:00
|
|
|
behx.NewScreenChange("start"),
|
2023-07-12 14:06:05 +03:00
|
|
|
),
|
2023-07-12 02:02:33 +03:00
|
|
|
),
|
|
|
|
)
|
|
|
|
|
|
|
|
var inlineKbd = behx.NewKeyboard(
|
|
|
|
behx.NewButtonRow(
|
|
|
|
behx.NewButton(
|
|
|
|
"INLINE PRESS ME",
|
|
|
|
behx.NewCustomAction(func(c *behx.Context){
|
|
|
|
log.Println("INLINE pressed the button!")
|
|
|
|
}),
|
2023-07-09 01:28:59 +03:00
|
|
|
),
|
2023-07-12 02:02:33 +03:00
|
|
|
behx.NewButton("INLINE PRESS ME 2", behx.NewCustomAction(func(c *behx.Context){
|
|
|
|
log.Println("INLINE pressed another button!")
|
|
|
|
})),
|
|
|
|
),
|
|
|
|
behx.NewButtonRow(
|
2023-07-12 14:30:05 +03:00
|
|
|
behx.NewButton(
|
|
|
|
"INLINE PRESS ME 3",
|
|
|
|
behx.ScreenChange("second"),
|
|
|
|
),
|
2023-07-09 01:28:59 +03:00
|
|
|
),
|
2023-07-08 22:26:21 +03:00
|
|
|
)
|
|
|
|
|
2023-07-12 02:02:33 +03:00
|
|
|
|
|
|
|
var startScreen = behx.NewScreen(
|
|
|
|
"Hello, World!",
|
|
|
|
"inline",
|
|
|
|
"root",
|
|
|
|
)
|
|
|
|
|
2023-07-12 14:06:05 +03:00
|
|
|
var secondScreen = behx.NewScreen(
|
|
|
|
"Second screen!",
|
|
|
|
"",
|
|
|
|
"second",
|
|
|
|
)
|
|
|
|
|
2023-07-12 02:02:33 +03:00
|
|
|
var behaviour = behx.NewBehaviour(
|
|
|
|
behx.NewScreenChange("start"),
|
|
|
|
behx.ScreenMap{
|
2023-07-09 01:28:59 +03:00
|
|
|
"start": startScreen,
|
2023-07-12 14:06:05 +03:00
|
|
|
"second": secondScreen,
|
2023-07-09 01:28:59 +03:00
|
|
|
},
|
2023-07-12 02:02:33 +03:00
|
|
|
behx.KeyboardMap{
|
|
|
|
"root": rootKbd,
|
|
|
|
"inline": inlineKbd,
|
2023-07-12 14:06:05 +03:00
|
|
|
"second": secondKbd,
|
2023-07-12 02:02:33 +03:00
|
|
|
},
|
|
|
|
)
|
2023-07-09 01:28:59 +03:00
|
|
|
|
2023-07-03 17:22:45 +03:00
|
|
|
func main() {
|
2023-07-08 22:26:21 +03:00
|
|
|
token := os.Getenv("BOT_TOKEN")
|
|
|
|
|
2023-07-12 00:33:51 +03:00
|
|
|
bot, err := behx.NewBot(token, behaviour, nil)
|
2023-07-08 22:26:21 +03:00
|
|
|
if err != nil {
|
|
|
|
log.Panic(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
bot.Debug = true
|
|
|
|
|
|
|
|
log.Printf("Authorized on account %s", bot.Self.UserName)
|
2023-07-12 00:33:51 +03:00
|
|
|
bot.Run()
|
2023-07-03 17:22:45 +03:00
|
|
|
}
|
2023-07-08 22:26:21 +03:00
|
|
|
|