Testing a few things.

This commit is contained in:
Benjamin A. Shelton 2026-09-10 15:44:40 -06:00
commit 9e2bb347db
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01

View file

@ -2,22 +2,32 @@ package main
import ( import (
"context" "context"
_ "os" "os"
_ "os/signal" "os/signal"
"sync"
"time"
"github.com/go-telegram/bot" "github.com/go-telegram/bot"
"github.com/go-telegram/bot/models" "github.com/go-telegram/bot/models"
"github.com/joho/godotenv"
"github.com/robfig/cron/v3"
"fmt" "fmt"
"git.destrealm.net/zancarius/justusbot/internal/bible" _ "git.destrealm.net/zancarius/justusbot/internal/bible"
"git.destrealm.net/zancarius/justusbot/internal/settings" _ "git.destrealm.net/zancarius/justusbot/internal/settings"
) )
// Send any text message to the bot after the bot has been started // Send any text message to the bot after the bot has been started
func main() { func main() {
/*ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) if err := godotenv.Load(); err != nil {
panic(fmt.Sprintf("dotenv: %s", err))
}
wg := &sync.WaitGroup{}
ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
defer cancel() defer cancel()
opts := []bot.Option{ opts := []bot.Option{
@ -26,18 +36,36 @@ func main() {
b, err := bot.New(os.Getenv("TOKEN"), opts...) b, err := bot.New(os.Getenv("TOKEN"), opts...)
if nil != err { if nil != err {
// panics for the sake of simplicity. fmt.Errorf("%v", err)
// you should handle this error properly in your code.
panic(err)
} }
b.RegisterHandler(bot.HandlerTypeMessageText, "/start", bot.MatchTypeExact, startHandler)
b.Start(ctx)*/ c := cron.New()
fmt.Println(bible.FindAlias("mat")) c.AddFunc("TZ=America/Denver 7 14 * * *", func(){fmt.Println("testing at 2pm")})
c.Start()
wg.Add(1)
go func(){
defer wg.Done()
b.Start(ctx)
}()
wg.Add(1)
go func(){
defer wg.Done()
time.Sleep(1*time.Second)
fmt.Println(b)
}()
wg.Wait()
/*fmt.Println(bible.FindAlias("mat"))
s, err := settings.LoadSettings("settings.toml") s, err := settings.LoadSettings("settings.toml")
fmt.Println(s, err) fmt.Println(s, err)*/
} }
func handler(ctx context.Context, b *bot.Bot, update *models.Update) { func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
fmt.Println(b.GetMe(ctx))
/*if update.Message != nil { /*if update.Message != nil {
b.SendMessage(ctx, &bot.SendMessageParams{ b.SendMessage(ctx, &bot.SendMessageParams{
ChatID: update.Message.Chat.ID, ChatID: update.Message.Chat.ID,
@ -45,3 +73,7 @@ func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
}) })
}*/ }*/
} }
func startHandler(ctx context.Context, b *bot.Bot, update *models.Update) {
fmt.Println("received start:", b, update)
}