@mtcute/core 0.15.2 → 0.16.0
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/cjs/highlevel/base.d.ts +3 -3
- package/cjs/highlevel/base.js.map +1 -1
- package/cjs/highlevel/methods/files/download-iterable.js +1 -1
- package/cjs/highlevel/methods/files/download-iterable.js.map +1 -1
- package/cjs/highlevel/methods/users/resolve-peer-many.js +1 -1
- package/cjs/highlevel/methods/users/resolve-peer-many.js.map +1 -1
- package/cjs/highlevel/types/messages/dialog.d.ts +4 -2
- package/cjs/highlevel/types/messages/dialog.js +4 -2
- package/cjs/highlevel/types/messages/dialog.js.map +1 -1
- package/cjs/highlevel/types/messages/message-action.d.ts +15 -1
- package/cjs/highlevel/types/messages/message-action.js +10 -0
- package/cjs/highlevel/types/messages/message-action.js.map +1 -1
- package/cjs/highlevel/types/peers/full-chat.d.ts +2 -0
- package/cjs/highlevel/types/peers/full-chat.js +4 -0
- package/cjs/highlevel/types/peers/full-chat.js.map +1 -1
- package/cjs/highlevel/updates/manager.js +3 -3
- package/cjs/highlevel/updates/manager.js.map +1 -1
- package/cjs/highlevel/worker/invoker.js +2 -1
- package/cjs/highlevel/worker/invoker.js.map +1 -1
- package/cjs/highlevel/worker/port.js +4 -3
- package/cjs/highlevel/worker/port.js.map +1 -1
- package/cjs/highlevel/worker/protocol.d.ts +10 -5
- package/cjs/highlevel/worker/protocol.js +66 -0
- package/cjs/highlevel/worker/protocol.js.map +1 -1
- package/cjs/highlevel/worker/worker.js +6 -5
- package/cjs/highlevel/worker/worker.js.map +1 -1
- package/cjs/network/client.d.ts +0 -16
- package/cjs/network/client.js +0 -2
- package/cjs/network/client.js.map +1 -1
- package/cjs/network/index.d.ts +2 -1
- package/cjs/network/index.js +1 -0
- package/cjs/network/index.js.map +1 -1
- package/cjs/network/middlewares/bundle.d.ts +3 -0
- package/cjs/network/middlewares/bundle.js +20 -0
- package/cjs/network/middlewares/bundle.js.map +1 -0
- package/cjs/network/middlewares/default.d.ts +8 -0
- package/cjs/network/middlewares/default.js +10 -0
- package/cjs/network/middlewares/default.js.map +1 -0
- package/cjs/network/middlewares/flood-waiter.d.ts +37 -0
- package/cjs/network/middlewares/flood-waiter.js +70 -0
- package/cjs/network/middlewares/flood-waiter.js.map +1 -0
- package/cjs/network/middlewares/index.d.ts +2 -0
- package/cjs/network/middlewares/index.js +29 -0
- package/cjs/network/middlewares/index.js.map +1 -0
- package/cjs/network/middlewares/internal-errors.d.ts +17 -0
- package/cjs/network/middlewares/internal-errors.js +41 -0
- package/cjs/network/middlewares/internal-errors.js.map +1 -0
- package/cjs/network/middlewares/on-error.d.ts +30 -0
- package/cjs/network/middlewares/on-error.js +44 -0
- package/cjs/network/middlewares/on-error.js.map +1 -0
- package/cjs/network/middlewares/on-method.d.ts +39 -0
- package/cjs/network/middlewares/on-method.js +45 -0
- package/cjs/network/middlewares/on-method.js.map +1 -0
- package/cjs/network/mtproto-session.js +1 -1
- package/cjs/network/mtproto-session.js.map +1 -1
- package/cjs/network/multi-session-connection.js +1 -1
- package/cjs/network/multi-session-connection.js.map +1 -1
- package/cjs/network/network-manager.d.ts +23 -6
- package/cjs/network/network-manager.js +55 -102
- package/cjs/network/network-manager.js.map +1 -1
- package/cjs/network/persistent-connection.js +5 -5
- package/cjs/network/persistent-connection.js.map +1 -1
- package/cjs/network/session-connection.js +6 -6
- package/cjs/network/session-connection.js.map +1 -1
- package/cjs/storage/driver.js +1 -1
- package/cjs/storage/driver.js.map +1 -1
- package/cjs/storage/storage.js +1 -1
- package/cjs/storage/storage.js.map +1 -1
- package/cjs/utils/abort-signal.d.ts +1 -0
- package/cjs/utils/abort-signal.js +13 -0
- package/cjs/utils/abort-signal.js.map +1 -0
- package/cjs/utils/composer.d.ts +3 -0
- package/cjs/utils/composer.js +22 -0
- package/cjs/utils/composer.js.map +1 -0
- package/cjs/utils/error-reporting.js +1 -1
- package/cjs/utils/error-reporting.js.map +1 -1
- package/cjs/utils/index.d.ts +1 -0
- package/cjs/utils/index.js +1 -0
- package/cjs/utils/index.js.map +1 -1
- package/cjs/utils/logger.js +15 -3
- package/cjs/utils/logger.js.map +1 -1
- package/esm/highlevel/base.d.ts +3 -3
- package/esm/highlevel/base.js.map +1 -1
- package/esm/highlevel/methods/files/download-iterable.js +1 -1
- package/esm/highlevel/methods/files/download-iterable.js.map +1 -1
- package/esm/highlevel/methods/users/resolve-peer-many.js +1 -1
- package/esm/highlevel/methods/users/resolve-peer-many.js.map +1 -1
- package/esm/highlevel/types/messages/dialog.d.ts +4 -2
- package/esm/highlevel/types/messages/dialog.js +4 -2
- package/esm/highlevel/types/messages/dialog.js.map +1 -1
- package/esm/highlevel/types/messages/message-action.d.ts +15 -1
- package/esm/highlevel/types/messages/message-action.js +10 -0
- package/esm/highlevel/types/messages/message-action.js.map +1 -1
- package/esm/highlevel/types/peers/full-chat.d.ts +2 -0
- package/esm/highlevel/types/peers/full-chat.js +4 -0
- package/esm/highlevel/types/peers/full-chat.js.map +1 -1
- package/esm/highlevel/updates/manager.js +3 -3
- package/esm/highlevel/updates/manager.js.map +1 -1
- package/esm/highlevel/worker/invoker.js +2 -1
- package/esm/highlevel/worker/invoker.js.map +1 -1
- package/esm/highlevel/worker/port.js +4 -3
- package/esm/highlevel/worker/port.js.map +1 -1
- package/esm/highlevel/worker/protocol.d.ts +10 -5
- package/esm/highlevel/worker/protocol.js +60 -1
- package/esm/highlevel/worker/protocol.js.map +1 -1
- package/esm/highlevel/worker/worker.js +6 -5
- package/esm/highlevel/worker/worker.js.map +1 -1
- package/esm/network/client.d.ts +0 -16
- package/esm/network/client.js +0 -2
- package/esm/network/client.js.map +1 -1
- package/esm/network/index.d.ts +2 -1
- package/esm/network/index.js +1 -0
- package/esm/network/index.js.map +1 -1
- package/esm/network/middlewares/bundle.d.ts +3 -0
- package/esm/network/middlewares/bundle.js +4 -0
- package/esm/network/middlewares/bundle.js.map +1 -0
- package/esm/network/middlewares/default.d.ts +8 -0
- package/esm/network/middlewares/default.js +6 -0
- package/esm/network/middlewares/default.js.map +1 -0
- package/esm/network/middlewares/flood-waiter.d.ts +37 -0
- package/esm/network/middlewares/flood-waiter.js +66 -0
- package/esm/network/middlewares/flood-waiter.js.map +1 -0
- package/esm/network/middlewares/index.d.ts +2 -0
- package/esm/network/middlewares/index.js +3 -0
- package/esm/network/middlewares/index.js.map +1 -0
- package/esm/network/middlewares/internal-errors.d.ts +17 -0
- package/esm/network/middlewares/internal-errors.js +37 -0
- package/esm/network/middlewares/internal-errors.js.map +1 -0
- package/esm/network/middlewares/on-error.d.ts +30 -0
- package/esm/network/middlewares/on-error.js +40 -0
- package/esm/network/middlewares/on-error.js.map +1 -0
- package/esm/network/middlewares/on-method.d.ts +39 -0
- package/esm/network/middlewares/on-method.js +41 -0
- package/esm/network/middlewares/on-method.js.map +1 -0
- package/esm/network/mtproto-session.js +1 -1
- package/esm/network/mtproto-session.js.map +1 -1
- package/esm/network/multi-session-connection.js +1 -1
- package/esm/network/multi-session-connection.js.map +1 -1
- package/esm/network/network-manager.d.ts +23 -6
- package/esm/network/network-manager.js +57 -104
- package/esm/network/network-manager.js.map +1 -1
- package/esm/network/persistent-connection.js +5 -5
- package/esm/network/persistent-connection.js.map +1 -1
- package/esm/network/session-connection.js +6 -6
- package/esm/network/session-connection.js.map +1 -1
- package/esm/storage/driver.js +1 -1
- package/esm/storage/driver.js.map +1 -1
- package/esm/storage/storage.js +1 -1
- package/esm/storage/storage.js.map +1 -1
- package/esm/utils/abort-signal.d.ts +1 -0
- package/esm/utils/abort-signal.js +9 -0
- package/esm/utils/abort-signal.js.map +1 -0
- package/esm/utils/composer.d.ts +3 -0
- package/esm/utils/composer.js +18 -0
- package/esm/utils/composer.js.map +1 -0
- package/esm/utils/error-reporting.js +1 -1
- package/esm/utils/error-reporting.js.map +1 -1
- package/esm/utils/index.d.ts +1 -0
- package/esm/utils/index.js +1 -0
- package/esm/utils/index.js.map +1 -1
- package/esm/utils/logger.js +15 -3
- package/esm/utils/logger.js.map +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/dialog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAStC;;;;;GAKG;AACH,MAAM,OAAO,MAAM;IAEF;IACA;IACA;IAHb,YACa,GAAiB,EACjB,MAAkB,EAClB,SAAsC;QAFtC,QAAG,GAAH,GAAG,CAAc;QACjB,WAAM,GAAN,MAAM,CAAY;QAClB,cAAS,GAAT,SAAS,CAA6B;IAChD,CAAC;IAEJ;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAAC,OAA8D,EAAE,KAAc;QAChG,eAAe,CAAC,cAAc,EAAE,OAAO,EAAE,6BAA6B,CAAC,CAAA;QAEvE,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAEtC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA0B,CAAA;QAClD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YAC7B,IAAI,CAAC,GAAG,CAAC,MAAM;gBAAE,OAAM;YAEvB,QAAQ,CAAC,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAA;QAClD,C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IAED;;OAEG;IACH,IAAI,oBAAoB;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,cAAc,EAAE,CAAC;YACvC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC3C,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,CAAA;IACrC,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAA;AAC/D,eAAe,CAAC,MAAM,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getMarkedPeerId } from '../../../utils/peer-utils.js'\nimport { assertTypeIsNot, hasValueAtKey } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Chat } from '../peers/chat.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { DraftMessage } from './draft-message.js'\nimport { Message } from './message.js'\n\n/**\n * Type used as an input for a folder in client methods\n *\n * You can pass folder object, id or title\n */\nexport type InputDialogFolder = string | number | tl.RawDialogFilter\n\n/**\n * A dialog.\n *\n * Think of it as something that is listed\n * in Telegram's main window.\n */\nexport class Dialog {\n constructor(\n readonly raw: tl.RawDialog,\n readonly _peers: PeersIndex,\n readonly _messages: Map<number, tl.TypeMessage>,\n ) {}\n\n /**\n * Parse a list of dialogs from a TL object\n *\n * @param client Client instance\n * @param dialogs TL object\n * @param limit Maximum number of dialogs to parse\n */\n static parseTlDialogs(dialogs: tl.messages.TypeDialogs | tl.messages.TypePeerDialogs, limit?: number): Dialog[] {\n assertTypeIsNot('parseDialogs', dialogs, 'messages.dialogsNotModified')\n\n const peers = PeersIndex.from(dialogs)\n\n const messages = new Map<number, tl.TypeMessage>()\n dialogs.messages.forEach((msg) => {\n if (!msg.peerId) return\n\n messages.set(getMarkedPeerId(msg.peerId), msg)\n })\n\n const arr = dialogs.dialogs.filter(hasValueAtKey('_', 'dialog')).map((it) => new Dialog(it, peers, messages))\n\n if (limit) {\n return arr.slice(0, limit)\n }\n\n return arr\n }\n\n /**\n * Find pinned dialogs from a list of dialogs\n *\n * @param dialogs Dialogs list\n * @param folder If passed, status of pin will be checked against this folder, and not globally\n */\n static findPinned(dialogs: Dialog[], folder?: tl.RawDialogFilter): Dialog[] {\n if (folder) {\n const index: Record<number, true> = {}\n folder.pinnedPeers.forEach((peer) => {\n index[getMarkedPeerId(peer)] = true\n })\n\n return dialogs.filter((i) => index[i.chat.id])\n }\n\n return dialogs.filter((i) => i.isPinned)\n }\n\n /**\n * Create a filter predicate for the given Folder.\n * Returned predicate can be used in `Array.filter()`\n *\n * @param folder Folder to filter for\n * @param excludePinned Whether to exclude pinned folders\n */\n static filterFolder(folder: tl.TypeDialogFilter, excludePinned = true): (val: Dialog) => boolean {\n if (folder._ === 'dialogFilterDefault') {\n return () => true\n }\n\n const pinned: Record<number, true> = {}\n const include: Record<number, true> = {}\n const exclude: Record<number, true> = {}\n\n // populate indices\n if (excludePinned) {\n folder.pinnedPeers.forEach((peer) => {\n pinned[getMarkedPeerId(peer)] = true\n })\n }\n folder.includePeers.forEach((peer) => {\n include[getMarkedPeerId(peer)] = true\n })\n\n if (folder._ === 'dialogFilterChatlist') {\n return (dialog) => {\n const chatId = dialog.chat.id\n\n if (excludePinned && pinned[chatId]) return false\n\n return include[chatId] || pinned[chatId]\n }\n }\n\n folder.excludePeers.forEach((peer) => {\n exclude[getMarkedPeerId(peer)] = true\n })\n\n return (dialog) => {\n const chat = dialog.chat\n const chatId = dialog.chat.id\n const chatType = dialog.chat.chatType\n\n // manual exclusion/inclusion and pins\n if (include[chatId]) return true\n\n if (exclude[chatId] || (excludePinned && pinned[chatId])) {\n return false\n }\n\n // exclusions based on status\n if (folder.excludeRead && !dialog.isUnread) return false\n if (folder.excludeMuted && dialog.isMuted) return false\n // even though this was handled in getDialogs, this method\n // could be used outside of it, so check again\n if (folder.excludeArchived && dialog.isArchived) return false\n\n // inclusions based on chat type\n if (folder.contacts && chatType === 'private' && chat.isContact) {\n return true\n }\n if (folder.nonContacts && chatType === 'private' && !chat.isContact) {\n return true\n }\n if (folder.groups && (chatType === 'group' || chatType === 'supergroup')) {\n return true\n }\n if (folder.broadcasts && chatType === 'channel') return true\n if (folder.bots && chatType === 'bot') return true\n\n return false\n }\n }\n\n /**\n * Whether this dialog is pinned\n */\n get isPinned(): boolean {\n return this.raw.pinned!\n }\n\n /**\n * Whether this chat was manually marked as unread\n */\n get isManuallyUnread(): boolean {\n return this.raw.unreadMark!\n }\n\n /**\n * Whether this chat should be considered unread\n * (i.e. has more than 1 unread message, or has\n * a \"manually unread\" mark)\n */\n get isUnread(): boolean {\n return this.raw.unreadMark || this.raw.unreadCount > 1\n }\n\n /**\n * Whether this dialog is muted\n */\n get isMuted(): boolean {\n return this.raw.notifySettings.silent!\n }\n\n /**\n * Whether this dialog is archived\n */\n get isArchived(): boolean {\n return this.raw.folderId === 1\n }\n\n /**\n * Chat that this dialog represents\n */\n get chat(): Chat {\n return Chat._parseFromPeer(this.raw.peer, this._peers)\n }\n\n /**\n * The latest message sent in this chat (if any)\n */\n get lastMessage(): Message | null {\n const cid = this.chat.id\n\n if (this._messages.has(cid)) {\n return new Message(this._messages.get(cid)!, this._peers)\n }\n\n return null\n }\n\n /**\n * ID of the last read outgoing message in this dialog\n */\n get lastReadOutgoing(): number {\n return this.raw.readOutboxMaxId\n }\n\n /**\n * ID of the last read ingoing message in this dialog\n */\n get lastReadIngoing(): number {\n return this.raw.readInboxMaxId\n }\n\n /**\n * ID of the last read message in this dialog\n */\n get lastRead(): number {\n return Math.max(this.raw.readOutboxMaxId, this.raw.readInboxMaxId)\n }\n\n /**\n * Number of unread messages\n */\n get unreadCount(): number {\n return this.raw.unreadCount\n }\n\n /**\n * Number of unread mentions\n */\n get unreadMentionsCount(): number {\n return this.raw.unreadMentionsCount\n }\n\n /**\n * Number of unread reactions\n */\n get unreadReactionsCount(): number {\n return this.raw.unreadReactionsCount\n }\n\n /**\n * Draft message in this dialog\n */\n get draftMessage(): DraftMessage | null {\n if (this.raw.draft?._ === 'draftMessage') {\n return new DraftMessage(this.raw.draft)\n }\n\n return null\n }\n\n /**\n * TTL period of all messages in this dialog\n */\n get ttlPeriod(): number | null {\n return this.raw.ttlPeriod ?? null\n }\n}\n\nmemoizeGetters(Dialog, ['chat', 'lastMessage', 'draftMessage'])\nmakeInspectable(Dialog)\n"]}
|
|
1
|
+
{"version":3,"file":"dialog.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/dialog.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAA;AAClF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAStC;;;;;GAKG;AACH,MAAM,OAAO,MAAM;IAEF;IACA;IACA;IAHb,YACa,GAAiB,EACjB,MAAkB,EAClB,SAAsC;QAFtC,QAAG,GAAH,GAAG,CAAc;QACjB,WAAM,GAAN,MAAM,CAAY;QAClB,cAAS,GAAT,SAAS,CAA6B;IAChD,CAAC;IAEJ;;;;;;OAMG;IACH,MAAM,CAAC,cAAc,CAA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C,CAAC;IAED;;OAEG;IACH,IAAI,eAAe;QACf,OAAO,IAAI,CAAC,GAAG,CAAC,cAAc,CAAA;IAClC,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IACtE,CAAC;IAED;;OAEG;IACH,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,WAAW,CAAA;IAC/B,CAAC;IAED;;OAEG;IACH,IAAI,mBAAmB;QACnB,OAAO,IAAI,CAAC,GAAG,CAAC,mBAAmB,CAAA;IACvC,CAAC;IAED;;OAEG;IACH,IAAI,oBAAoB;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAA;IACxC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,KAAK,cAAc,EAAE,CAAC;YACvC,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAA;QAC3C,CAAC;QAED,OAAO,IAAI,CAAA;IACf,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,IAAI,CAAA;IACrC,CAAC;CACJ;AAED,cAAc,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC,CAAA;AAC/D,eAAe,CAAC,MAAM,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getMarkedPeerId } from '../../../utils/peer-utils.js'\nimport { assertTypeIsNot, hasValueAtKey } from '../../../utils/type-assertions.js'\nimport { makeInspectable } from '../../utils/index.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Chat } from '../peers/chat.js'\nimport { PeersIndex } from '../peers/peers-index.js'\nimport { DraftMessage } from './draft-message.js'\nimport { Message } from './message.js'\n\n/**\n * Type used as an input for a folder in client methods\n *\n * You can pass folder object, id or title\n */\nexport type InputDialogFolder = string | number | tl.RawDialogFilter\n\n/**\n * A dialog.\n *\n * Think of it as something that is listed\n * in Telegram's main window.\n */\nexport class Dialog {\n constructor(\n readonly raw: tl.RawDialog,\n readonly _peers: PeersIndex,\n readonly _messages: Map<number, tl.TypeMessage>,\n ) {}\n\n /**\n * Parse a list of dialogs from a TL object\n *\n * @param client Client instance\n * @param dialogs TL object\n * @param limit Maximum number of dialogs to parse\n */\n static parseTlDialogs(dialogs: tl.messages.TypeDialogs | tl.messages.TypePeerDialogs, limit?: number): Dialog[] {\n assertTypeIsNot('parseDialogs', dialogs, 'messages.dialogsNotModified')\n\n const peers = PeersIndex.from(dialogs)\n\n const messages = new Map<number, tl.TypeMessage>()\n dialogs.messages.forEach((msg) => {\n if (!msg.peerId) return\n\n messages.set(getMarkedPeerId(msg.peerId), msg)\n })\n\n const arr = dialogs.dialogs.filter(hasValueAtKey('_', 'dialog')).map((it) => new Dialog(it, peers, messages))\n\n if (limit) {\n return arr.slice(0, limit)\n }\n\n return arr\n }\n\n /**\n * Find pinned dialogs from a list of dialogs\n *\n * @param dialogs Dialogs list\n * @param folder If passed, status of pin will be checked against this folder, and not globally\n */\n static findPinned(dialogs: Dialog[], folder?: tl.RawDialogFilter): Dialog[] {\n if (folder) {\n const index: Record<number, true> = {}\n folder.pinnedPeers.forEach((peer) => {\n index[getMarkedPeerId(peer)] = true\n })\n\n return dialogs.filter((i) => index[i.chat.id])\n }\n\n return dialogs.filter((i) => i.isPinned)\n }\n\n /**\n * Create a filter predicate for the given Folder.\n * Returned predicate can be used in `Array.filter()`\n *\n * @param folder Folder to filter for\n * @param excludePinned Whether to exclude pinned folders\n */\n static filterFolder(folder: tl.TypeDialogFilter, excludePinned = true): (val: Dialog) => boolean {\n if (folder._ === 'dialogFilterDefault') {\n return () => true\n }\n\n const pinned: Record<number, true> = {}\n const include: Record<number, true> = {}\n const exclude: Record<number, true> = {}\n\n // populate indices\n if (excludePinned) {\n folder.pinnedPeers.forEach((peer) => {\n pinned[getMarkedPeerId(peer)] = true\n })\n }\n folder.includePeers.forEach((peer) => {\n include[getMarkedPeerId(peer)] = true\n })\n\n if (folder._ === 'dialogFilterChatlist') {\n return (dialog) => {\n const chatId = dialog.chat.id\n\n if (excludePinned && pinned[chatId]) return false\n\n return include[chatId] || pinned[chatId]\n }\n }\n\n folder.excludePeers.forEach((peer) => {\n exclude[getMarkedPeerId(peer)] = true\n })\n\n return (dialog) => {\n const chat = dialog.chat\n const chatId = dialog.chat.id\n const chatType = dialog.chat.chatType\n\n // manual exclusion/inclusion and pins\n if (include[chatId]) return true\n\n if (exclude[chatId] || (excludePinned && pinned[chatId])) {\n return false\n }\n\n // exclusions based on status\n if (folder.excludeRead && !dialog.isUnread) return false\n if (folder.excludeMuted && dialog.isMuted) return false\n // even though this was handled in getDialogs, this method\n // could be used outside of it, so check again\n if (folder.excludeArchived && dialog.isArchived) return false\n\n // inclusions based on chat type\n if (folder.contacts && chatType === 'private' && chat.isContact) {\n return true\n }\n if (folder.nonContacts && chatType === 'private' && !chat.isContact) {\n return true\n }\n if (folder.groups && (chatType === 'group' || chatType === 'supergroup')) {\n return true\n }\n if (folder.broadcasts && chatType === 'channel') return true\n if (folder.bots && chatType === 'bot') return true\n\n return false\n }\n }\n\n /**\n * Whether this dialog is pinned\n */\n get isPinned(): boolean {\n return this.raw.pinned!\n }\n\n /**\n * Whether this chat was manually marked as unread\n */\n get isManuallyUnread(): boolean {\n return this.raw.unreadMark!\n }\n\n /**\n * Whether this chat should be considered unread\n * (i.e. has more than 1 unread message, or has\n * a \"manually unread\" mark)\n */\n get isUnread(): boolean {\n return this.raw.unreadMark || this.raw.unreadCount > 1\n }\n\n /**\n * Whether this dialog is muted.\n *\n * If `null`, the default account-level setting should be used.\n */\n get isMuted(): boolean | null {\n return this.raw.notifySettings.silent ?? null\n }\n\n /**\n * Whether this dialog is archived\n */\n get isArchived(): boolean {\n return this.raw.folderId === 1\n }\n\n /**\n * Chat that this dialog represents\n */\n get chat(): Chat {\n return Chat._parseFromPeer(this.raw.peer, this._peers)\n }\n\n /**\n * The latest message sent in this chat (if any)\n */\n get lastMessage(): Message | null {\n const cid = this.chat.id\n\n if (this._messages.has(cid)) {\n return new Message(this._messages.get(cid)!, this._peers)\n }\n\n return null\n }\n\n /**\n * ID of the last read outgoing message in this dialog\n */\n get lastReadOutgoing(): number {\n return this.raw.readOutboxMaxId\n }\n\n /**\n * ID of the last read ingoing message in this dialog\n */\n get lastReadIngoing(): number {\n return this.raw.readInboxMaxId\n }\n\n /**\n * ID of the last read message in this dialog\n */\n get lastRead(): number {\n return Math.max(this.raw.readOutboxMaxId, this.raw.readInboxMaxId)\n }\n\n /**\n * Number of unread messages\n */\n get unreadCount(): number {\n return this.raw.unreadCount\n }\n\n /**\n * Number of unread mentions\n */\n get unreadMentionsCount(): number {\n return this.raw.unreadMentionsCount\n }\n\n /**\n * Number of unread reactions\n */\n get unreadReactionsCount(): number {\n return this.raw.unreadReactionsCount\n }\n\n /**\n * Draft message in this dialog\n */\n get draftMessage(): DraftMessage | null {\n if (this.raw.draft?._ === 'draftMessage') {\n return new DraftMessage(this.raw.draft)\n }\n\n return null\n }\n\n /**\n * TTL period of all messages in this dialog\n */\n get ttlPeriod(): number | null {\n return this.raw.ttlPeriod ?? null\n }\n}\n\nmemoizeGetters(Dialog, ['chat', 'lastMessage', 'draftMessage'])\nmakeInspectable(Dialog)\n"]}
|
|
@@ -344,6 +344,20 @@ export interface ActionBoostApply {
|
|
|
344
344
|
/** Number of boosts applied */
|
|
345
345
|
count: number;
|
|
346
346
|
}
|
|
347
|
-
|
|
347
|
+
/** A payment was refunded */
|
|
348
|
+
export interface ActionPaymentRefunded {
|
|
349
|
+
readonly type: 'payment_refunded';
|
|
350
|
+
/** Three-letter ISO 4217 currency code */
|
|
351
|
+
currency: string;
|
|
352
|
+
/** Marked ID of the peer where the stars were refunded (?) */
|
|
353
|
+
peerId: number;
|
|
354
|
+
/** Number of `currency` refunded, in the smallest unit */
|
|
355
|
+
amount: tl.Long;
|
|
356
|
+
/** Payload defined by the bot */
|
|
357
|
+
payload?: Uint8Array;
|
|
358
|
+
/** Information about the charge */
|
|
359
|
+
charge: tl.TypePaymentCharge;
|
|
360
|
+
}
|
|
361
|
+
export type MessageAction = ActionChatCreated | ActionChannelCreated | ActionChatMigrateTo | ActionChannelMigrateFrom | ActionMessagePinned | ActionHistoryCleared | ActionGameScore | ActionContactJoined | ActionTitleChanged | ActionPhotoChanged | ActionPhotoDeleted | ActionUsersAdded | ActionUserLeft | ActionUserRemoved | ActionUserJoinedLink | ActionPaymentReceived | ActionPaymentSent | ActionCall | ActionScreenshotTaken | ActionBotAllowed | ActionGeoProximity | ActionGroupCallStarted | ActionGroupCallEnded | ActionGroupCallScheduled | ActionGroupInvite | ActionTtlChanged | ActionTopicCreated | ActionTopicEdited | ActionCustom | ActionThemeChanged | ActionUserJoinedApproved | ActionWebviewDataSent | ActionWebviewDataReceived | ActionPremiumGifted | ActionPhotoSuggested | ActionPeerSent | ActionPeerChosen | ActionWallpaperChanged | ActionGiftCode | ActionGiveawayStarted | ActionGiveawayEnded | ActionBoostApply | ActionPaymentRefunded | null;
|
|
348
362
|
/** @internal */
|
|
349
363
|
export declare function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getMarkedPeerId } from '../../../utils/peer-utils.js';
|
|
1
2
|
import { _callDiscardReasonFromTl } from '../calls/index.js';
|
|
2
3
|
import { Photo } from '../media/photo.js';
|
|
3
4
|
import { parsePeer } from '../peers/peer.js';
|
|
@@ -250,6 +251,15 @@ export function _messageActionFromTl(act) {
|
|
|
250
251
|
type: 'boost_apply',
|
|
251
252
|
count: act.boosts,
|
|
252
253
|
};
|
|
254
|
+
case 'messageActionPaymentRefunded':
|
|
255
|
+
return {
|
|
256
|
+
type: 'payment_refunded',
|
|
257
|
+
currency: act.currency,
|
|
258
|
+
peerId: getMarkedPeerId(act.peer),
|
|
259
|
+
amount: act.totalAmount,
|
|
260
|
+
payload: act.payload,
|
|
261
|
+
charge: act.charge,
|
|
262
|
+
};
|
|
253
263
|
default:
|
|
254
264
|
return null;
|
|
255
265
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message-action.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AAgflD,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAgB,GAAyB;IACzE,kBAAkB;IAClB,6GAA6G;IAC7G,uEAAuE;IAEvE,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,EAAE,EAAE,GAAG,CAAC,SAAS;aACpB,CAAA;QACL,KAAK,iCAAiC;YAClC,OAAO;gBACH,IAAI,EAAE,sBAAsB;gBAC5B,EAAE,EAAE,GAAG,CAAC,MAAM;gBACd,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,gBAAgB;aACzB,CAAA;QACL,KAAK,2BAA2B;YAC5B,OAAO;gBACH,IA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AC,MAAM,CAAC,CAAC;aAC3D,CAAA;QACL,KAAK,+BAA+B;YAChC,OAAO;gBACH,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,GAAG,CAAC,IAAK;gBACf,OAAO,EAAE,GAAG,CAAC,OAAQ;gBACrB,SAAS,EAAE,GAAG,CAAC,SAAS;aAC3B,CAAA;QACL,KAAK,uBAAuB;YACxB,OAAO;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,EAAE,GAAG;aACX,CAAA;QACL,KAAK,6BAA6B;YAC9B,OAAO;gBACH,IAAI,EAAE,kBAAkB;aAC3B,CAAA;QACL,KAAK,8BAA8B;YAC/B,OAAO;gBACH,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,GAAG,CAAC,YAAY;gBACzB,aAAa,EAAE,GAAG,CAAC,cAAc;aACpC,CAAA;QACL,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,GAAG,CAAC,MAAM;aACpB,CAAA;QACL;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { _callDiscardReasonFromTl, CallDiscardReason } from '../calls/index.js'\nimport { Photo } from '../media/photo.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport type { Message } from './message.js'\n\n/** Group was created */\nexport interface ActionChatCreated {\n readonly type: 'chat_created'\n\n /** Group name */\n readonly title: string\n\n /** IDs of the users in the group */\n readonly users: number[]\n}\n\n/** Channel/supergroup was created */\nexport interface ActionChannelCreated {\n readonly type: 'channel_created'\n\n /** Original channel/supergroup title */\n readonly title: string\n}\n\n/** Chat was migrated to a supergroup with a given ID */\nexport interface ActionChatMigrateTo {\n readonly type: 'chat_migrate_to'\n\n /** Marked ID of the supergroup chat was migrated to */\n readonly id: number\n}\n\n/** Supergroup was migrated from a chat with a given ID */\nexport interface ActionChannelMigrateFrom {\n readonly type: 'channel_migrate_from'\n\n /** Marked ID of the chat this channel was migrated from */\n readonly id: number\n\n /** Old chat's title */\n readonly title: string\n}\n\n/**\n * A message has been pinned.\n *\n * To get the message itself, use {@link Message.getReplyTo}\n */\nexport interface ActionMessagePinned {\n readonly type: 'message_pinned'\n}\n\n/** History was cleared in a private chat. */\nexport interface ActionHistoryCleared {\n readonly type: 'history_cleared'\n}\n\n/** Someone scored in a game (usually only used for newly set high scores) */\nexport interface ActionGameScore {\n readonly type: 'game_score'\n\n /** Game ID */\n readonly gameId: tl.Long\n\n /** Score */\n readonly score: number\n}\n\n/** Contact has joined Telegram */\nexport interface ActionContactJoined {\n readonly type: 'contact_joined'\n}\n\n/** Group title was changed */\nexport interface ActionTitleChanged {\n readonly type: 'title_changed'\n\n /** New group name */\n readonly title: string\n}\n\n/** Group photo was changed */\nexport interface ActionPhotoChanged {\n readonly type: 'photo_changed'\n\n /** New group photo */\n readonly photo: Photo\n}\n\n/** Group photo was deleted */\nexport interface ActionPhotoDeleted {\n readonly type: 'photo_deleted'\n}\n\n/** Users were added to the chat */\nexport interface ActionUsersAdded {\n readonly type: 'users_added'\n\n /** IDs of the users that were added */\n readonly users: number[]\n}\n\n/** User has left the group */\nexport interface ActionUserLeft {\n readonly type: 'user_left'\n}\n\n/** User was removed from the group */\nexport interface ActionUserRemoved {\n readonly type: 'user_removed'\n\n /** ID of the user that was removed from the group */\n readonly user: number\n}\n\n/** User has joined the group via an invite link */\nexport interface ActionUserJoinedLink {\n readonly type: 'user_joined_link'\n\n /** ID of the user who created the link */\n readonly inviter: number\n}\n\n/**\n * User has joined the group via an invite link\n * and was approved by an administrator\n */\nexport interface ActionUserJoinedApproved {\n readonly type: 'user_joined_approved'\n}\n\n/** A payment was received from a user (bot) */\nexport interface ActionPaymentReceived {\n readonly type: 'payment_received'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n\n /** Bot specified invoice payload */\n readonly payload: Uint8Array\n\n /** Order information provided by the user */\n readonly info?: tl.TypePaymentRequestedInfo\n\n /** ID of the shipping option chosen by the user */\n readonly shippingOptionId?: string\n\n /** Payment provider ID */\n readonly charge?: tl.TypePaymentCharge\n}\n\n/** A payment was sent to a user */\nexport interface ActionPaymentSent {\n readonly type: 'payment_sent'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n}\n\n/** A phone call */\nexport interface ActionCall {\n readonly type: 'call'\n\n /** Call ID */\n readonly id: tl.Long\n\n /** Whether this is a video call */\n readonly isVideo: boolean\n\n /** Duration if the call in seconds (0 if not available) */\n readonly duration: number\n\n /** Call discard reason, if available */\n readonly reason?: CallDiscardReason\n}\n\n/** A screenshot was taken */\nexport interface ActionScreenshotTaken {\n readonly type: 'screenshot_taken'\n}\n\n/** User has authorized via the bot */\nexport interface ActionBotAllowed {\n readonly type: 'bot_allowed'\n\n /** Domain where the user has logged in */\n readonly domain?: string\n}\n\n/**\n * A user is in proximity of another user\n * (see [Proximity alerts](https://core.telegram.org/api/live-location#proximity-alert))\n */\nexport interface ActionGeoProximity {\n readonly type: 'geo_proximity'\n\n /** ID of the user who sent the geolocation with proximity alerts */\n readonly targetId: number\n\n /** ID of the user who has approached `targetId` */\n readonly userId: number\n\n /** Distance between them in meters */\n readonly distance: number\n}\n\n/** Group call has started */\nexport interface ActionGroupCallStarted {\n readonly type: 'group_call_started'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n}\n\n/** Group call has ended */\nexport interface ActionGroupCallEnded {\n readonly type: 'group_call_ended'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Duration of the call */\n readonly duration: number\n}\n\n/** Group call has been scheduled */\nexport interface ActionGroupCallScheduled {\n readonly type: 'group_call_scheduled'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Date when the call will start */\n readonly date: Date\n}\n\n/** Group call has ended */\nexport interface ActionGroupInvite {\n readonly type: 'group_call_invite'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** IDs of the users invited to the call */\n readonly userIds: number[]\n}\n\n/** Messages TTL changed */\nexport interface ActionTtlChanged {\n readonly type: 'ttl_changed'\n\n /** New TTL period */\n readonly period: number\n}\n\n/** Forum topic was created */\nexport interface ActionTopicCreated {\n readonly type: 'topic_created'\n\n /** Title of the topic */\n title: string\n\n /** Icon color of the topic */\n iconColor: number\n\n /** Icon emoji of the topic */\n iconCustomEmoji?: tl.Long\n}\n\n/** Forum topic was modified */\nexport interface ActionTopicEdited {\n readonly type: 'topic_edited'\n\n /** New title of the topic */\n title?: string\n\n /** New icon emoji of the topic (may be empty) */\n iconCustomEmoji?: tl.Long\n\n /** Whether the topic was opened/closed */\n closed?: boolean\n\n /** Whether the topic was (un-)hidden - only for \"General\" topic (`id=1`) */\n hidden?: boolean\n}\n\n/** A non-standard action has happened in the chat */\nexport interface ActionCustom {\n readonly type: 'custom'\n\n /** Text to be shown in the interface */\n action: string\n}\n\n/** Chat theme was changed */\nexport interface ActionThemeChanged {\n readonly type: 'theme_changed'\n\n /** Emoji representing the new theme */\n emoji: string\n}\n\n/** Data was sent from a WebView (user-side action) */\nexport interface ActionWebviewDataSent {\n readonly type: 'webview_sent'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n}\n\n/** Data was received from a WebView (bot-side action) */\nexport interface ActionWebviewDataReceived {\n readonly type: 'webview_received'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n\n /** Data received from the WebView */\n data: string\n}\n\n/** Premium subscription was gifted */\nexport interface ActionPremiumGifted {\n readonly type: 'premium_gifted'\n\n /**\n * Currency in which it was paid for.\n * Three-letter ISO 4217 currency code)\n */\n currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n amount: number\n\n /** Duration of the gifted subscription in months */\n months: number\n\n /** If the subscription was bought with crypto, information about it */\n crypto?: {\n /** Crypto currency name */\n currency: string\n /** Price in the smallest units */\n amount: number\n }\n}\n\n/** A photo has been suggested as a profile photo */\nexport interface ActionPhotoSuggested {\n readonly type: 'photo_suggested'\n\n /** Photo that was suggested */\n photo: Photo\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button.\n * The user-side version of {@link ActionPeerChosen}\n */\nexport interface ActionPeerSent {\n readonly type: 'peer_sent'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Brief information about the chosen peers */\n peers: tl.TypeRequestedPeer[]\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button\n * The bot-side version of {@link ActionPeerSent}\n */\nexport interface ActionPeerChosen {\n readonly type: 'peer_chosen'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Chosen peers */\n peers: Peer[]\n}\n\n/** A wallpaper of the chathas been changed */\nexport interface ActionWallpaperChanged {\n readonly type: 'wallpaper_changed'\n\n /**\n * Whether the user has applied the same wallpaper\n * as the other party previously set in the chat\n */\n same: boolean\n\n /**\n * Whether the wallpaper was forcefully applied for\n * both sides, without explicit confirmation from the other\n * side.\n */\n forBoth: boolean\n\n /** TL object representing the new wallpaper */\n wallpaper: tl.TypeWallPaper\n}\n\n/** A Telergam Premium gift code was received */\nexport interface ActionGiftCode {\n readonly type: 'gift_code'\n\n /** Information about the gift code */\n raw: tl.RawMessageActionGiftCode\n}\n\n/** A Telergam Premium giveaway was started */\nexport interface ActionGiveawayStarted {\n readonly type: 'giveaway_started'\n}\n\n/** A Telergam Premium giveaway was ended and results are available */\nexport interface ActionGiveawayEnded {\n readonly type: 'giveaway_ended'\n\n /** Number of winners in the giveaway */\n winners: number\n\n /** Number of undistributed prizes */\n undistributed: number\n}\n\n/** Boosts were applied to the group */\nexport interface ActionBoostApply {\n readonly type: 'boost_apply'\n\n /** Number of boosts applied */\n count: number\n}\n\nexport type MessageAction =\n | ActionChatCreated\n | ActionChannelCreated\n | ActionChatMigrateTo\n | ActionChannelMigrateFrom\n | ActionMessagePinned\n | ActionHistoryCleared\n | ActionGameScore\n | ActionContactJoined\n | ActionTitleChanged\n | ActionPhotoChanged\n | ActionPhotoDeleted\n | ActionUsersAdded\n | ActionUserLeft\n | ActionUserRemoved\n | ActionUserJoinedLink\n | ActionPaymentReceived\n | ActionPaymentSent\n | ActionCall\n | ActionScreenshotTaken\n | ActionBotAllowed\n | ActionGeoProximity\n | ActionGroupCallStarted\n | ActionGroupCallEnded\n | ActionGroupCallScheduled\n | ActionGroupInvite\n | ActionTtlChanged\n | ActionTopicCreated\n | ActionTopicEdited\n | ActionCustom\n | ActionThemeChanged\n | ActionUserJoinedApproved\n | ActionWebviewDataSent\n | ActionWebviewDataReceived\n | ActionPremiumGifted\n | ActionPhotoSuggested\n | ActionPeerSent\n | ActionPeerChosen\n | ActionWallpaperChanged\n | ActionGiftCode\n | ActionGiveawayStarted\n | ActionGiveawayEnded\n | ActionBoostApply\n | null\n\n/** @internal */\nexport function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction {\n // todo - passport\n // messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted\n // messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType>\n\n switch (act._) {\n case 'messageActionChatCreate':\n return {\n type: 'chat_created',\n title: act.title,\n users: act.users,\n }\n case 'messageActionChannelCreate':\n return {\n type: 'channel_created',\n title: act.title,\n }\n case 'messageActionChatMigrateTo':\n return {\n type: 'chat_migrate_to',\n id: act.channelId,\n }\n case 'messageActionChannelMigrateFrom':\n return {\n type: 'channel_migrate_from',\n id: act.chatId,\n title: act.title,\n }\n case 'messageActionPinMessage':\n return {\n type: 'message_pinned',\n }\n case 'messageActionHistoryClear':\n return {\n type: 'history_cleared',\n }\n case 'messageActionGameScore':\n return {\n type: 'game_score',\n gameId: act.gameId,\n score: act.score,\n }\n case 'messageActionContactSignUp':\n return {\n type: 'contact_joined',\n }\n case 'messageActionChatEditTitle':\n return {\n type: 'title_changed',\n title: act.title,\n }\n case 'messageActionChatEditPhoto':\n return {\n type: 'photo_changed',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionChatDeletePhoto':\n return {\n type: 'photo_deleted',\n }\n case 'messageActionChatAddUser':\n return {\n type: 'users_added',\n users: act.users,\n }\n case 'messageActionChatDeleteUser':\n if (this.raw.fromId?._ === 'peerUser' && act.userId === this.raw.fromId.userId) {\n return {\n type: 'user_left',\n }\n }\n\n return {\n type: 'user_removed',\n user: act.userId,\n }\n\n case 'messageActionChatJoinedByLink':\n return {\n type: 'user_joined_link',\n inviter: act.inviterId,\n }\n case 'messageActionPaymentSentMe':\n return {\n type: 'payment_received',\n currency: act.currency,\n amount: act.totalAmount,\n payload: act.payload,\n info: act.info,\n shippingOptionId: act.shippingOptionId,\n charge: act.charge,\n }\n case 'messageActionPaymentSent':\n return {\n type: 'payment_sent',\n currency: act.currency,\n amount: act.totalAmount,\n }\n case 'messageActionPhoneCall':\n return {\n type: 'call',\n id: act.callId,\n isVideo: Boolean(act.video),\n reason: act.reason ? _callDiscardReasonFromTl(act.reason) : undefined,\n duration: act.duration ?? 0,\n }\n case 'messageActionScreenshotTaken':\n return {\n type: 'screenshot_taken',\n }\n case 'messageActionBotAllowed':\n return {\n type: 'bot_allowed',\n domain: act.domain,\n }\n case 'messageActionGeoProximityReached':\n if (act.fromId._ !== 'peerUser' || act.toId._ !== 'peerUser') {\n return null\n }\n\n return {\n type: 'geo_proximity',\n targetId: act.toId.userId,\n userId: act.fromId.userId,\n distance: act.distance,\n }\n\n case 'messageActionGroupCall':\n if (act.duration) {\n return {\n type: 'group_call_ended',\n call: act.call,\n duration: act.duration,\n }\n }\n\n return {\n type: 'group_call_started',\n call: act.call,\n }\n case 'messageActionGroupCallScheduled':\n return {\n type: 'group_call_scheduled',\n call: act.call,\n date: new Date(act.scheduleDate * 1000),\n }\n case 'messageActionInviteToGroupCall':\n return {\n type: 'group_call_invite',\n call: act.call,\n userIds: act.users,\n }\n case 'messageActionSetMessagesTTL':\n return {\n type: 'ttl_changed',\n period: act.period,\n }\n case 'messageActionTopicCreate':\n return {\n type: 'topic_created',\n title: act.title,\n iconColor: act.iconColor,\n iconCustomEmoji: act.iconEmojiId,\n }\n case 'messageActionTopicEdit':\n return {\n type: 'topic_edited',\n title: act.title,\n iconCustomEmoji: act.iconEmojiId,\n closed: act.closed,\n hidden: act.hidden,\n }\n case 'messageActionCustomAction':\n return {\n type: 'custom',\n action: act.message,\n }\n case 'messageActionSetChatTheme':\n return {\n type: 'theme_changed',\n emoji: act.emoticon,\n }\n case 'messageActionChatJoinedByRequest':\n return {\n type: 'user_joined_approved',\n }\n case 'messageActionWebViewDataSent':\n return {\n type: 'webview_sent',\n text: act.text,\n }\n case 'messageActionWebViewDataSentMe':\n return {\n type: 'webview_received',\n text: act.text,\n data: act.data,\n }\n case 'messageActionGiftPremium':\n return {\n type: 'premium_gifted',\n currency: act.currency,\n amount: act.amount.toNumber(),\n months: act.months,\n crypto: act.cryptoAmount ?\n {\n currency: act.cryptoCurrency!,\n amount: act.cryptoAmount.toNumber(),\n } :\n undefined,\n }\n case 'messageActionSuggestProfilePhoto':\n return {\n type: 'photo_suggested',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionRequestedPeerSentMe':\n return {\n type: 'peer_sent',\n buttonId: act.buttonId,\n peers: act.peers,\n }\n case 'messageActionRequestedPeer':\n return {\n type: 'peer_chosen',\n buttonId: act.buttonId,\n peers: act.peers.map((it) => parsePeer(it, this._peers)),\n }\n case 'messageActionSetChatWallPaper':\n return {\n type: 'wallpaper_changed',\n same: act.same!,\n forBoth: act.forBoth!,\n wallpaper: act.wallpaper,\n }\n case 'messageActionGiftCode':\n return {\n type: 'gift_code',\n raw: act,\n }\n case 'messageActionGiveawayLaunch':\n return {\n type: 'giveaway_started',\n }\n case 'messageActionGiveawayResults':\n return {\n type: 'giveaway_ended',\n winners: act.winnersCount,\n undistributed: act.unclaimedCount,\n }\n case 'messageActionBoostApply':\n return {\n type: 'boost_apply',\n count: act.boosts,\n }\n default:\n return null\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"message-action.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/messages/message-action.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,EAAE,wBAAwB,EAAqB,MAAM,mBAAmB,CAAA;AAC/E,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,SAAS,EAAQ,MAAM,kBAAkB,CAAA;AAqgBlD,gBAAgB;AAChB,MAAM,UAAU,oBAAoB,CAAgB,GAAyB;IACzE,kBAAkB;IAClB,6GAA6G;IAC7G,uEAAuE;IAEvE,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,cAAc;gBACpB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,4BAA4B;YAC7B,OAAO;gBACH,IAAI,EAAE,iBAAiB;gBACvB,EAAE,EAAE,GAAG,CAAC,SAAS;aACpB,CAAA;QACL,KAAK,iCAAiC;YAClC,OAAO;gBACH,IAAI,EAAE,sBAAsB;gBAC5B,EAAE,EAAE,GAAG,CAAC,MAAM;gBACd,KAAK,EAAE,GAAG,CAAC,KAAK;aACnB,CAAA;QACL,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,gBAAgB;aACzB,CAAA;QACL,KAAK,2BAA2B;YAC5B,OAAO;gBACH,IAAI,EAAE,i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AAC,CAAC;aAC3D,CAAA;QACL,KAAK,+BAA+B;YAChC,OAAO;gBACH,IAAI,EAAE,mBAAmB;gBACzB,IAAI,EAAE,GAAG,CAAC,IAAK;gBACf,OAAO,EAAE,GAAG,CAAC,OAAQ;gBACrB,SAAS,EAAE,GAAG,CAAC,SAAS;aAC3B,CAAA;QACL,KAAK,uBAAuB;YACxB,OAAO;gBACH,IAAI,EAAE,WAAW;gBACjB,GAAG,EAAE,GAAG;aACX,CAAA;QACL,KAAK,6BAA6B;YAC9B,OAAO;gBACH,IAAI,EAAE,kBAAkB;aAC3B,CAAA;QACL,KAAK,8BAA8B;YAC/B,OAAO;gBACH,IAAI,EAAE,gBAAgB;gBACtB,OAAO,EAAE,GAAG,CAAC,YAAY;gBACzB,aAAa,EAAE,GAAG,CAAC,cAAc;aACpC,CAAA;QACL,KAAK,yBAAyB;YAC1B,OAAO;gBACH,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,GAAG,CAAC,MAAM;aACpB,CAAA;QACL,KAAK,8BAA8B;YAC/B,OAAO;gBACH,IAAI,EAAE,kBAAkB;gBACxB,QAAQ,EAAE,GAAG,CAAC,QAAQ;gBACtB,MAAM,EAAE,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC;gBACjC,MAAM,EAAE,GAAG,CAAC,WAAW;gBACvB,OAAO,EAAE,GAAG,CAAC,OAAO;gBACpB,MAAM,EAAE,GAAG,CAAC,MAAM;aACrB,CAAA;QACL;YACI,OAAO,IAAI,CAAA;IACnB,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { getMarkedPeerId } from '../../../utils/peer-utils.js'\nimport { _callDiscardReasonFromTl, CallDiscardReason } from '../calls/index.js'\nimport { Photo } from '../media/photo.js'\nimport { parsePeer, Peer } from '../peers/peer.js'\nimport type { Message } from './message.js'\n\n/** Group was created */\nexport interface ActionChatCreated {\n readonly type: 'chat_created'\n\n /** Group name */\n readonly title: string\n\n /** IDs of the users in the group */\n readonly users: number[]\n}\n\n/** Channel/supergroup was created */\nexport interface ActionChannelCreated {\n readonly type: 'channel_created'\n\n /** Original channel/supergroup title */\n readonly title: string\n}\n\n/** Chat was migrated to a supergroup with a given ID */\nexport interface ActionChatMigrateTo {\n readonly type: 'chat_migrate_to'\n\n /** Marked ID of the supergroup chat was migrated to */\n readonly id: number\n}\n\n/** Supergroup was migrated from a chat with a given ID */\nexport interface ActionChannelMigrateFrom {\n readonly type: 'channel_migrate_from'\n\n /** Marked ID of the chat this channel was migrated from */\n readonly id: number\n\n /** Old chat's title */\n readonly title: string\n}\n\n/**\n * A message has been pinned.\n *\n * To get the message itself, use {@link Message.getReplyTo}\n */\nexport interface ActionMessagePinned {\n readonly type: 'message_pinned'\n}\n\n/** History was cleared in a private chat. */\nexport interface ActionHistoryCleared {\n readonly type: 'history_cleared'\n}\n\n/** Someone scored in a game (usually only used for newly set high scores) */\nexport interface ActionGameScore {\n readonly type: 'game_score'\n\n /** Game ID */\n readonly gameId: tl.Long\n\n /** Score */\n readonly score: number\n}\n\n/** Contact has joined Telegram */\nexport interface ActionContactJoined {\n readonly type: 'contact_joined'\n}\n\n/** Group title was changed */\nexport interface ActionTitleChanged {\n readonly type: 'title_changed'\n\n /** New group name */\n readonly title: string\n}\n\n/** Group photo was changed */\nexport interface ActionPhotoChanged {\n readonly type: 'photo_changed'\n\n /** New group photo */\n readonly photo: Photo\n}\n\n/** Group photo was deleted */\nexport interface ActionPhotoDeleted {\n readonly type: 'photo_deleted'\n}\n\n/** Users were added to the chat */\nexport interface ActionUsersAdded {\n readonly type: 'users_added'\n\n /** IDs of the users that were added */\n readonly users: number[]\n}\n\n/** User has left the group */\nexport interface ActionUserLeft {\n readonly type: 'user_left'\n}\n\n/** User was removed from the group */\nexport interface ActionUserRemoved {\n readonly type: 'user_removed'\n\n /** ID of the user that was removed from the group */\n readonly user: number\n}\n\n/** User has joined the group via an invite link */\nexport interface ActionUserJoinedLink {\n readonly type: 'user_joined_link'\n\n /** ID of the user who created the link */\n readonly inviter: number\n}\n\n/**\n * User has joined the group via an invite link\n * and was approved by an administrator\n */\nexport interface ActionUserJoinedApproved {\n readonly type: 'user_joined_approved'\n}\n\n/** A payment was received from a user (bot) */\nexport interface ActionPaymentReceived {\n readonly type: 'payment_received'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n\n /** Bot specified invoice payload */\n readonly payload: Uint8Array\n\n /** Order information provided by the user */\n readonly info?: tl.TypePaymentRequestedInfo\n\n /** ID of the shipping option chosen by the user */\n readonly shippingOptionId?: string\n\n /** Payment provider ID */\n readonly charge?: tl.TypePaymentCharge\n}\n\n/** A payment was sent to a user */\nexport interface ActionPaymentSent {\n readonly type: 'payment_sent'\n\n /** Three-letter ISO 4217 currency code */\n readonly currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n readonly amount: tl.Long\n}\n\n/** A phone call */\nexport interface ActionCall {\n readonly type: 'call'\n\n /** Call ID */\n readonly id: tl.Long\n\n /** Whether this is a video call */\n readonly isVideo: boolean\n\n /** Duration if the call in seconds (0 if not available) */\n readonly duration: number\n\n /** Call discard reason, if available */\n readonly reason?: CallDiscardReason\n}\n\n/** A screenshot was taken */\nexport interface ActionScreenshotTaken {\n readonly type: 'screenshot_taken'\n}\n\n/** User has authorized via the bot */\nexport interface ActionBotAllowed {\n readonly type: 'bot_allowed'\n\n /** Domain where the user has logged in */\n readonly domain?: string\n}\n\n/**\n * A user is in proximity of another user\n * (see [Proximity alerts](https://core.telegram.org/api/live-location#proximity-alert))\n */\nexport interface ActionGeoProximity {\n readonly type: 'geo_proximity'\n\n /** ID of the user who sent the geolocation with proximity alerts */\n readonly targetId: number\n\n /** ID of the user who has approached `targetId` */\n readonly userId: number\n\n /** Distance between them in meters */\n readonly distance: number\n}\n\n/** Group call has started */\nexport interface ActionGroupCallStarted {\n readonly type: 'group_call_started'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n}\n\n/** Group call has ended */\nexport interface ActionGroupCallEnded {\n readonly type: 'group_call_ended'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Duration of the call */\n readonly duration: number\n}\n\n/** Group call has been scheduled */\nexport interface ActionGroupCallScheduled {\n readonly type: 'group_call_scheduled'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** Date when the call will start */\n readonly date: Date\n}\n\n/** Group call has ended */\nexport interface ActionGroupInvite {\n readonly type: 'group_call_invite'\n\n /** TL object representing the call */\n readonly call: tl.TypeInputGroupCall\n\n /** IDs of the users invited to the call */\n readonly userIds: number[]\n}\n\n/** Messages TTL changed */\nexport interface ActionTtlChanged {\n readonly type: 'ttl_changed'\n\n /** New TTL period */\n readonly period: number\n}\n\n/** Forum topic was created */\nexport interface ActionTopicCreated {\n readonly type: 'topic_created'\n\n /** Title of the topic */\n title: string\n\n /** Icon color of the topic */\n iconColor: number\n\n /** Icon emoji of the topic */\n iconCustomEmoji?: tl.Long\n}\n\n/** Forum topic was modified */\nexport interface ActionTopicEdited {\n readonly type: 'topic_edited'\n\n /** New title of the topic */\n title?: string\n\n /** New icon emoji of the topic (may be empty) */\n iconCustomEmoji?: tl.Long\n\n /** Whether the topic was opened/closed */\n closed?: boolean\n\n /** Whether the topic was (un-)hidden - only for \"General\" topic (`id=1`) */\n hidden?: boolean\n}\n\n/** A non-standard action has happened in the chat */\nexport interface ActionCustom {\n readonly type: 'custom'\n\n /** Text to be shown in the interface */\n action: string\n}\n\n/** Chat theme was changed */\nexport interface ActionThemeChanged {\n readonly type: 'theme_changed'\n\n /** Emoji representing the new theme */\n emoji: string\n}\n\n/** Data was sent from a WebView (user-side action) */\nexport interface ActionWebviewDataSent {\n readonly type: 'webview_sent'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n}\n\n/** Data was received from a WebView (bot-side action) */\nexport interface ActionWebviewDataReceived {\n readonly type: 'webview_received'\n\n /** Text of the button that was pressed to open the WebView */\n text: string\n\n /** Data received from the WebView */\n data: string\n}\n\n/** Premium subscription was gifted */\nexport interface ActionPremiumGifted {\n readonly type: 'premium_gifted'\n\n /**\n * Currency in which it was paid for.\n * Three-letter ISO 4217 currency code)\n */\n currency: string\n\n /**\n * Price of the product in the smallest units of the currency\n * (integer, not float/double). For example, for a price of\n * `US$ 1.45`, `amount = 145`\n */\n amount: number\n\n /** Duration of the gifted subscription in months */\n months: number\n\n /** If the subscription was bought with crypto, information about it */\n crypto?: {\n /** Crypto currency name */\n currency: string\n /** Price in the smallest units */\n amount: number\n }\n}\n\n/** A photo has been suggested as a profile photo */\nexport interface ActionPhotoSuggested {\n readonly type: 'photo_suggested'\n\n /** Photo that was suggested */\n photo: Photo\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button.\n * The user-side version of {@link ActionPeerChosen}\n */\nexport interface ActionPeerSent {\n readonly type: 'peer_sent'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Brief information about the chosen peers */\n peers: tl.TypeRequestedPeer[]\n}\n\n/**\n * A peer was chosen by the user after clicking on a RequestPeer button\n * The bot-side version of {@link ActionPeerSent}\n */\nexport interface ActionPeerChosen {\n readonly type: 'peer_chosen'\n\n /** ID of the button passed earlier by the bot */\n buttonId: number\n\n /** Chosen peers */\n peers: Peer[]\n}\n\n/** A wallpaper of the chathas been changed */\nexport interface ActionWallpaperChanged {\n readonly type: 'wallpaper_changed'\n\n /**\n * Whether the user has applied the same wallpaper\n * as the other party previously set in the chat\n */\n same: boolean\n\n /**\n * Whether the wallpaper was forcefully applied for\n * both sides, without explicit confirmation from the other\n * side.\n */\n forBoth: boolean\n\n /** TL object representing the new wallpaper */\n wallpaper: tl.TypeWallPaper\n}\n\n/** A Telergam Premium gift code was received */\nexport interface ActionGiftCode {\n readonly type: 'gift_code'\n\n /** Information about the gift code */\n raw: tl.RawMessageActionGiftCode\n}\n\n/** A Telergam Premium giveaway was started */\nexport interface ActionGiveawayStarted {\n readonly type: 'giveaway_started'\n}\n\n/** A Telergam Premium giveaway was ended and results are available */\nexport interface ActionGiveawayEnded {\n readonly type: 'giveaway_ended'\n\n /** Number of winners in the giveaway */\n winners: number\n\n /** Number of undistributed prizes */\n undistributed: number\n}\n\n/** Boosts were applied to the group */\nexport interface ActionBoostApply {\n readonly type: 'boost_apply'\n\n /** Number of boosts applied */\n count: number\n}\n\n/** A payment was refunded */\nexport interface ActionPaymentRefunded {\n readonly type: 'payment_refunded'\n\n /** Three-letter ISO 4217 currency code */\n currency: string\n\n /** Marked ID of the peer where the stars were refunded (?) */\n peerId: number\n\n /** Number of `currency` refunded, in the smallest unit */\n amount: tl.Long\n\n /** Payload defined by the bot */\n payload?: Uint8Array\n\n /** Information about the charge */\n charge: tl.TypePaymentCharge\n}\n\nexport type MessageAction =\n | ActionChatCreated\n | ActionChannelCreated\n | ActionChatMigrateTo\n | ActionChannelMigrateFrom\n | ActionMessagePinned\n | ActionHistoryCleared\n | ActionGameScore\n | ActionContactJoined\n | ActionTitleChanged\n | ActionPhotoChanged\n | ActionPhotoDeleted\n | ActionUsersAdded\n | ActionUserLeft\n | ActionUserRemoved\n | ActionUserJoinedLink\n | ActionPaymentReceived\n | ActionPaymentSent\n | ActionCall\n | ActionScreenshotTaken\n | ActionBotAllowed\n | ActionGeoProximity\n | ActionGroupCallStarted\n | ActionGroupCallEnded\n | ActionGroupCallScheduled\n | ActionGroupInvite\n | ActionTtlChanged\n | ActionTopicCreated\n | ActionTopicEdited\n | ActionCustom\n | ActionThemeChanged\n | ActionUserJoinedApproved\n | ActionWebviewDataSent\n | ActionWebviewDataReceived\n | ActionPremiumGifted\n | ActionPhotoSuggested\n | ActionPeerSent\n | ActionPeerChosen\n | ActionWallpaperChanged\n | ActionGiftCode\n | ActionGiveawayStarted\n | ActionGiveawayEnded\n | ActionBoostApply\n | ActionPaymentRefunded\n | null\n\n/** @internal */\nexport function _messageActionFromTl(this: Message, act: tl.TypeMessageAction): MessageAction {\n // todo - passport\n // messageActionSecureValuesSentMe#1b287353 values:Vector<SecureValue> credentials:SecureCredentialsEncrypted\n // messageActionSecureValuesSent#d95c6154 types:Vector<SecureValueType>\n\n switch (act._) {\n case 'messageActionChatCreate':\n return {\n type: 'chat_created',\n title: act.title,\n users: act.users,\n }\n case 'messageActionChannelCreate':\n return {\n type: 'channel_created',\n title: act.title,\n }\n case 'messageActionChatMigrateTo':\n return {\n type: 'chat_migrate_to',\n id: act.channelId,\n }\n case 'messageActionChannelMigrateFrom':\n return {\n type: 'channel_migrate_from',\n id: act.chatId,\n title: act.title,\n }\n case 'messageActionPinMessage':\n return {\n type: 'message_pinned',\n }\n case 'messageActionHistoryClear':\n return {\n type: 'history_cleared',\n }\n case 'messageActionGameScore':\n return {\n type: 'game_score',\n gameId: act.gameId,\n score: act.score,\n }\n case 'messageActionContactSignUp':\n return {\n type: 'contact_joined',\n }\n case 'messageActionChatEditTitle':\n return {\n type: 'title_changed',\n title: act.title,\n }\n case 'messageActionChatEditPhoto':\n return {\n type: 'photo_changed',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionChatDeletePhoto':\n return {\n type: 'photo_deleted',\n }\n case 'messageActionChatAddUser':\n return {\n type: 'users_added',\n users: act.users,\n }\n case 'messageActionChatDeleteUser':\n if (this.raw.fromId?._ === 'peerUser' && act.userId === this.raw.fromId.userId) {\n return {\n type: 'user_left',\n }\n }\n\n return {\n type: 'user_removed',\n user: act.userId,\n }\n\n case 'messageActionChatJoinedByLink':\n return {\n type: 'user_joined_link',\n inviter: act.inviterId,\n }\n case 'messageActionPaymentSentMe':\n return {\n type: 'payment_received',\n currency: act.currency,\n amount: act.totalAmount,\n payload: act.payload,\n info: act.info,\n shippingOptionId: act.shippingOptionId,\n charge: act.charge,\n }\n case 'messageActionPaymentSent':\n return {\n type: 'payment_sent',\n currency: act.currency,\n amount: act.totalAmount,\n }\n case 'messageActionPhoneCall':\n return {\n type: 'call',\n id: act.callId,\n isVideo: Boolean(act.video),\n reason: act.reason ? _callDiscardReasonFromTl(act.reason) : undefined,\n duration: act.duration ?? 0,\n }\n case 'messageActionScreenshotTaken':\n return {\n type: 'screenshot_taken',\n }\n case 'messageActionBotAllowed':\n return {\n type: 'bot_allowed',\n domain: act.domain,\n }\n case 'messageActionGeoProximityReached':\n if (act.fromId._ !== 'peerUser' || act.toId._ !== 'peerUser') {\n return null\n }\n\n return {\n type: 'geo_proximity',\n targetId: act.toId.userId,\n userId: act.fromId.userId,\n distance: act.distance,\n }\n\n case 'messageActionGroupCall':\n if (act.duration) {\n return {\n type: 'group_call_ended',\n call: act.call,\n duration: act.duration,\n }\n }\n\n return {\n type: 'group_call_started',\n call: act.call,\n }\n case 'messageActionGroupCallScheduled':\n return {\n type: 'group_call_scheduled',\n call: act.call,\n date: new Date(act.scheduleDate * 1000),\n }\n case 'messageActionInviteToGroupCall':\n return {\n type: 'group_call_invite',\n call: act.call,\n userIds: act.users,\n }\n case 'messageActionSetMessagesTTL':\n return {\n type: 'ttl_changed',\n period: act.period,\n }\n case 'messageActionTopicCreate':\n return {\n type: 'topic_created',\n title: act.title,\n iconColor: act.iconColor,\n iconCustomEmoji: act.iconEmojiId,\n }\n case 'messageActionTopicEdit':\n return {\n type: 'topic_edited',\n title: act.title,\n iconCustomEmoji: act.iconEmojiId,\n closed: act.closed,\n hidden: act.hidden,\n }\n case 'messageActionCustomAction':\n return {\n type: 'custom',\n action: act.message,\n }\n case 'messageActionSetChatTheme':\n return {\n type: 'theme_changed',\n emoji: act.emoticon,\n }\n case 'messageActionChatJoinedByRequest':\n return {\n type: 'user_joined_approved',\n }\n case 'messageActionWebViewDataSent':\n return {\n type: 'webview_sent',\n text: act.text,\n }\n case 'messageActionWebViewDataSentMe':\n return {\n type: 'webview_received',\n text: act.text,\n data: act.data,\n }\n case 'messageActionGiftPremium':\n return {\n type: 'premium_gifted',\n currency: act.currency,\n amount: act.amount.toNumber(),\n months: act.months,\n crypto: act.cryptoAmount ?\n {\n currency: act.cryptoCurrency!,\n amount: act.cryptoAmount.toNumber(),\n } :\n undefined,\n }\n case 'messageActionSuggestProfilePhoto':\n return {\n type: 'photo_suggested',\n photo: new Photo(act.photo as tl.RawPhoto),\n }\n case 'messageActionRequestedPeerSentMe':\n return {\n type: 'peer_sent',\n buttonId: act.buttonId,\n peers: act.peers,\n }\n case 'messageActionRequestedPeer':\n return {\n type: 'peer_chosen',\n buttonId: act.buttonId,\n peers: act.peers.map((it) => parsePeer(it, this._peers)),\n }\n case 'messageActionSetChatWallPaper':\n return {\n type: 'wallpaper_changed',\n same: act.same!,\n forBoth: act.forBoth!,\n wallpaper: act.wallpaper,\n }\n case 'messageActionGiftCode':\n return {\n type: 'gift_code',\n raw: act,\n }\n case 'messageActionGiveawayLaunch':\n return {\n type: 'giveaway_started',\n }\n case 'messageActionGiveawayResults':\n return {\n type: 'giveaway_ended',\n winners: act.winnersCount,\n undistributed: act.unclaimedCount,\n }\n case 'messageActionBoostApply':\n return {\n type: 'boost_apply',\n count: act.boosts,\n }\n case 'messageActionPaymentRefunded':\n return {\n type: 'payment_refunded',\n currency: act.currency,\n peerId: getMarkedPeerId(act.peer),\n amount: act.totalAmount,\n payload: act.payload,\n charge: act.charge,\n }\n default:\n return null\n }\n}\n"]}
|
|
@@ -76,6 +76,8 @@ export declare class FullChat extends Chat {
|
|
|
76
76
|
* Number of boosts required for the user to be unrestricted in this chat.
|
|
77
77
|
*/
|
|
78
78
|
get boostsForUnrestrict(): number;
|
|
79
|
+
/** Whether the current user can view Telegram Stars revenue for this chat */
|
|
80
|
+
get canViewStarsRevenue(): boolean;
|
|
79
81
|
/**
|
|
80
82
|
* Chat members count, for groups, supergroups and channels only.
|
|
81
83
|
*/
|
|
@@ -169,6 +169,10 @@ class FullChat extends Chat {
|
|
|
169
169
|
return 0;
|
|
170
170
|
return this.fullPeer?.boostsUnrestrict ?? 0;
|
|
171
171
|
}
|
|
172
|
+
/** Whether the current user can view Telegram Stars revenue for this chat */
|
|
173
|
+
get canViewStarsRevenue() {
|
|
174
|
+
return this.fullPeer._ === 'channelFull' && this.fullPeer.canViewStats;
|
|
175
|
+
}
|
|
172
176
|
/**
|
|
173
177
|
* Chat members count, for groups, supergroups and channels only.
|
|
174
178
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"full-chat.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/peers/full-chat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE7C;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI;IAGjB;IAFb,YACI,IAA+B,EACtB,QAA2C;QAEpD,KAAK,CAAC,IAAI,CAAC,CAAA;QAFF,aAAQ,GAAR,QAAQ,CAAmC;IAGxD,CAAC;IAED,gBAAgB;IAChB,MAAM,CAAC,MAAM,CAAC,IAAqD;QAC/D,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAEnC,IAAI,IAAI,CAAC,CAAC,KAAK,gBAAgB,EAAE,CAAC;YAC9B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAA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AAC,KAAK,iBAAiB,EAAE,CAAC;YACzG,OAAO,IAAI,CAAA;QACf,CAAC;QAED,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;IACnD,CAAC;IAEO,WAAW,CAAO;IAC1B;;;;;OAKG;IACH,IAAI,UAAU;QACV,OAAO,IAAI,CAAC,WAAW,IAAI,IAAI,CAAA;IACnC,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACT,OAAO,IAAI,CAAC,QAAQ,EAAE,SAAS,IAAI,IAAI,CAAA;IAC3C,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACR,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,UAAU;YAAE,OAAO,IAAI,CAAA;QAEjE,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7C,CAAC;CACJ;AAED,cAAc,CAAC,QAAQ,EAAE;IACrB,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;IACb,UAAU;IACV,YAAY;IACZ,UAAU;IACV,UAAU;CACb,CAAC,CAAA;AACF,eAAe,CAAC,QAAQ,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../types/errors.js'\nimport { makeInspectable } from '../../utils/inspectable.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Photo } from '../media/photo.js'\nimport { StickerSet } from '../misc/sticker-set.js'\nimport { BusinessAccount } from '../premium/business-account.js'\nimport { Chat } from './chat.js'\nimport { ChatInviteLink } from './chat-invite-link.js'\nimport { ChatLocation } from './chat-location.js'\nimport { PeersIndex } from './peers-index.js'\n\n/**\n * Complete information about a particular chat.\n */\nexport class FullChat extends Chat {\n constructor(\n peer: tl.TypeUser | tl.TypeChat,\n readonly fullPeer: tl.TypeUserFull | tl.TypeChatFull,\n ) {\n super(peer)\n }\n\n /** @internal */\n static _parse(full: tl.messages.RawChatFull | tl.users.TypeUserFull): FullChat {\n const peers = PeersIndex.from(full)\n\n if (full._ === 'users.userFull') {\n const { fullUser } = full\n const user = peers.user(full.fullUser.id)\n\n if (!user || user._ === 'userEmpty') {\n throw new MtTypeAssertionError('Chat._parseFull', 'user', user?._ ?? 'undefined')\n }\n\n const ret = new FullChat(user, fullUser)\n\n if (fullUser.personalChannelId) {\n ret._linkedChat = new Chat(peers.chat(fullUser.personalChannelId))\n }\n\n return ret\n }\n\n const { fullChat } = full\n\n const ret = new FullChat(peers.chat(fullChat.id), fullChat)\n\n if (fullChat._ === 'channelFull' && fullChat.linkedChatId) {\n ret._linkedChat = new Chat(peers.chat(fullChat.linkedChatId))\n }\n\n return ret\n }\n\n /**\n * Whether this chat (user) has restricted sending them voice/video messages.\n */\n get hasBlockedVoices(): boolean {\n return this.fullPeer?._ === 'userFull' && this.fullPeer.voiceMessagesForbidden!\n }\n\n /**\n * Full information about this chat's photo, if any.\n *\n * Unlike {@link Chat.photo}, this field contains additional information\n * about the photo, such as its date, more sizes, and is the only\n * way to get the animated profile photo.\n *\n * This field takes into account any personal/fallback photo\n * that the user may have set\n */\n get fullPhoto(): Photo | null {\n if (!this.fullPeer) return null\n\n let photo: tl.TypePhoto | undefined = undefined\n\n switch (this.fullPeer._) {\n case 'userFull':\n photo = this.fullPeer.personalPhoto ?? this.fullPeer.profilePhoto ?? this.fullPeer.fallbackPhoto\n break\n case 'chatFull':\n case 'channelFull':\n photo = this.fullPeer.chatPhoto\n }\n\n if (photo?._ !== 'photo') return null\n\n return new Photo(photo)\n }\n\n /**\n * A custom photo (set by the current user) that should be displayed\n * instead of the actual chat photo.\n *\n * Currently only available for users.\n */\n get personalPhoto(): Photo | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n if (this.fullPeer.personalPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.personalPhoto)\n }\n\n /**\n * Actual profile photo of the user, bypassing the custom one.\n */\n get realPhoto(): Photo | null {\n if (!this.fullPeer) return null\n if (this.fullPeer._ !== 'userFull') return this.fullPhoto\n if (this.fullPeer.personalPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.personalPhoto)\n }\n\n /**\n * A photo that the user has set to be shown\n * in case their actual profile photo is not available\n * due to privacy settings.\n *\n * Currently only available for users.\n */\n get publicPhoto(): Photo | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n if (this.fullPeer.fallbackPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.fallbackPhoto)\n }\n\n /**\n * Bio of the other party in a private chat, or description of a\n * group, supergroup or channel.\n */\n get bio(): string | null {\n return this.fullPeer?.about ?? null\n }\n\n /**\n * Chat's primary invite link, for groups, supergroups and channels.\n */\n get inviteLink(): ChatInviteLink | null {\n if (this.fullPeer && this.fullPeer._ !== 'userFull') {\n switch (this.fullPeer.exportedInvite?._) {\n case 'chatInvitePublicJoinRequests':\n return null\n case 'chatInviteExported':\n return new ChatInviteLink(this.fullPeer.exportedInvite)\n }\n }\n\n return null\n }\n\n /**\n * For supergroups, information about the group sticker set.\n */\n get stickerSet(): StickerSet | null {\n if (this.fullPeer?._ !== 'channelFull' || !this.fullPeer.stickerset) return null\n\n return new StickerSet(this.fullPeer.stickerset)\n }\n\n /**\n * For supergroups, information about the group emoji set.\n */\n get emojiSet(): StickerSet | null {\n if (this.fullPeer?._ !== 'channelFull' || !this.fullPeer.emojiset) return null\n\n return new StickerSet(this.fullPeer.emojiset)\n }\n\n /**\n * Whether the group sticker set can be changed by you.\n */\n get canSetStickerSet(): boolean | null {\n return this.fullPeer && this.fullPeer._ === 'channelFull' ? this.fullPeer.canSetStickers ?? null : null\n }\n\n /**\n * Number of boosts applied by the current user to this chat.\n */\n get boostsApplied(): number {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull') return 0\n\n return this.fullPeer?.boostsApplied ?? 0\n }\n\n /**\n * Number of boosts required for the user to be unrestricted in this chat.\n */\n get boostsForUnrestrict(): number {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull') return 0\n\n return this.fullPeer?.boostsUnrestrict ?? 0\n }\n\n /**\n * Chat members count, for groups, supergroups and channels only.\n */\n get membersCount(): number | null {\n switch (this.fullPeer._) {\n case 'userFull':\n return null\n case 'chatFull':\n if (this.fullPeer.participants._ !== 'chatParticipants') {\n return null\n }\n\n return this.fullPeer.participants.participants.length\n case 'channelFull':\n return this.fullPeer.participantsCount ?? null\n }\n }\n\n /**\n * Location of the chat.\n */\n get location(): ChatLocation | null {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull' || this.fullPeer.location?._ !== 'channelLocation') {\n return null\n }\n\n return new ChatLocation(this.fullPeer.location)\n }\n\n private _linkedChat?: Chat\n /**\n * Information about a linked chat:\n * - for channels: the discussion group\n * - for supergroups: the linked channel\n * - for users: the personal channel\n */\n get linkedChat(): Chat | null {\n return this._linkedChat ?? null\n }\n\n /**\n * TTL of all messages in this chat, in seconds\n */\n get ttlPeriod(): number | null {\n return this.fullPeer?.ttlPeriod ?? null\n }\n\n /**\n * If this is a business account, information about the business.\n */\n get business(): BusinessAccount | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n\n return new BusinessAccount(this.fullPeer)\n }\n}\n\nmemoizeGetters(FullChat, [\n 'fullPhoto',\n 'personalPhoto',\n 'realPhoto',\n 'publicPhoto',\n 'location',\n 'stickerSet',\n 'emojiSet',\n 'business',\n])\nmakeInspectable(FullChat)\n"]}
|
|
1
|
+
{"version":3,"file":"full-chat.js","sourceRoot":"","sources":["../../../../../src/highlevel/types/peers/full-chat.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAE,UAAU,E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CAAC,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,UAAU;YAAE,OAAO,IAAI,CAAA;QAEjE,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7C,CAAC;CACJ;AAED,cAAc,CAAC,QAAQ,EAAE;IACrB,WAAW;IACX,eAAe;IACf,WAAW;IACX,aAAa;IACb,UAAU;IACV,YAAY;IACZ,UAAU;IACV,UAAU;CACb,CAAC,CAAA;AACF,eAAe,CAAC,QAAQ,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../types/errors.js'\nimport { makeInspectable } from '../../utils/inspectable.js'\nimport { memoizeGetters } from '../../utils/memoize.js'\nimport { Photo } from '../media/photo.js'\nimport { StickerSet } from '../misc/sticker-set.js'\nimport { BusinessAccount } from '../premium/business-account.js'\nimport { Chat } from './chat.js'\nimport { ChatInviteLink } from './chat-invite-link.js'\nimport { ChatLocation } from './chat-location.js'\nimport { PeersIndex } from './peers-index.js'\n\n/**\n * Complete information about a particular chat.\n */\nexport class FullChat extends Chat {\n constructor(\n peer: tl.TypeUser | tl.TypeChat,\n readonly fullPeer: tl.TypeUserFull | tl.TypeChatFull,\n ) {\n super(peer)\n }\n\n /** @internal */\n static _parse(full: tl.messages.RawChatFull | tl.users.TypeUserFull): FullChat {\n const peers = PeersIndex.from(full)\n\n if (full._ === 'users.userFull') {\n const { fullUser } = full\n const user = peers.user(full.fullUser.id)\n\n if (!user || user._ === 'userEmpty') {\n throw new MtTypeAssertionError('Chat._parseFull', 'user', user?._ ?? 'undefined')\n }\n\n const ret = new FullChat(user, fullUser)\n\n if (fullUser.personalChannelId) {\n ret._linkedChat = new Chat(peers.chat(fullUser.personalChannelId))\n }\n\n return ret\n }\n\n const { fullChat } = full\n\n const ret = new FullChat(peers.chat(fullChat.id), fullChat)\n\n if (fullChat._ === 'channelFull' && fullChat.linkedChatId) {\n ret._linkedChat = new Chat(peers.chat(fullChat.linkedChatId))\n }\n\n return ret\n }\n\n /**\n * Whether this chat (user) has restricted sending them voice/video messages.\n */\n get hasBlockedVoices(): boolean {\n return this.fullPeer?._ === 'userFull' && this.fullPeer.voiceMessagesForbidden!\n }\n\n /**\n * Full information about this chat's photo, if any.\n *\n * Unlike {@link Chat.photo}, this field contains additional information\n * about the photo, such as its date, more sizes, and is the only\n * way to get the animated profile photo.\n *\n * This field takes into account any personal/fallback photo\n * that the user may have set\n */\n get fullPhoto(): Photo | null {\n if (!this.fullPeer) return null\n\n let photo: tl.TypePhoto | undefined = undefined\n\n switch (this.fullPeer._) {\n case 'userFull':\n photo = this.fullPeer.personalPhoto ?? this.fullPeer.profilePhoto ?? this.fullPeer.fallbackPhoto\n break\n case 'chatFull':\n case 'channelFull':\n photo = this.fullPeer.chatPhoto\n }\n\n if (photo?._ !== 'photo') return null\n\n return new Photo(photo)\n }\n\n /**\n * A custom photo (set by the current user) that should be displayed\n * instead of the actual chat photo.\n *\n * Currently only available for users.\n */\n get personalPhoto(): Photo | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n if (this.fullPeer.personalPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.personalPhoto)\n }\n\n /**\n * Actual profile photo of the user, bypassing the custom one.\n */\n get realPhoto(): Photo | null {\n if (!this.fullPeer) return null\n if (this.fullPeer._ !== 'userFull') return this.fullPhoto\n if (this.fullPeer.personalPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.personalPhoto)\n }\n\n /**\n * A photo that the user has set to be shown\n * in case their actual profile photo is not available\n * due to privacy settings.\n *\n * Currently only available for users.\n */\n get publicPhoto(): Photo | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n if (this.fullPeer.fallbackPhoto?._ !== 'photo') return null\n\n return new Photo(this.fullPeer.fallbackPhoto)\n }\n\n /**\n * Bio of the other party in a private chat, or description of a\n * group, supergroup or channel.\n */\n get bio(): string | null {\n return this.fullPeer?.about ?? null\n }\n\n /**\n * Chat's primary invite link, for groups, supergroups and channels.\n */\n get inviteLink(): ChatInviteLink | null {\n if (this.fullPeer && this.fullPeer._ !== 'userFull') {\n switch (this.fullPeer.exportedInvite?._) {\n case 'chatInvitePublicJoinRequests':\n return null\n case 'chatInviteExported':\n return new ChatInviteLink(this.fullPeer.exportedInvite)\n }\n }\n\n return null\n }\n\n /**\n * For supergroups, information about the group sticker set.\n */\n get stickerSet(): StickerSet | null {\n if (this.fullPeer?._ !== 'channelFull' || !this.fullPeer.stickerset) return null\n\n return new StickerSet(this.fullPeer.stickerset)\n }\n\n /**\n * For supergroups, information about the group emoji set.\n */\n get emojiSet(): StickerSet | null {\n if (this.fullPeer?._ !== 'channelFull' || !this.fullPeer.emojiset) return null\n\n return new StickerSet(this.fullPeer.emojiset)\n }\n\n /**\n * Whether the group sticker set can be changed by you.\n */\n get canSetStickerSet(): boolean | null {\n return this.fullPeer && this.fullPeer._ === 'channelFull' ? this.fullPeer.canSetStickers ?? null : null\n }\n\n /**\n * Number of boosts applied by the current user to this chat.\n */\n get boostsApplied(): number {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull') return 0\n\n return this.fullPeer?.boostsApplied ?? 0\n }\n\n /**\n * Number of boosts required for the user to be unrestricted in this chat.\n */\n get boostsForUnrestrict(): number {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull') return 0\n\n return this.fullPeer?.boostsUnrestrict ?? 0\n }\n\n /** Whether the current user can view Telegram Stars revenue for this chat */\n get canViewStarsRevenue(): boolean {\n return this.fullPeer._ === 'channelFull' && this.fullPeer.canViewStats!\n }\n\n /**\n * Chat members count, for groups, supergroups and channels only.\n */\n get membersCount(): number | null {\n switch (this.fullPeer._) {\n case 'userFull':\n return null\n case 'chatFull':\n if (this.fullPeer.participants._ !== 'chatParticipants') {\n return null\n }\n\n return this.fullPeer.participants.participants.length\n case 'channelFull':\n return this.fullPeer.participantsCount ?? null\n }\n }\n\n /**\n * Location of the chat.\n */\n get location(): ChatLocation | null {\n if (!this.fullPeer || this.fullPeer._ !== 'channelFull' || this.fullPeer.location?._ !== 'channelLocation') {\n return null\n }\n\n return new ChatLocation(this.fullPeer.location)\n }\n\n private _linkedChat?: Chat\n /**\n * Information about a linked chat:\n * - for channels: the discussion group\n * - for supergroups: the linked channel\n * - for users: the personal channel\n */\n get linkedChat(): Chat | null {\n return this._linkedChat ?? null\n }\n\n /**\n * TTL of all messages in this chat, in seconds\n */\n get ttlPeriod(): number | null {\n return this.fullPeer?.ttlPeriod ?? null\n }\n\n /**\n * If this is a business account, information about the business.\n */\n get business(): BusinessAccount | null {\n if (!this.fullPeer || this.fullPeer._ !== 'userFull') return null\n\n return new BusinessAccount(this.fullPeer)\n }\n}\n\nmemoizeGetters(FullChat, [\n 'fullPhoto',\n 'personalPhoto',\n 'realPhoto',\n 'publicPhoto',\n 'location',\n 'stickerSet',\n 'emojiSet',\n 'business',\n])\nmakeInspectable(FullChat)\n"]}
|
|
@@ -763,7 +763,7 @@ export class UpdatesManager {
|
|
|
763
763
|
if (!requestedDiff.has(channelId)) {
|
|
764
764
|
requestedDiff.set(channelId, this._fetchChannelDifference(channelId, fallbackPts)
|
|
765
765
|
.catch((err) => {
|
|
766
|
-
this.log.warn('error fetching difference for %d: %
|
|
766
|
+
this.log.warn('error fetching difference for %d: %e', channelId, err);
|
|
767
767
|
})
|
|
768
768
|
.then((ok) => {
|
|
769
769
|
requestedDiff.delete(channelId);
|
|
@@ -849,7 +849,7 @@ export class UpdatesManager {
|
|
|
849
849
|
this.stopLoop();
|
|
850
850
|
return;
|
|
851
851
|
}
|
|
852
|
-
this.log.warn('error fetching common difference: %
|
|
852
|
+
this.log.warn('error fetching common difference: %e', err);
|
|
853
853
|
if (tl.RpcError.is(err, 'PERSISTENT_TIMESTAMP_INVALID')) {
|
|
854
854
|
// this function never throws
|
|
855
855
|
return this._fetchUpdatesState();
|
|
@@ -976,7 +976,7 @@ export class UpdatesManager {
|
|
|
976
976
|
log.warn('cannot fetch full peer %d - unknown peer type %s', id, peer._);
|
|
977
977
|
})
|
|
978
978
|
.catch((err) => {
|
|
979
|
-
log.warn('error fetching full peer %d: %
|
|
979
|
+
log.warn('error fetching full peer %d: %e', id, err);
|
|
980
980
|
});
|
|
981
981
|
}
|
|
982
982
|
}
|