return err
}
- botSettings, hasBot, err := loadBotConfig(dir)
+ botSettings, hasBot, err := loadTelegramConfig(dir)
if err != nil {
return err
}
return err
}
- client := newClient(address, auth, agent.CacheKey(), filepath.Join(agent.dir, "usage.jsonl"))
+ client := newModelClient(address, auth, agent.CacheKey(), filepath.Join(agent.dir, "usage.jsonl"))
memory, err := openMemory(ctx, agent.dir, time.Now, newCompactor(client, agent.Prompt, config.Compactor))
if err != nil {
return err
return errors.Join(err, listener.Close())
}
- var telegram *telegramBot
+ var telegram *TelegramBot
if hasBot {
- telegram = newTelegramBot(newBotAPI(telegramAPI, botSettings.Token), botSettings.Owner, filepath.Join(agent.dir, offsetFileName), log.New(out, "telegram: ", log.LstdFlags))
+ telegram = newTelegramBot(newTelegramAPI(telegramAPIURL, botSettings.Token), botSettings.Owner, filepath.Join(agent.dir, telegramOffsetFileName), log.New(out, "telegram: ", log.LstdFlags))
_, err = fmt.Fprintln(out, "onechat: the Telegram bot waits for messages of its owner")
if err != nil {
return errors.Join(err, listener.Close())
// serveAgent runs the loop that start makes and serves the clients of
// listener until ctx ends or the loop fails. It closes listener. When bot is
// not nil, it runs the bot too, and a failure of the bot stops the agent.
-func serveAgent(ctx context.Context, listener net.Listener, bot *telegramBot, start func(notify func(Event)) (*loop, error)) error {
+func serveAgent(ctx context.Context, listener net.Listener, bot *TelegramBot, start func(notify func(Event)) (*loop, error)) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()