Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export function toPlain(markdown) {
const points = text => Array.from(text).length

// Split a block that alone exceeds the limit: text at line boundaries (a line that
// is still too long is cut where it lands — Telegram answers it as plain text), a
// is still too long is cut where it lands; Telegram answers it as plain text), a
// code fence into several fenced blocks.
function forceCut(block, limit) {
if (block.kind !== 'code') {
Expand Down
38 changes: 19 additions & 19 deletions ds-bot/src/host/im/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ export function install(rt) {
requested: 'A connection request was sent to DS Bot; allow it in Settings → IM on the computer.',
unbound: 'This IM bot is not bound to a Bot yet; pick one in DS Bot Settings → IM.',
unboundGroup: 'This group is not bound yet; pick a group or a Bot for it in DS Bot Settings → IM.',
connected: `Connected — you can talk to ${values.target} now.`,
connected: `Connected: you can talk to ${values.target} now.`,
stopped: 'Stopped.',
idle: 'Nothing is running.',
stale: 'This card was already answered.',
noFile: 'This file cannot be sent here; send it on the computer.',
greeting: `Hello, I am ${values.name}.`,
question: `${values.bot} asks: `,
approval: `${values.bot} asks for approval: `,
secretAsk: `${values.bot} needs the key ${values.name} — fill it on the computer or the phone app.`,
viewShow: `${values.bot} shared a card — answer it on the computer or the phone app.`,
secretAsk: `${values.bot} needs the key ${values.name}: fill it on the computer or the phone app.`,
viewShow: `${values.bot} shared a card: answer it on the computer or the phone app.`,
answered: 'answered',
numbers: 'reply with the number',
numbersMulti: 'reply with the numbers, separated by spaces',
Expand Down Expand Up @@ -150,16 +150,16 @@ export function install(rt) {
requested: 'Se envió una solicitud de conexión a DS Bot; permítela en Ajustes → IM en el ordenador.',
unbound: 'Este bot de IM aún no está vinculado a un Bot; elige uno en Ajustes de DS Bot → IM.',
unboundGroup: 'Este grupo aún no está vinculado; elige un grupo o un Bot en Ajustes de DS Bot → IM.',
connected: `Conectado — ya puedes hablar con ${values.target}.`,
connected: `Conectado: ya puedes hablar con ${values.target}.`,
stopped: 'Detenido.',
idle: 'No hay nada en curso.',
stale: 'Esta tarjeta ya fue respondida.',
noFile: 'Este archivo no se puede enviar por aquí; envíalo desde el ordenador.',
greeting: `Hola, soy ${values.name}.`,
question: `${values.bot} pregunta: `,
approval: `${values.bot} pide aprobación: `,
secretAsk: `${values.bot} necesita la clave ${values.name} — rellénala en el ordenador o en la app móvil.`,
viewShow: `${values.bot} compartió una tarjeta — respóndela en el ordenador o en la app móvil.`,
secretAsk: `${values.bot} necesita la clave ${values.name}: rellénala en el ordenador o en la app móvil.`,
viewShow: `${values.bot} compartió una tarjeta: respóndela en el ordenador o en la app móvil.`,
answered: 'respondido',
numbers: 'responde con el número',
numbersMulti: 'responde con los números separados por espacios',
Expand All @@ -172,16 +172,16 @@ export function install(rt) {
requested: 'Une demande de connexion a été envoyée à DS Bot ; autorisez-la dans Paramètres → IM sur l’ordinateur.',
unbound: 'Ce bot IM n’est pas encore lié à un Bot ; choisissez-en un dans Paramètres DS Bot → IM.',
unboundGroup: 'Ce groupe n’est pas encore lié ; choisissez un groupe ou un Bot dans Paramètres DS Bot → IM.',
connected: `Connecté — vous pouvez maintenant parler à ${values.target}.`,
connected: `Connecté : vous pouvez maintenant parler à ${values.target}.`,
stopped: 'Arrêté.',
idle: 'Rien n’est en cours.',
stale: 'Cette carte a déjà reçu une réponse.',
noFile: 'Ce fichier ne peut pas être envoyé ici ; envoyez-le depuis l’ordinateur.',
greeting: `Bonjour, je suis ${values.name}.`,
question: `${values.bot} demande : `,
approval: `${values.bot} demande une approbation : `,
secretAsk: `${values.bot} a besoin de la clé ${values.name} — renseignez-la sur l’ordinateur ou l’application mobile.`,
viewShow: `${values.bot} a partagé une carte — répondez-y sur l’ordinateur ou l’application mobile.`,
secretAsk: `${values.bot} a besoin de la clé ${values.name} : renseignez-la sur l’ordinateur ou l’application mobile.`,
viewShow: `${values.bot} a partagé une carte : répondez-y sur l’ordinateur ou l’application mobile.`,
answered: 'répondu',
numbers: 'répondez avec le numéro',
numbersMulti: 'répondez avec les numéros séparés par des espaces',
Expand All @@ -194,16 +194,16 @@ export function install(rt) {
requested: 'Eine Verbindungsanfrage wurde an DS Bot gesendet; erlaube sie am Computer unter Einstellungen → IM.',
unbound: 'Dieser IM-Bot ist noch keinem Bot zugewiesen; wähle einen in den DS Bot-Einstellungen → IM.',
unboundGroup: 'Diese Gruppe ist noch nicht zugewiesen; wähle eine Gruppe oder einen Bot in den DS Bot-Einstellungen → IM.',
connected: `Verbunden — du kannst jetzt mit ${values.target} sprechen.`,
connected: `Verbunden: du kannst jetzt mit ${values.target} sprechen.`,
stopped: 'Gestoppt.',
idle: 'Aktuell läuft nichts.',
stale: 'Diese Karte wurde bereits beantwortet.',
noFile: 'Diese Datei kann hier nicht gesendet werden; sende sie am Computer.',
greeting: `Hallo, ich bin ${values.name}.`,
question: `${values.bot} fragt: `,
approval: `${values.bot} bittet um Freigabe: `,
secretAsk: `${values.bot} benötigt den Schlüssel ${values.name} — gib ihn am Computer oder in der Smartphone-App ein.`,
viewShow: `${values.bot} hat eine Karte geteilt — beantworte sie am Computer oder in der Smartphone-App.`,
secretAsk: `${values.bot} benötigt den Schlüssel ${values.name}: gib ihn am Computer oder in der Smartphone-App ein.`,
viewShow: `${values.bot} hat eine Karte geteilt: beantworte sie am Computer oder in der Smartphone-App.`,
answered: 'beantwortet',
numbers: 'mit der Nummer antworten',
numbersMulti: 'mit durch Leerzeichen getrennten Nummern antworten',
Expand Down Expand Up @@ -598,8 +598,8 @@ export function install(rt) {
if (NUMBERS.test(body)) {
const picked = body.trim().split(/\s+/).map(Number)
const held = newestOpenCard(conn, msg.chat.key)
// Anything that does not clearly answer the newest open card — a stale
// source, an out-of-range pick, several picks on a single choice — is a
// Anything that does not clearly answer the newest open card (a stale
// source, an out-of-range pick, several picks on a single choice) is a
// normal message for the Bot, never swallowed and never 'stale'.
if (held !== undefined && held.cardKey.startsWith('q:')) {
const found = questionById(held.cardKey.slice(2))
Expand Down Expand Up @@ -680,7 +680,7 @@ export function install(rt) {
// ------------------------------------------------------------------ cards
const cardText = {
question: (bot, question) => {
const options = (question.options ?? []).map((option, index) => `${index + 1}. ${option.label}${option.description ? ` — ${option.description}` : ''}`).join('\n')
const options = (question.options ?? []).map((option, index) => `${index + 1}. ${option.label}${option.description ? ` - ${option.description}` : ''}`).join('\n')
const hint = question.multiSelect === true ? text('numbersMulti') : text('numbers')
return `${text('question', { bot })}${question.question}${question.detail ? `\n${question.detail}` : ''}\n${options}\n(${hint})`
},
Expand All @@ -689,7 +689,7 @@ export function install(rt) {
const detail = choice.texts.join('\n')
return `${text('question', { bot })}${title ?? ''}${detail !== '' ? `\n${detail}` : ''}\n${options}\n(${text('numbers')})`
},
approval: (bot, entry) => `${text('approval', { bot })}${entry.tool}${entry.reason ? ` — ${entry.reason}` : ''}${entry.detail?.text ? `\n${entry.detail.text}` : ''}${entry.detail?.code ? `\n${entry.detail.code}` : ''}`,
approval: (bot, entry) => `${text('approval', { bot })}${entry.tool}${entry.reason ? `: ${entry.reason}` : ''}${entry.detail?.text ? `\n${entry.detail.text}` : ''}${entry.detail?.code ? `\n${entry.detail.code}` : ''}`,
}
const cardButtons = {
question: (question) => (question.multiSelect === true ? undefined : (question.options ?? []).map((option, index) => ({ data: `q:${question.id}:${index}`, label: option.label }))),
Expand Down Expand Up @@ -727,7 +727,7 @@ export function install(rt) {
const buttons = imPlatform(conn.platform)?.buttons === true ? cardButtons.question(question) : undefined
await sendCard(conn, cardKey, listeners(conn, { botId }), cardText.question(bot.name, question), buttons)
}
// Secret requests: text only — the key is typed on the computer or phone.
// Secret requests: text only: the key is typed on the computer or phone.
for (const [botId, list] of Object.entries(state.secretRequests ?? {})) {
const bot = rt.botOf(botId)
if (bot === undefined) continue
Expand Down Expand Up @@ -767,7 +767,7 @@ export function install(rt) {
const chat = conn.chats?.[entry.chatKey]
if (chat === undefined) continue
entry.edited = true
const body = entry.text !== undefined ? `${entry.text}\n— ${entry.answer}` : `(${text('answered')})`
const body = entry.text !== undefined ? `${entry.text}\n- ${entry.answer}` : `(${text('answered')})`
runner.handle.edit({ key: entry.chatKey, kind: chat.kind, title: chat.title }, entry.messageId, { text: body }).catch(() => {})
scheduleWrite(conn.id)
}
Expand Down Expand Up @@ -1112,7 +1112,7 @@ export function install(rt) {
const login = await adapter.loginWait(String(body.loginId ?? ''), env)
if (login.status !== 'done') return { status: login.status }
// Confirmed: create the connection with the platform credentials the
// login returned, paired with the scanning owner — no review needed.
// login returned, paired with the scanning owner; no review needed.
const conn = {
id: `im_${randomBytes(4).toString('hex')}`,
platform: platform.id,
Expand Down
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/platforms/dingtalk.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// ticketed WebSocket; every frame is ACKed by echoing its messageId with
// code 200, system pings get a pong, and the robot callback carries the
// sessionWebhook for passive replies. Outside that window the OpenAPI
// batchSend/groupMessages path answers instead. No buttons — the core
// batchSend/groupMessages path answers instead. No buttons: the core
// numbers choices. Wire details ported from dingtalk-stream (MIT, see
// NOTICE).
import { chunkMarkdown } from '../format.js'
Expand Down
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/platforms/feishu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Feishu / Lark: the long connection speaks protobuf pbbp2 frames — control
// Feishu / Lark: the long connection speaks protobuf pbbp2 frames: control
// pings answered with pong, data frames ACKed by sending the frame back with a
// {"code":200} payload and a biz_rt header; split payloads reassemble by
// sum/seq. p2p messages are direct; a group message counts when the bot's
Expand Down
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/platforms/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import wecom from './wecom.js'
import weixin from './weixin.js'

// Every platform with an adapter. The rest of IM_PLATFORMS still show in settings as
// coming soon — a connection can only be added for a platform listed here.
// coming soon; a connection can only be added for a platform listed here.
export const adapters = { telegram, discord, slack, qq, dingtalk, wecom, feishu, weixin }
4 changes: 2 additions & 2 deletions ds-bot/src/host/im/platforms/qq.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// gateway (hello, heartbeat, identify, resume, reconnect, invalid session) for
// C2C and group @ messages. Sends are passive replies carrying the inbound
// msg_id with an incrementing msg_seq; outside the reply window the platform
// refuses and the reason is permanent. No buttons — the core numbers choices.
// refuses and the reason is permanent. No buttons: the core numbers choices.
// Wire details ported from @tencent-connect/qqbot-nodejs (MIT, see NOTICE).
import { chunkMarkdown } from '../format.js'
import { retryDelay, retryWait } from './retry.js'
Expand Down Expand Up @@ -54,7 +54,7 @@ export default {
let sequence
let sessionId
// Passive replies reuse the inbound msg_id with a msg_seq that climbs
// per id — outside the window the platform refuses (permanent).
// per id; outside the window the platform refuses (permanent).
const msgSeq = new Map()
const lastMsgId = new Map()

Expand Down
4 changes: 2 additions & 2 deletions ds-bot/src/host/im/platforms/telegram.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Telegram Bot API adapter: getUpdates long polling in, sendMessage out. Parts of the
// protocol mapping follow dsh-im (MIT, © 2026 xmanrui — see NOTICE).
// protocol mapping follow dsh-im (MIT, © 2026 xmanrui, see NOTICE).
import { chunkTelegram } from '../format.js'
import { retryDelay, retryWait } from './retry.js'

Expand Down Expand Up @@ -33,7 +33,7 @@ export default {
const base = `${apiBase(env)}/bot${token}`
const fileBase = `${apiBase(env)}/file/bot${token}`
let stopped = false
// Every call in flight keeps its own controller, so stop() ends them all —
// Every call in flight keeps its own controller, so stop() ends them all:
// a long poll must not outlive the adapter by ~65 s and collide with the
// restarted one (Telegram answers 409).
const inFlight = new Set()
Expand Down
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/platforms/wecom.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// WeCom intelligent robot: one long-lived WebSocket, a { cmd, headers: {
// req_id }, body } protocol — aibot_subscribe authenticates, ping heartbeats,
// req_id }, body } protocol: aibot_subscribe authenticates, ping heartbeats,
// aibot_msg_callback carries inbound messages answered through
// aibot_respond_msg with the callback's req_id, later messages use
// aibot_send_msg. Template-card buttons come back as aibot_event_callback.
Expand Down
2 changes: 1 addition & 1 deletion ds-bot/src/host/im/platforms/weixin.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// WeChat iLink: a QR login creates the connection — get_bot_qrcode, then a
// WeChat iLink: a QR login creates the connection: get_bot_qrcode, then a
// get_qrcode_status long poll until the owner confirms on their phone; the
// reply carries bot_token, ilink_bot_id, ilink_user_id and the base URL.
// From then a getupdates long poll delivers messages (the get_updates_buf
Expand Down
Loading