Fixing a bunch of bugs and making some improvements #19

Merged
skobkin merged 6 commits from fix_chat_type_middleware_nil_pointer into main 2024-03-12 20:08:50 +00:00
2 changed files with 25 additions and 1 deletions
Showing only changes of commit 3fa7c2434f - Show all commits

24
bot/logger.go Normal file
View file

@ -0,0 +1,24 @@
package bot
import (
"fmt"
"log/slog"
)
type Logger struct {
prefix string
}
func NewLogger(prefix string) Logger {
return Logger{
prefix: prefix,
}
}
func (l Logger) Debugf(format string, args ...any) {
slog.Debug(l.prefix + fmt.Sprint(format, args))
}
func (l Logger) Errorf(format string, args ...any) {
slog.Error(l.prefix + fmt.Sprintf(format, args))
}

View file

@ -20,7 +20,7 @@ func main() {
llmc := llm.NewConnector(ollamaBaseUrl, ollamaToken) llmc := llm.NewConnector(ollamaBaseUrl, ollamaToken)
ext := extractor.NewExtractor() ext := extractor.NewExtractor()
telegramApi, err := tg.NewBot(telegramToken, tg.WithDefaultLogger(false, true)) telegramApi, err := tg.NewBot(telegramToken, tg.WithLogger(bot.NewLogger("telego: ")))
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
os.Exit(1) os.Exit(1)