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-10 01:51:01 +00:00
|
|
|
telegramApi, err := tg.NewBot(telegramToken, tg.WithDefaultLogger(false, true))
|
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 {
|
|
|
|
slog.Error("Running bot finished with an error", err)
|
|
|
|
os.Exit(1)
|
2024-03-08 02:15:03 +00:00
|
|
|
}
|
|
|
|
}
|