2024-03-08 02:15:03 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log/slog"
|
|
|
|
"os"
|
2024-03-10 01:51:01 +00:00
|
|
|
"telegram-ollama-reply-bot/bot"
|
|
|
|
"telegram-ollama-reply-bot/extractor"
|
|
|
|
"telegram-ollama-reply-bot/llm"
|
2024-03-08 02:15:03 +00:00
|
|
|
|
|
|
|
tg "github.com/mymmrac/telego"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
ollamaToken := os.Getenv("OLLAMA_TOKEN")
|
|
|
|
ollamaBaseUrl := os.Getenv("OLLAMA_BASE_URL")
|
|
|
|
|
|
|
|
telegramToken := os.Getenv("TELEGRAM_TOKEN")
|
|
|
|
|
2024-03-10 01:51:01 +00:00
|
|
|
llmc := llm.NewConnector(ollamaBaseUrl, ollamaToken)
|
|
|
|
ext := extractor.NewExtractor()
|
2024-03-08 02:15:03 +00:00
|
|
|
|
2024-03-12 20:05:52 +00:00
|
|
|
telegramApi, err := tg.NewBot(telegramToken, tg.WithLogger(bot.NewLogger("telego: ")))
|
2024-03-08 02:15:03 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2024-03-10 01:51:01 +00:00
|
|
|
botService := bot.NewBot(telegramApi, llmc, ext)
|
2024-03-08 02:15:03 +00:00
|
|
|
|
2024-03-10 01:51:01 +00:00
|
|
|
err = botService.Run()
|
|
|
|
if err != nil {
|
2024-03-12 19:06:40 +00:00
|
|
|
slog.Error("Running bot finished with an error", "error", err)
|
2024-03-10 01:51:01 +00:00
|
|
|
os.Exit(1)
|
2024-03-08 02:15:03 +00:00
|
|
|
}
|
|
|
|
}
|