teleton 0.1.18 → 0.1.19

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/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
7
7
  <a href="https://nodejs.org/"><img src="https://img.shields.io/badge/node-%3E%3D20.0.0-brightgreen" alt="Node.js"></a>
8
8
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5.7-blue" alt="TypeScript"></a>
9
+ <a href="https://ai.resistance.dog"><img src="https://img.shields.io/badge/Website-ai.resistance.dog-ff6600" alt="Website"></a>
9
10
  </p>
10
11
 
11
12
  ---
@@ -9577,15 +9577,10 @@ var telegramGetFoldersExecutor = async (_params, context) => {
9577
9577
  try {
9578
9578
  const gramJsClient = context.bridge.getClient().getClient();
9579
9579
  const result = await gramJsClient.invoke(new Api31.messages.GetDialogFilters());
9580
- if (!Array.isArray(result)) {
9581
- return {
9582
- success: false,
9583
- error: "Unexpected result type from dialog filters"
9584
- };
9585
- }
9586
- const folders = result.filter((filter) => filter.className === "DialogFilter").map((filter) => ({
9580
+ const filterList = Array.isArray(result) ? result : result.filters ?? [];
9581
+ const folders = filterList.filter((filter) => filter.className === "DialogFilter").map((filter) => ({
9587
9582
  id: filter.id,
9588
- title: filter.title,
9583
+ title: filter.title?.text ?? filter.title,
9589
9584
  emoji: filter.emoticon || null,
9590
9585
  pinnedPeersCount: filter.pinnedPeers?.length || 0,
9591
9586
  includedPeersCount: filter.includePeers?.length || 0,
@@ -9670,12 +9665,13 @@ var telegramCreateFolderExecutor = async (params, context) => {
9670
9665
  includeBots = false
9671
9666
  } = params;
9672
9667
  const gramJsClient = context.bridge.getClient().getClient();
9673
- const existingFilters = await gramJsClient.invoke(new Api32.messages.GetDialogFilters());
9674
- const maxId = Array.isArray(existingFilters) ? Math.max(0, ...existingFilters.map((f) => f.id || 0)) : 0;
9675
- const newId = maxId + 1;
9668
+ const result = await gramJsClient.invoke(new Api32.messages.GetDialogFilters());
9669
+ const filters = Array.isArray(result) ? result : result.filters ?? [];
9670
+ const usedIds = filters.filter((f) => typeof f.id === "number").map((f) => f.id);
9671
+ const newId = usedIds.length > 0 ? Math.max(...usedIds) + 1 : 2;
9676
9672
  const filterData = {
9677
9673
  id: newId,
9678
- title,
9674
+ title: new Api32.TextWithEntities({ text: title, entities: [] }),
9679
9675
  pinnedPeers: [],
9680
9676
  includePeers: [],
9681
9677
  excludePeers: [],
@@ -9732,14 +9728,9 @@ var telegramAddChatToFolderExecutor = async (params, context) => {
9732
9728
  try {
9733
9729
  const { folderId, chatId } = params;
9734
9730
  const gramJsClient = context.bridge.getClient().getClient();
9735
- const filters = await gramJsClient.invoke(new Api33.messages.GetDialogFilters());
9736
- if (!Array.isArray(filters)) {
9737
- return {
9738
- success: false,
9739
- error: "Failed to get existing folders"
9740
- };
9741
- }
9742
- const folder = filters.find((f) => f.id === folderId);
9731
+ const filtersResult = await gramJsClient.invoke(new Api33.messages.GetDialogFilters());
9732
+ const filterList = Array.isArray(filtersResult) ? filtersResult : filtersResult.filters ?? [];
9733
+ const folder = filterList.find((f) => f.id === folderId);
9743
9734
  if (!folder || folder.className !== "DialogFilter") {
9744
9735
  return {
9745
9736
  success: false,
@@ -9763,7 +9754,7 @@ var telegramAddChatToFolderExecutor = async (params, context) => {
9763
9754
  success: true,
9764
9755
  data: {
9765
9756
  folderId,
9766
- folderTitle: folder.title,
9757
+ folderTitle: folder.title?.text ?? folder.title,
9767
9758
  chatId,
9768
9759
  totalChatsInFolder: updatedIncludePeers.length
9769
9760
  }
@@ -21987,7 +21978,13 @@ var dealVerifyPaymentExecutor = async (params, context) => {
21987
21978
  }
21988
21979
  const now = Math.floor(Date.now() / 1e3);
21989
21980
  if (now > deal.expires_at) {
21990
- context.db.prepare(`UPDATE deals SET status = 'expired' WHERE id = ?`).run(params.dealId);
21981
+ const expireResult = context.db.prepare(`UPDATE deals SET status = 'expired' WHERE id = ? AND status = 'accepted'`).run(params.dealId);
21982
+ if (expireResult.changes !== 1) {
21983
+ return {
21984
+ success: false,
21985
+ error: `Deal #${params.dealId} already transitioned by another process`
21986
+ };
21987
+ }
21991
21988
  return {
21992
21989
  success: false,
21993
21990
  error: `Deal #${params.dealId} has expired (2 minutes elapsed)`
@@ -22023,14 +22020,20 @@ var dealVerifyPaymentExecutor = async (params, context) => {
22023
22020
  error: `Payment verification failed: ${verification.error || "Transaction not found"}`
22024
22021
  };
22025
22022
  }
22026
- context.db.prepare(
22023
+ const verifyResult = context.db.prepare(
22027
22024
  `UPDATE deals SET
22028
22025
  status = 'verified',
22029
22026
  user_payment_tx_hash = ?,
22030
22027
  user_payment_wallet = ?,
22031
22028
  user_payment_verified_at = unixepoch()
22032
- WHERE id = ?`
22029
+ WHERE id = ? AND status = 'accepted'`
22033
22030
  ).run(verification.txHash, verification.playerWallet, params.dealId);
22031
+ if (verifyResult.changes !== 1) {
22032
+ return {
22033
+ success: false,
22034
+ error: `Deal #${params.dealId} already transitioned by another process (expected 'accepted')`
22035
+ };
22036
+ }
22034
22037
  console.log(
22035
22038
  `\u2705 [Deal] Payment verified for #${params.dealId} - TX: ${verification.txHash?.slice(0, 8)}...`
22036
22039
  );
@@ -22076,13 +22079,19 @@ var dealVerifyPaymentExecutor = async (params, context) => {
22076
22079
  error: `Gift not received yet. Expected: ${deal.user_gives_gift_slug} from user ${deal.user_telegram_id}. Please ensure user has sent the gift.`
22077
22080
  };
22078
22081
  }
22079
- context.db.prepare(
22082
+ const giftVerifyResult = context.db.prepare(
22080
22083
  `UPDATE deals SET
22081
22084
  status = 'verified',
22082
22085
  user_payment_gift_msgid = ?,
22083
22086
  user_payment_verified_at = unixepoch()
22084
- WHERE id = ?`
22087
+ WHERE id = ? AND status = 'accepted'`
22085
22088
  ).run(matchingGift.msgId, params.dealId);
22089
+ if (giftVerifyResult.changes !== 1) {
22090
+ return {
22091
+ success: false,
22092
+ error: `Deal #${params.dealId} already transitioned by another process (expected 'accepted')`
22093
+ };
22094
+ }
22086
22095
  console.log(`\u2705 [Deal] Gift verified for #${params.dealId} - msgId: ${matchingGift.msgId}`);
22087
22096
  await autoExecuteAfterVerification(params.dealId, context.db, context.bridge);
22088
22097
  return {
package/dist/cli/index.js CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  saveWallet,
18
18
  validateApiKeyFormat,
19
19
  walletExists
20
- } from "../chunk-Q4N5NJ2B.js";
20
+ } from "../chunk-ABHUNKXQ.js";
21
21
  import "../chunk-JDPS46IZ.js";
22
22
  import "../chunk-E2NXSWOS.js";
23
23
  import {
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  TonnetApp,
3
3
  main
4
- } from "./chunk-Q4N5NJ2B.js";
4
+ } from "./chunk-ABHUNKXQ.js";
5
5
  import "./chunk-JDPS46IZ.js";
6
6
  import "./chunk-E2NXSWOS.js";
7
7
  import "./chunk-EYWNOHMJ.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "teleton",
3
- "version": "0.1.18",
3
+ "version": "0.1.19",
4
4
  "description": "Personal AI Agent for Telegram",
5
5
  "author": "ZKProof (https://t.me/zkproof)",
6
6
  "license": "MIT",