@imessaging/core 0.8.11 → 0.8.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imessaging/core",
3
- "version": "0.8.11",
3
+ "version": "0.8.12",
4
4
  "description": "Core messaging transport contracts and Telegram peer storage",
5
5
  "keywords": [
6
6
  "messaging",
package/src/index.ts CHANGED
@@ -26,6 +26,7 @@ export {
26
26
  canReceiveEdits,
27
27
  canSaveDraft,
28
28
  canShowTyping,
29
+ canTellSelf,
29
30
  hasCommandMenu,
30
31
  isTelegramRecipient,
31
32
  } from "./types";
@@ -68,6 +69,8 @@ export type {
68
69
  OutboundMessage,
69
70
  ReactionTransport,
70
71
  ResolvedPeer,
72
+ SelfAccount,
73
+ SelfAwareTransport,
71
74
  SendResult,
72
75
  TelegramPeerStore,
73
76
  TelegramRecipient,
package/src/types.ts CHANGED
@@ -470,6 +470,22 @@ export function canGetPeerInfo(transport: MessageTransport): transport is PeerIn
470
470
  return typeof (transport as PeerInfoTransport).peerInfo === "function";
471
471
  }
472
472
 
473
+ /** Учётка, под которой работает транспорт: по ней отличают свои сообщения от чужих. */
474
+ export type SelfAccount = {
475
+ id: string;
476
+ username?: string;
477
+ isBot: boolean;
478
+ };
479
+
480
+ /** Транспорт знает свою учётку. Ответ кэшируется: повторный вызов не ходит в сеть. */
481
+ export interface SelfAwareTransport extends MessageTransport {
482
+ self(): Promise<SelfAccount>;
483
+ }
484
+
485
+ export function canTellSelf(transport: MessageTransport): transport is SelfAwareTransport {
486
+ return typeof (transport as SelfAwareTransport).self === "function";
487
+ }
488
+
473
489
  /** Карточка контакта в адресной книге учётки: имя и заметка о человеке, текст заметки даёт продукт. */
474
490
  export type ContactCard = {
475
491
  userId: string;