Skip to content

Commit 8d1a59b

Browse files
committed
chore(telegram): gofmt alignment pass
1 parent 136cde9 commit 8d1a59b

9 files changed

Lines changed: 60 additions & 64 deletions

File tree

internal/telegram/approver.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ type pendingRequest struct {
4848
//
4949
// Thread-safe: PromptCommand and HandleCallback are safe to call concurrently.
5050
type TelegramApprover struct {
51-
bot *Bot
52-
pending map[string]*pendingRequest // requestID -> pending request
53-
mu sync.Mutex
54-
trusted map[danger.RiskClass]bool
51+
bot *Bot
52+
pending map[string]*pendingRequest // requestID -> pending request
53+
mu sync.Mutex
54+
trusted map[danger.RiskClass]bool
5555
trustAll bool // when true, all PromptCommand calls auto-approve
56-
log Logger
57-
cancel chan struct{} // closed by Cancel() to interrupt waiting PromptCommand
56+
log Logger
57+
cancel chan struct{} // closed by Cancel() to interrupt waiting PromptCommand
5858

5959
// ChatID is the Telegram chat where approval prompts are sent.
6060
ChatID int64

internal/telegram/bot.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ func NewBot(token string) *Bot {
5252
Token: token,
5353
BaseURL: fmt.Sprintf("https://api.telegram.org/bot%s", token),
5454
FileBaseURL: fmt.Sprintf("https://api.telegram.org/file/bot%s", token),
55-
Client: transport.NewPooledClient(60 * time.Second),
55+
Client: transport.NewPooledClient(60 * time.Second),
5656
stopRetries: make(chan struct{}),
57-
log: NewNopLogger(),
57+
log: NewNopLogger(),
5858
}
5959
}
6060

internal/telegram/bot_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1710,4 +1710,3 @@ func TestIsFatalAPIError(t *testing.T) {
17101710
}
17111711
}
17121712
}
1713-

internal/telegram/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ type TelegramConfig struct {
1313
AllowedChats []int64 `json:"allowed_chats"`
1414
AllowedUsers []int64 `json:"allowed_users"`
1515
BotUsername string `json:"bot_username"`
16-
PollInterval int `json:"poll_interval"` // seconds, default 1
17-
PollTimeout int `json:"poll_timeout"` // seconds, default 30
18-
MaxMsgLength int `json:"max_msg_length"` // default 4096
19-
DailyTokenBudget int64 `json:"daily_token_budget"` // 0 = unlimited (default)
20-
SessionTTL int `json:"session_ttl_hours"` // hours, default 24
16+
PollInterval int `json:"poll_interval"` // seconds, default 1
17+
PollTimeout int `json:"poll_timeout"` // seconds, default 30
18+
MaxMsgLength int `json:"max_msg_length"` // default 4096
19+
DailyTokenBudget int64 `json:"daily_token_budget"` // 0 = unlimited (default)
20+
SessionTTL int `json:"session_ttl_hours"` // hours, default 24
2121
AgentTimeout int `json:"agent_timeout_seconds"` // max agent run duration, default 900 (15m), 0 = unlimited
2222
FallbackURLs []string `json:"fallback_urls"`
23-
HealthAddr string `json:"health_addr"` // e.g. "127.0.0.1:9090" (empty = disabled)
24-
LogLevel string `json:"log_level"` // "debug","info","warn","error" (default "info")
25-
LogFile string `json:"log_file"` // path or empty for stderr
26-
DefaultChatID int64 `json:"default_chat_id"` // for --deliver and cron delivery
23+
HealthAddr string `json:"health_addr"` // e.g. "127.0.0.1:9090" (empty = disabled)
24+
LogLevel string `json:"log_level"` // "debug","info","warn","error" (default "info")
25+
LogFile string `json:"log_file"` // path or empty for stderr
26+
DefaultChatID int64 `json:"default_chat_id"` // for --deliver and cron delivery
2727
}
2828

2929
// DefaultConfig returns a TelegramConfig with sensible defaults.

