67 lines
1.5 KiB
Go

package commands
import (
"context"
"fmt"
"log/slog"
"os"
"git.maximotejeda.com/maximo/telegram-base-bot/internal/application/helpers"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
)
var (
HELPSTRING =`
# Telegram Base Bot
This is an Simple example template to
initiate bots projects with the same
basic functionalities needed common
on all prj like:
-\ Keyboard Making
-\ Command Handler
-\ Interaction Handler
-\ Message Handler
-\ Callback Query
-\ MiddleWares:
-\ Singleflight
-\ rate limiting
-\ Login
The service is highly dependant on
the tgb user microservice which is
in charge of hanlding the bot and
authing users and banning
`
)
func RegisterCommands(ctx context.Context, log *slog.Logger, b *bot.Bot){
b.RegisterHandler(bot.HandlerTypeMessageText, "/help",bot.MatchTypeExact, HelpCommand)
}
func HelpCommand(ctx context.Context, b *bot.Bot, update *models.Update){
_, err := b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: fmt.Sprintf("%s", HELPSTRING),
ParseMode: models.ParseModeHTML,
})
if err != nil {
fmt.Println(err)
}
icon , err := os.ReadFile("icon.png")
if err != nil {
fmt.Println(err)
fmt.Println(os.Getwd())
}
//helpers.SendDocument(ctx, b, update, []byte("hello try"), "hello.txt")
err = helpers.SendPhotos(ctx, b, update, icon, "fb logo")
if err != nil {
fmt.Println(err)
}
}