@imessaging/telegram-mtproto 0.8.1 → 0.8.2

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/telegram-mtproto",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "Telegram MTProto user-account transport for imessaging",
5
5
  "keywords": [
6
6
  "messaging",
@@ -31,7 +31,7 @@
31
31
  "test": "bun test"
32
32
  },
33
33
  "dependencies": {
34
- "@imessaging/core": "^0.8.1",
34
+ "@imessaging/core": "^0.8.2",
35
35
  "big-integer": "^1.6.52"
36
36
  },
37
37
  "peerDependencies": {
@@ -8,8 +8,10 @@ import type {
8
8
  EditableMessage,
9
9
  EditableMessageTransport,
10
10
  EditResult,
11
+ MessageReaction,
11
12
  MessageRecipient,
12
13
  OutboundMessage,
14
+ ReactionTransport,
13
15
  ResolvedPeer,
14
16
  SendResult,
15
17
  TelegramPeerStore,
@@ -89,6 +91,7 @@ export class TelegramMtprotoTransport
89
91
  EditableMessageTransport,
90
92
  ButtonPressTransport,
91
93
  IncomingMessageTransport,
94
+ ReactionTransport,
92
95
  ReadReceiptTransport,
93
96
  TypingTransport
94
97
  {
@@ -326,6 +329,29 @@ export class TelegramMtprotoTransport
326
329
  );
327
330
  }
328
331
 
332
+ async react(reaction: MessageReaction): Promise<void> {
333
+ this.assertConnected();
334
+ if (!isTelegramRecipient(reaction.recipient)) {
335
+ if (reaction.recipient.type === "email") {
336
+ throw new Error("Telegram MTProto cannot react to an email");
337
+ }
338
+ throw new Error(`Telegram MTProto cannot react to ${reaction.recipient.type}`);
339
+ }
340
+ const messageId = Number(reaction.messageId);
341
+ if (!Number.isSafeInteger(messageId) || messageId <= 0) {
342
+ throw new Error(`Telegram message id must be a positive integer: ${reaction.messageId}`);
343
+ }
344
+ const peer = await this.getInputPeer(reaction.recipient);
345
+ await this.client.invoke(
346
+ new Api.messages.SendReaction({
347
+ peer,
348
+ msgId: messageId,
349
+ reaction: reaction.emoji ? [new Api.ReactionEmoji({ emoticon: reaction.emoji })] : [],
350
+ }),
351
+ );
352
+ this.lastActivityAt = new Date();
353
+ }
354
+
329
355
  async disconnect(): Promise<void> {
330
356
  await this.client.disconnect();
331
357
  this.connected = false;