internal/telegram/handler.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,16 @@ func (h *Handler) DeleteApprover(chatID int64) {
9494
// NewHandler creates a Handler with the given bot and default settings.
9595
func NewHandler(bot *Bot) *Handler {
9696
return &Handler{
97-
Bot: bot,
97+
Bot: bot,
9898
Config: HandlerConfig{
9999
MaxMsgLength: 4096,
100100
},
101-
log: NewNopLogger(),
102-
OnTextMessage: defaultTextHandler(),
103-
OnCallbackQuery: defaultCallbackHandler(),
104-
OnCommand: defaultCommandHandler(),
105-
OnVoiceMessage: defaultVoiceHandler(bot),
106-
OnPhotoMessage: defaultPhotoHandler(bot),
101+
log: NewNopLogger(),
102+
OnTextMessage: defaultTextHandler(),
103+
OnCallbackQuery: defaultCallbackHandler(),
104+
OnCommand: defaultCommandHandler(),
105+
OnVoiceMessage: defaultVoiceHandler(bot),
106+
OnPhotoMessage: defaultPhotoHandler(bot),
107107
OnDocumentMessage: defaultDocumentHandler(bot),
108108
}
109109
}
@@ -266,7 +266,7 @@ func (h *Handler) handleMessage(msg *Message) {
266266
h.SendResponse(msg.Chat.ID, resp, msg.ID)
267267
}
268268
}
269-
case msg.Text != "":
269+
case msg.Text != "":
270270
if h.OnTextMessage != nil {
271271
resp, err := h.OnTextMessage(msg.Chat.ID, msg.ID, msg.Text)
272272
if err != nil {
@@ -579,7 +579,6 @@ func extractCommand(text string) (cmd string, args string) {
579579
return cmdPart, args
580580
}
581581

582-
583582
// approvalToast returns a toast message for an approval callback action.
584583
// Parses the callback data prefix to determine the user's choice.
585584
func approvalToast(data string) string {

internal/telegram/plan_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ func TestMostRecentPlan_Empty(t *testing.T) {
260260

261261
func TestFirstLine(t *testing.T) {
262262
tests := []struct {
263-
input string
264-
maxLen int
265-
expect string
263+
input string
264+
maxLen int
265+
expect string
266266
}{
267267
{"# Heading\ncontent", 80, "Heading"},
268268
{"single line", 80, "single line"},

internal/telegram/session.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
// session.Store. Each Telegram chat gets its own session identified by
2121
// "tg-<chatID>". An in-memory cache avoids redundant disk reads.
2222
type SessionManager struct {
23-
Store *session.Store
24-
Cache map[int64]*ChatSession
25-
Mu sync.RWMutex
26-
BaseDir string
27-
SessionTTL time.Duration
23+
Store *session.Store
24+
Cache map[int64]*ChatSession
25+
Mu sync.RWMutex
26+
BaseDir string
27+
SessionTTL time.Duration
2828
clarifyChannels sync.Map // map[int64]chan string — per-chat clarify response channels
2929
}
3030

internal/telegram/session_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,8 +592,6 @@ func TestConcurrentSave(t *testing.T) {
592592
}
593593
}
594594

595-
596-
597595
// TestConcurrentMixed runs GetOrCreate, Save, Load, and Delete
598596
// concurrently with distinct chat ID ranges per operation to avoid
599597
// triggering the known post-unlock field race in Save, while still

internal/telegram/types.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@ const (
1010

1111
// Update represents an incoming Telegram update.
1212
type Update struct {
13-
ID int `json:"update_id"`
14-
Message *Message `json:"message,omitempty"`
15-
EditedMessage *Message `json:"edited_message,omitempty"`
16-
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
13+
ID int `json:"update_id"`
14+
Message *Message `json:"message,omitempty"`
15+
EditedMessage *Message `json:"edited_message,omitempty"`
16+
CallbackQuery *CallbackQuery `json:"callback_query,omitempty"`
1717
}
1818

1919
// Message represents a Telegram message.
2020
type Message struct {
21-
ID int `json:"message_id"`
22-
From *User `json:"from,omitempty"`
23-
Chat *Chat `json:"chat,omitempty"`
24-
Date int `json:"date,omitempty"`
25-
Text string `json:"text,omitempty"`
26-
Entities []MessageEntity `json:"entities,omitempty"`
27-
Photo []PhotoSize `json:"photo,omitempty"`
28-
Voice *Voice `json:"voice,omitempty"`
29-
Document *Document `json:"document,omitempty"`
30-
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
21+
ID int `json:"message_id"`
22+
From *User `json:"from,omitempty"`
23+
Chat *Chat `json:"chat,omitempty"`
24+
Date int `json:"date,omitempty"`
25+
Text string `json:"text,omitempty"`
26+
Entities []MessageEntity `json:"entities,omitempty"`
27+
Photo []PhotoSize `json:"photo,omitempty"`
28+
Voice *Voice `json:"voice,omitempty"`
29+
Document *Document `json:"document,omitempty"`
30+
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
3131
}
3232

3333
// User represents a Telegram user or bot.
@@ -132,36 +132,36 @@ type WebhookInfo struct {
132132

133133
// SendOpts contains optional parameters for SendMessage.
134134
type SendOpts struct {
135-
ParseMode string `json:"parse_mode,omitempty"`
136-
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
137-
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
138-
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
135+
ParseMode string `json:"parse_mode,omitempty"`
136+
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
137+
DisableWebPagePreview bool `json:"disable_web_page_preview,omitempty"`
138+
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
139139
}
140140

141141
// UpdateResponse is the generic Telegram API response for a single update-related request.
142142
type UpdateResponse struct {
143-
OK bool `json:"ok"`
144-
Result json.RawMessage `json:"result,omitempty"`
145-
Description string `json:"description,omitempty"`
146-
ErrorCode int `json:"error_code,omitempty"`
143+
OK bool `json:"ok"`
144+
Result json.RawMessage `json:"result,omitempty"`
145+
Description string `json:"description,omitempty"`
146+
ErrorCode int `json:"error_code,omitempty"`
147147
}
148148

149149
// UserProfilePhotos contains a set of user profile photos.
150150
type UserProfilePhotos struct {
151-
TotalCount int `json:"total_count,omitempty"`
151+
TotalCount int `json:"total_count,omitempty"`
152152
Photos [][]PhotoSize `json:"photos,omitempty"`
153153
}
154154

155155
// FileResponse is the Telegram API response for getFile.
156156
type FileResponse struct {
157-
OK bool `json:"ok"`
158-
Result *File `json:"result,omitempty"`
157+
OK bool `json:"ok"`
158+
Result *File `json:"result,omitempty"`
159159
}
160160

161161
// GetUpdatesResponse is the Telegram API response for getUpdates.
162162
type GetUpdatesResponse struct {
163-
OK bool `json:"ok"`
164-
Result []Update `json:"result,omitempty"`
163+
OK bool `json:"ok"`
164+
Result []Update `json:"result,omitempty"`
165165
}
166166

167167
// SendMessageResponse is the Telegram API response for sendMessage.

0 commit comments

Comments
 (0)