opencode-telegram-mirror 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-telegram-mirror",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Standalone bot that mirrors OpenCode sessions to Telegram topics",
5
5
  "type": "module",
6
6
  "main": "src/main.ts",
@@ -96,36 +96,52 @@ export async function showQuestionButtons({
96
96
  const q = request.questions[i]
97
97
  if (!q) continue
98
98
 
99
+ const maxButtons = 100
100
+ const maxOptions = Math.max(maxButtons - 1, 0)
101
+ const trimmedOptions = q.options.slice(0, maxOptions)
102
+ const includeOther = trimmedOptions.length < maxButtons
103
+ const optionLines = trimmedOptions.map((opt, optIdx) => {
104
+ const description = opt.description ? ` - ${opt.description}` : ""
105
+ return `${optIdx + 1}. ${opt.label}${description}`
106
+ })
107
+
99
108
  // Build inline keyboard - max 8 buttons per row, max 100 buttons total
100
109
  const options = [
101
- ...q.options.slice(0, 7).map((opt, optIdx) => ({
110
+ ...trimmedOptions.map((opt, optIdx) => ({
102
111
  label: opt.label.slice(0, 64), // Telegram button text limit
103
112
  callbackData: `q:${threadKey}:${i}:${optIdx}`,
104
113
  })),
105
- {
114
+ ]
115
+
116
+ if (includeOther) {
117
+ options.push({
106
118
  label: "Other",
107
119
  callbackData: `q:${threadKey}:${i}:other`,
108
- },
109
- ]
120
+ })
121
+ }
110
122
 
111
- const keyboard = TelegramClient.buildInlineKeyboard(options, { columns: 2 })
123
+ if (optionLines.length > 0 && includeOther) {
124
+ optionLines.push(`${optionLines.length + 1}. Other`)
125
+ }
112
126
 
113
- const messageResult = await telegram.sendMessage(
114
- `*${q.header}*\n${q.question}`,
115
- { replyMarkup: keyboard }
116
- )
127
+ const keyboard = TelegramClient.buildInlineKeyboard(options, { columns: 1 })
117
128
 
118
- if (messageResult.status === "error") {
119
- log("error", "Failed to send question message", {
120
- threadKey,
121
- error: messageResult.error.message,
122
- })
123
- continue
124
- }
129
+ const messageResult = await telegram.sendMessage(
130
+ `*${q.header}*\n${q.question}${optionLines.length > 0 ? `\n\n${optionLines.join("\n")}` : ""}`,
131
+ { replyMarkup: keyboard }
132
+ )
125
133
 
126
- if (messageResult.value) {
127
- context.messageIds.push(messageResult.value.message_id)
128
- }
134
+ if (messageResult.status === "error") {
135
+ log("error", "Failed to send question message", {
136
+ threadKey,
137
+ error: messageResult.error.message,
138
+ })
139
+ continue
140
+ }
141
+
142
+ if (messageResult.value) {
143
+ context.messageIds.push(messageResult.value.message_id)
144
+ }
129
145
 
130
146
  }
131
147