@mtkruto/node 0.0.996 → 0.0.997
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/esm/3_types.d.ts +1 -0
- package/esm/3_types.js +1 -0
- package/esm/4_constants.d.ts +1 -1
- package/esm/4_constants.js +1 -1
- package/esm/client/3_types.d.ts +1 -1
- package/esm/client/4_client.d.ts +9 -1
- package/esm/client/4_client.js +56 -5
- package/esm/types/0_chat_action.d.ts +1 -0
- package/esm/types/0_chat_action.js +1 -0
- package/package.json +1 -1
- package/script/3_types.d.ts +1 -0
- package/script/3_types.js +1 -0
- package/script/4_constants.d.ts +1 -1
- package/script/4_constants.js +1 -1
- package/script/client/3_types.d.ts +1 -1
- package/script/client/4_client.d.ts +9 -1
- package/script/client/4_client.js +56 -5
- package/script/types/0_chat_action.d.ts +1 -0
- package/script/types/0_chat_action.js +2 -0
package/esm/3_types.d.ts
CHANGED
package/esm/3_types.js
CHANGED
package/esm/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 161;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.0.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.0.997";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/esm/4_constants.js
CHANGED
|
@@ -54,7 +54,7 @@ export const PUBLIC_KEYS = Object.freeze([
|
|
|
54
54
|
export const VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
55
55
|
export const INITIAL_DC = "2-test";
|
|
56
56
|
export const LAYER = 161;
|
|
57
|
-
export const APP_VERSION = "MTKruto 0.0.
|
|
57
|
+
export const APP_VERSION = "MTKruto 0.0.997";
|
|
58
58
|
// @ts-ignore: lib
|
|
59
59
|
export const DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
60
60
|
export const LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/esm/client/3_types.d.ts
CHANGED
|
@@ -196,7 +196,7 @@ export interface SendPollParams {
|
|
|
196
196
|
*/
|
|
197
197
|
protectContent?: boolean;
|
|
198
198
|
}
|
|
199
|
-
export type ConnectionState = "
|
|
199
|
+
export type ConnectionState = "notConnected" | "updating" | "ready";
|
|
200
200
|
export type AuthorizationState = {
|
|
201
201
|
authorized: boolean;
|
|
202
202
|
};
|
package/esm/client/4_client.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MaybePromise } from "../1_utilities.js";
|
|
|
2
2
|
import { functions, ReadObject, types } from "../2_tl.js";
|
|
3
3
|
import { Storage } from "../3_storage.js";
|
|
4
4
|
import { DC } from "../3_transport.js";
|
|
5
|
-
import { Message } from "../3_types.js";
|
|
5
|
+
import { ChatAction, Message } from "../3_types.js";
|
|
6
6
|
import { With } from "./0_utilities.js";
|
|
7
7
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
8
8
|
import { AnswerCallbackQueryParams, AuthorizeUserParams, ChatID, ClientParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, Handler, ParseMode, SendMessagesParams, SendPollParams, Update } from "./3_types.js";
|
|
@@ -203,6 +203,14 @@ export declare class Client extends ClientAbstract {
|
|
|
203
203
|
* @param options The poll's options.
|
|
204
204
|
*/
|
|
205
205
|
sendPoll(chatId: ChatID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<With<Message, "poll">>;
|
|
206
|
+
/**
|
|
207
|
+
* Send a chat action.
|
|
208
|
+
*
|
|
209
|
+
* @param chatId The chat to send the chat action to.
|
|
210
|
+
* @param action The chat action.
|
|
211
|
+
* @param messageThreadId The thread to send the chat action to.
|
|
212
|
+
*/
|
|
213
|
+
sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
|
|
206
214
|
private handle;
|
|
207
215
|
use(handler: Handler): void;
|
|
208
216
|
branch(predicate: (upd: Update) => MaybePromise<boolean>, trueHandler: Handler, falseHandler: Handler): void;
|
package/esm/client/4_client.js
CHANGED
|
@@ -152,7 +152,7 @@ export class Client extends ClientAbstract {
|
|
|
152
152
|
value: ((connected) => {
|
|
153
153
|
this.connectMutex.acquire().then(async (release) => {
|
|
154
154
|
try {
|
|
155
|
-
const connectionState = connected ? "ready" : "
|
|
155
|
+
const connectionState = connected ? "ready" : "notConnected";
|
|
156
156
|
if (this.connected == connected && this.lastPropagatedConnectionState != connectionState) {
|
|
157
157
|
await this.propagateConnectionState(connectionState);
|
|
158
158
|
this.lastPropagatedConnectionState = connectionState;
|
|
@@ -216,7 +216,9 @@ export class Client extends ClientAbstract {
|
|
|
216
216
|
enumerable: true,
|
|
217
217
|
configurable: true,
|
|
218
218
|
writable: true,
|
|
219
|
-
value:
|
|
219
|
+
value: (_, n) => {
|
|
220
|
+
return n();
|
|
221
|
+
}
|
|
220
222
|
});
|
|
221
223
|
this.parseMode = params?.parseMode ?? "none";
|
|
222
224
|
this.appVersion = params?.appVersion ?? APP_VERSION;
|
|
@@ -1177,8 +1179,11 @@ export class Client extends ClientAbstract {
|
|
|
1177
1179
|
return messages;
|
|
1178
1180
|
}
|
|
1179
1181
|
async resolveSendAs(params) {
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
+
const sendAs = params?.sendAs;
|
|
1183
|
+
if (sendAs !== undefined) {
|
|
1184
|
+
await this.assertUser("sendAs");
|
|
1185
|
+
return sendAs ? await this.getInputPeer(sendAs) : undefined;
|
|
1186
|
+
}
|
|
1182
1187
|
}
|
|
1183
1188
|
/**
|
|
1184
1189
|
* Send a text message.
|
|
@@ -1583,6 +1588,52 @@ export class Client extends ClientAbstract {
|
|
|
1583
1588
|
const message = await this.updatesToMessages(chatId, result).then((v) => v[0]);
|
|
1584
1589
|
return Client.assertMsgHas(message, "poll");
|
|
1585
1590
|
}
|
|
1591
|
+
/**
|
|
1592
|
+
* Send a chat action.
|
|
1593
|
+
*
|
|
1594
|
+
* @param chatId The chat to send the chat action to.
|
|
1595
|
+
* @param action The chat action.
|
|
1596
|
+
* @param messageThreadId The thread to send the chat action to.
|
|
1597
|
+
*/
|
|
1598
|
+
async sendChatAction(chatId, action_, messageThreadId) {
|
|
1599
|
+
let action;
|
|
1600
|
+
switch (action_) {
|
|
1601
|
+
case "typing":
|
|
1602
|
+
action = new types.SendMessageTypingAction();
|
|
1603
|
+
break;
|
|
1604
|
+
case "upload_photo":
|
|
1605
|
+
action = new types.SendMessageUploadPhotoAction({ progress: 0 });
|
|
1606
|
+
break;
|
|
1607
|
+
case "record_video":
|
|
1608
|
+
action = new types.SendMessageRecordVideoAction();
|
|
1609
|
+
break;
|
|
1610
|
+
case "upload_video":
|
|
1611
|
+
action = new types.SendMessageRecordVideoAction();
|
|
1612
|
+
break;
|
|
1613
|
+
case "record_voice":
|
|
1614
|
+
action = new types.SendMessageRecordAudioAction();
|
|
1615
|
+
break;
|
|
1616
|
+
case "upload_audio":
|
|
1617
|
+
action = new types.SendMessageUploadAudioAction({ progress: 0 });
|
|
1618
|
+
break;
|
|
1619
|
+
case "upload_document":
|
|
1620
|
+
action = new types.SendMessageUploadDocumentAction({ progress: 0 });
|
|
1621
|
+
break;
|
|
1622
|
+
case "choose_sticker":
|
|
1623
|
+
action = new types.SendMessageChooseStickerAction();
|
|
1624
|
+
break;
|
|
1625
|
+
case "find_location":
|
|
1626
|
+
action = new types.SendMessageGeoLocationAction();
|
|
1627
|
+
break;
|
|
1628
|
+
case "record_video_note":
|
|
1629
|
+
action = new types.SendMessageRecordRoundAction();
|
|
1630
|
+
break;
|
|
1631
|
+
case "upload_video_note":
|
|
1632
|
+
action = new types.SendMessageUploadRoundAction({ progress: 0 });
|
|
1633
|
+
break;
|
|
1634
|
+
}
|
|
1635
|
+
await this.invoke(new functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
|
|
1636
|
+
}
|
|
1586
1637
|
use(handler) {
|
|
1587
1638
|
const handle = this.handle;
|
|
1588
1639
|
this.handle = async (upd, next) => {
|
|
@@ -1606,7 +1657,7 @@ export class Client extends ClientAbstract {
|
|
|
1606
1657
|
});
|
|
1607
1658
|
}
|
|
1608
1659
|
filter(predicate, handler) {
|
|
1609
|
-
this.branch(predicate, handler,
|
|
1660
|
+
this.branch(predicate, handler, (_, n) => n());
|
|
1610
1661
|
}
|
|
1611
1662
|
on(filter, handler) {
|
|
1612
1663
|
const type = typeof filter === "string" ? filter : filter[0];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ChatAction = "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_audio" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
package/script/3_types.d.ts
CHANGED
package/script/3_types.js
CHANGED
|
@@ -16,6 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./types/!0_file_id.js"), exports);
|
|
18
18
|
__exportStar(require("./types/0_audio.js"), exports);
|
|
19
|
+
__exportStar(require("./types/0_chat_action.js"), exports);
|
|
19
20
|
__exportStar(require("./types/0_chat_administrator_rights.js"), exports);
|
|
20
21
|
__exportStar(require("./types/0_chat_photo.js"), exports);
|
|
21
22
|
__exportStar(require("./types/0_contact.js"), exports);
|
package/script/4_constants.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const PUBLIC_KEYS: PublicKeys;
|
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
7
|
export declare const LAYER = 161;
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.0.
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.0.997";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -80,7 +80,7 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
81
|
exports.INITIAL_DC = "2-test";
|
|
82
82
|
exports.LAYER = 161;
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.0.
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.0.997";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
|
@@ -196,7 +196,7 @@ export interface SendPollParams {
|
|
|
196
196
|
*/
|
|
197
197
|
protectContent?: boolean;
|
|
198
198
|
}
|
|
199
|
-
export type ConnectionState = "
|
|
199
|
+
export type ConnectionState = "notConnected" | "updating" | "ready";
|
|
200
200
|
export type AuthorizationState = {
|
|
201
201
|
authorized: boolean;
|
|
202
202
|
};
|
|
@@ -2,7 +2,7 @@ import { MaybePromise } from "../1_utilities.js";
|
|
|
2
2
|
import { functions, ReadObject, types } from "../2_tl.js";
|
|
3
3
|
import { Storage } from "../3_storage.js";
|
|
4
4
|
import { DC } from "../3_transport.js";
|
|
5
|
-
import { Message } from "../3_types.js";
|
|
5
|
+
import { ChatAction, Message } from "../3_types.js";
|
|
6
6
|
import { With } from "./0_utilities.js";
|
|
7
7
|
import { ClientAbstract } from "./1_client_abstract.js";
|
|
8
8
|
import { AnswerCallbackQueryParams, AuthorizeUserParams, ChatID, ClientParams, EditMessageParams, FilterableUpdates, FilterUpdate, ForwardMessagesParams, Handler, ParseMode, SendMessagesParams, SendPollParams, Update } from "./3_types.js";
|
|
@@ -203,6 +203,14 @@ export declare class Client extends ClientAbstract {
|
|
|
203
203
|
* @param options The poll's options.
|
|
204
204
|
*/
|
|
205
205
|
sendPoll(chatId: ChatID, question: string, options: [string, string, ...string[]], params?: SendPollParams): Promise<With<Message, "poll">>;
|
|
206
|
+
/**
|
|
207
|
+
* Send a chat action.
|
|
208
|
+
*
|
|
209
|
+
* @param chatId The chat to send the chat action to.
|
|
210
|
+
* @param action The chat action.
|
|
211
|
+
* @param messageThreadId The thread to send the chat action to.
|
|
212
|
+
*/
|
|
213
|
+
sendChatAction(chatId: ChatID, action_: ChatAction, messageThreadId?: number): Promise<void>;
|
|
206
214
|
private handle;
|
|
207
215
|
use(handler: Handler): void;
|
|
208
216
|
branch(predicate: (upd: Update) => MaybePromise<boolean>, trueHandler: Handler, falseHandler: Handler): void;
|
|
@@ -155,7 +155,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
155
155
|
value: ((connected) => {
|
|
156
156
|
this.connectMutex.acquire().then(async (release) => {
|
|
157
157
|
try {
|
|
158
|
-
const connectionState = connected ? "ready" : "
|
|
158
|
+
const connectionState = connected ? "ready" : "notConnected";
|
|
159
159
|
if (this.connected == connected && this.lastPropagatedConnectionState != connectionState) {
|
|
160
160
|
await this.propagateConnectionState(connectionState);
|
|
161
161
|
this.lastPropagatedConnectionState = connectionState;
|
|
@@ -219,7 +219,9 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
219
219
|
enumerable: true,
|
|
220
220
|
configurable: true,
|
|
221
221
|
writable: true,
|
|
222
|
-
value:
|
|
222
|
+
value: (_, n) => {
|
|
223
|
+
return n();
|
|
224
|
+
}
|
|
223
225
|
});
|
|
224
226
|
this.parseMode = params?.parseMode ?? "none";
|
|
225
227
|
this.appVersion = params?.appVersion ?? _4_constants_js_1.APP_VERSION;
|
|
@@ -1180,8 +1182,11 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1180
1182
|
return messages;
|
|
1181
1183
|
}
|
|
1182
1184
|
async resolveSendAs(params) {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
+
const sendAs = params?.sendAs;
|
|
1186
|
+
if (sendAs !== undefined) {
|
|
1187
|
+
await this.assertUser("sendAs");
|
|
1188
|
+
return sendAs ? await this.getInputPeer(sendAs) : undefined;
|
|
1189
|
+
}
|
|
1185
1190
|
}
|
|
1186
1191
|
/**
|
|
1187
1192
|
* Send a text message.
|
|
@@ -1586,6 +1591,52 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1586
1591
|
const message = await this.updatesToMessages(chatId, result).then((v) => v[0]);
|
|
1587
1592
|
return Client.assertMsgHas(message, "poll");
|
|
1588
1593
|
}
|
|
1594
|
+
/**
|
|
1595
|
+
* Send a chat action.
|
|
1596
|
+
*
|
|
1597
|
+
* @param chatId The chat to send the chat action to.
|
|
1598
|
+
* @param action The chat action.
|
|
1599
|
+
* @param messageThreadId The thread to send the chat action to.
|
|
1600
|
+
*/
|
|
1601
|
+
async sendChatAction(chatId, action_, messageThreadId) {
|
|
1602
|
+
let action;
|
|
1603
|
+
switch (action_) {
|
|
1604
|
+
case "typing":
|
|
1605
|
+
action = new _2_tl_js_1.types.SendMessageTypingAction();
|
|
1606
|
+
break;
|
|
1607
|
+
case "upload_photo":
|
|
1608
|
+
action = new _2_tl_js_1.types.SendMessageUploadPhotoAction({ progress: 0 });
|
|
1609
|
+
break;
|
|
1610
|
+
case "record_video":
|
|
1611
|
+
action = new _2_tl_js_1.types.SendMessageRecordVideoAction();
|
|
1612
|
+
break;
|
|
1613
|
+
case "upload_video":
|
|
1614
|
+
action = new _2_tl_js_1.types.SendMessageRecordVideoAction();
|
|
1615
|
+
break;
|
|
1616
|
+
case "record_voice":
|
|
1617
|
+
action = new _2_tl_js_1.types.SendMessageRecordAudioAction();
|
|
1618
|
+
break;
|
|
1619
|
+
case "upload_audio":
|
|
1620
|
+
action = new _2_tl_js_1.types.SendMessageUploadAudioAction({ progress: 0 });
|
|
1621
|
+
break;
|
|
1622
|
+
case "upload_document":
|
|
1623
|
+
action = new _2_tl_js_1.types.SendMessageUploadDocumentAction({ progress: 0 });
|
|
1624
|
+
break;
|
|
1625
|
+
case "choose_sticker":
|
|
1626
|
+
action = new _2_tl_js_1.types.SendMessageChooseStickerAction();
|
|
1627
|
+
break;
|
|
1628
|
+
case "find_location":
|
|
1629
|
+
action = new _2_tl_js_1.types.SendMessageGeoLocationAction();
|
|
1630
|
+
break;
|
|
1631
|
+
case "record_video_note":
|
|
1632
|
+
action = new _2_tl_js_1.types.SendMessageRecordRoundAction();
|
|
1633
|
+
break;
|
|
1634
|
+
case "upload_video_note":
|
|
1635
|
+
action = new _2_tl_js_1.types.SendMessageUploadRoundAction({ progress: 0 });
|
|
1636
|
+
break;
|
|
1637
|
+
}
|
|
1638
|
+
await this.invoke(new _2_tl_js_1.functions.MessagesSetTyping({ peer: await this.getInputPeer(chatId), action, topMsgId: messageThreadId }));
|
|
1639
|
+
}
|
|
1589
1640
|
use(handler) {
|
|
1590
1641
|
const handle = this.handle;
|
|
1591
1642
|
this.handle = async (upd, next) => {
|
|
@@ -1609,7 +1660,7 @@ class Client extends _1_client_abstract_js_1.ClientAbstract {
|
|
|
1609
1660
|
});
|
|
1610
1661
|
}
|
|
1611
1662
|
filter(predicate, handler) {
|
|
1612
|
-
this.branch(predicate, handler,
|
|
1663
|
+
this.branch(predicate, handler, (_, n) => n());
|
|
1613
1664
|
}
|
|
1614
1665
|
on(filter, handler) {
|
|
1615
1666
|
const type = typeof filter === "string" ? filter : filter[0];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ChatAction = "typing" | "upload_photo" | "record_video" | "upload_video" | "record_voice" | "upload_audio" | "upload_document" | "choose_sticker" | "find_location" | "record_video_note" | "upload_video_note";
|