]> git.giacomolli.uk - onechat/blobdiff - daemon.go
Name and order the Telegram bot code
[onechat] / daemon.go
index b37e0cf7c29a45fa7d2f3d37a34060b58d4af79b..5486843771dbb1a3f92ba2be473a5120d6aae530 100644 (file)
--- a/daemon.go
+++ b/daemon.go
@@ -74,7 +74,7 @@ func daemon(ctx context.Context, out io.Writer) (err error) {
                return err
        }
 
                return err
        }
 
-       botSettings, hasBot, err := loadBotConfig(dir)
+       botSettings, hasBot, err := loadTelegramConfig(dir)
        if err != nil {
                return err
        }
        if err != nil {
                return err
        }
@@ -118,9 +118,9 @@ func daemon(ctx context.Context, out io.Writer) (err error) {
                return errors.Join(err, listener.Close())
        }
 
                return errors.Join(err, listener.Close())
        }
 
-       var telegram *telegramBot
+       var telegram *TelegramBot
        if hasBot {
        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())
                _, err = fmt.Fprintln(out, "onechat: the Telegram bot waits for messages of its owner")
                if err != nil {
                        return errors.Join(err, listener.Close())
@@ -135,7 +135,7 @@ func daemon(ctx context.Context, out io.Writer) (err error) {
 // 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.
 // 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()
 
        ctx, cancel := context.WithCancel(ctx)
        defer cancel()