@songsid/agend 2.1.4-beta.31 → 2.1.4-beta.32

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.
@@ -5109,7 +5109,7 @@ export class FleetManager {
5109
5109
  * longer parses) collapses the clicked message so the dead button stops
5110
5110
  * inviting clicks — the same courtesy the cancel button extends.
5111
5111
  */
5112
- consumeNonceCallback(prefix, actionRe, data, callbackAdapterId, receivingAdapter) {
5112
+ consumeNonceCallback(prefix, actionRe, data, callbackAdapterId, receivingAdapter, staleHandling) {
5113
5113
  if (!data.callbackData.startsWith(prefix))
5114
5114
  return null;
5115
5115
  const match = data.callbackData.match(actionRe);
@@ -5121,7 +5121,17 @@ export class FleetManager {
5121
5121
  pending = undefined;
5122
5122
  if (!match || !pending) {
5123
5123
  const adapter = receivingAdapter ?? this.adapter;
5124
- adapter?.editMessageRemoveButtons?.(data.chatId, data.messageId, t("buttons.stale"), data.threadId).catch(() => { });
5124
+ if (staleHandling?.keepText && adapter?.removeMessageButtons) {
5125
+ adapter.removeMessageButtons(data.chatId, data.messageId, data.threadId)
5126
+ .catch(() => { });
5127
+ }
5128
+ else {
5129
+ adapter?.editMessageRemoveButtons?.(data.chatId, data.messageId, t("buttons.stale"), data.threadId).catch(() => { });
5130
+ }
5131
+ if (staleHandling?.notice) {
5132
+ adapter?.sendText(data.chatId, staleHandling.notice, { threadId: data.threadId })
5133
+ .catch(() => { });
5134
+ }
5125
5135
  return "consumed";
5126
5136
  }
5127
5137
  // Bind the capability to the exact message/world that created it. Telegram
@@ -5294,7 +5304,12 @@ export class FleetManager {
5294
5304
  }
5295
5305
  }
5296
5306
  async handleTipDismiss(data, callbackAdapterId, receivingAdapter) {
5297
- const claimed = this.consumeNonceCallback(TIP_DISMISS_CALLBACK_PREFIX, /^tip-dismiss:([0-9a-f]+):(dismiss|confused)$/, data, callbackAdapterId, receivingAdapter);
5307
+ const claimed = this.consumeNonceCallback(TIP_DISMISS_CALLBACK_PREFIX, /^tip-dismiss:([0-9a-f]+):(dismiss|confused)$/, data, callbackAdapterId, receivingAdapter,
5308
+ // A restart orphans the expiry timer, so tip buttons can outlive their
5309
+ // nonce by days. Keep the tip text readable and always tell the clicker
5310
+ // what to do next (the keyboard edit itself can be refused: Telegram
5311
+ // rejects edits on messages older than 48h).
5312
+ { keepText: true, notice: t("tips.expired_use_tips") });
5298
5313
  if (claimed === null)
5299
5314
  return false;
5300
5315
  if (claimed === "consumed")
@@ -5363,7 +5378,7 @@ export class FleetManager {
5363
5378
  return true;
5364
5379
  }
5365
5380
  async handleTipUnlock(data, callbackAdapterId, receivingAdapter) {
5366
- const claimed = this.consumeNonceCallback(TIP_UNLOCK_CALLBACK_PREFIX, /^tip-unlock:([0-9a-f]+):(unlock)$/, data, callbackAdapterId, receivingAdapter);
5381
+ const claimed = this.consumeNonceCallback(TIP_UNLOCK_CALLBACK_PREFIX, /^tip-unlock:([0-9a-f]+):(unlock)$/, data, callbackAdapterId, receivingAdapter, { keepText: true, notice: t("tips.expired_use_tips") });
5367
5382
  if (claimed === null)
5368
5383
  return false;
5369
5384
  if (claimed === "consumed")