@capybara-hq/plugin-telegram 0.1.0-rc.5 → 0.1.0-rc.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "name": "telegram",
4
- "version": "0.1.0-rc.5",
4
+ "version": "0.1.0-rc.6",
5
5
  "publisher": "Capybara",
6
6
  "description": {
7
7
  "en": "Telegram (channel@1 bot over the Bot API: long polling or webhook, inline keyboard cards)",
@@ -17,7 +17,7 @@
17
17
  "entry": "./dist/index.mjs",
18
18
  "manifest": {
19
19
  "name": "telegram",
20
- "version": "0.1.0-rc.5",
20
+ "version": "0.1.0-rc.6",
21
21
  "sdk": "^0.1.0-rc.4",
22
22
  "provides": [
23
23
  "channel@1"
package/dist/index.mjs CHANGED
@@ -599,10 +599,12 @@ var urlButton = (text, url) => isHttp(url) ? [{ text, url }] : [];
599
599
  function cardText(card, locale) {
600
600
  const url = card.kind === "connect" || card.kind === "bind" ? card.url : card.webUrl;
601
601
  const lines = renderCardAsText(card, locale).split("\n");
602
- const last = lines[lines.length - 1];
603
- if (lines.length > 1 && last?.endsWith(url)) {
604
- lines.pop();
605
- const label = markdownToTelegramHtml(last.slice(0, last.length - url.length));
602
+ let at = lines.length - 1;
603
+ if (card.kind === "question" && card.state === "pending" && card.textReply !== void 0) at--;
604
+ const line = lines[at];
605
+ if (at > 0 && line?.endsWith(url)) {
606
+ lines.splice(at, 1);
607
+ const label = markdownToTelegramHtml(line.slice(0, line.length - url.length));
606
608
  return { body: markdownToTelegramHtml(lines.join("\n")), linkLine: `${label}${htmlLink(url)}` };
607
609
  }
608
610
  return { body: markdownToTelegramHtml(lines.join("\n")) };
@@ -649,7 +651,9 @@ async function keyboard(card, locale, tokens) {
649
651
  case "question": {
650
652
  const f = card.form.fields[0];
651
653
  const rows = [];
652
- if (card.state === "pending" && f && !f.multiSelect && questionRenderableInline(card.form) && "enum" in f.schema) {
654
+ if (card.state === "pending" && f && !f.multiSelect && // With textReply the Other path is a plain reply: a field with allowOther still gets its
655
+ // option buttons, never an Other button.
656
+ questionRenderableInline(card.form, { textReply: card.textReply !== void 0 }) && "enum" in f.schema) {
653
657
  for (const option of f.schema.enum) {
654
658
  rows.push(
655
659
  await callbackButton(tokens, option, {
@@ -1342,7 +1346,7 @@ function createTelegramChannel(o) {
1342
1346
  // src/index.ts
1343
1347
  var index_default = defineExtension({
1344
1348
  name: "telegram",
1345
- version: "0.1.0-rc.5",
1349
+ version: "0.1.0-rc.6",
1346
1350
  sdk: "^0.1.0-rc.4",
1347
1351
  provides: [CHANNEL_EXTENSION_POINT],
1348
1352
  permissions: { network: ["api.telegram.org"] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/plugin-telegram",
3
- "version": "0.1.0-rc.5",
3
+ "version": "0.1.0-rc.6",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Telegram (channel@1 bot over the Bot API: long polling or webhook, inline keyboard cards)",