tdjson
Version:
TypeScript types for libtdjson.so
1,090 lines • 446 kB
JavaScript
"use strict";
/* eslint-disable @typescript-eslint/no-unsafe-return */
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tdjson = void 0;
var Tdjson = /** @class */ (function () {
function Tdjson() {
}
/**
Returns the current authorization state. This is an offline method. For informational purposes only. Use
updateAuthorizationState instead to maintain the current authorization state. Can be called before initialization.
*/
Tdjson.prototype.getAuthorizationState = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getAuthorizationState',
})];
});
});
};
/**
Sets the parameters for TDLib initialization. Works only when the current authorization state is
authorizationStateWaitTdlibParameters.
*/
Tdjson.prototype.setTdlibParameters = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setTdlibParameters' }))];
});
});
};
/**
Sets the phone number of the user and sends an authentication code to the user. Works only when the current
authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current
authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress,
authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or
authorizationStateWaitPassword.
*/
Tdjson.prototype.setAuthenticationPhoneNumber = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setAuthenticationPhoneNumber' }))];
});
});
};
/**
Checks whether an in-store purchase of Telegram Premium is possible before authorization. Works only when the current
authorization state is authorizationStateWaitPremiumPurchase.
*/
Tdjson.prototype.checkAuthenticationPremiumPurchase = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationPremiumPurchase' }))];
});
});
};
/**
Informs server about an in-store purchase of Telegram Premium before authorization. Works only when the current
authorization state is authorizationStateWaitPremiumPurchase.
*/
Tdjson.prototype.setAuthenticationPremiumPurchaseTransaction = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setAuthenticationPremiumPurchaseTransaction' }))];
});
});
};
/**
Sets the email address of the user and sends an authentication code to the email address. Works only when the current
authorization state is authorizationStateWaitEmailAddress.
*/
Tdjson.prototype.setAuthenticationEmailAddress = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setAuthenticationEmailAddress' }))];
});
});
};
/**
Resends an authentication code to the user. Works only when the current authorization state is
authorizationStateWaitCode, the next_code_type of the result is not null and the server-specified timeout has passed, or
when the current authorization state is authorizationStateWaitEmailCode.
*/
Tdjson.prototype.resendAuthenticationCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'resendAuthenticationCode' }))];
});
});
};
/**
Checks the authentication of an email address. Works only when the current authorization state is
authorizationStateWaitEmailCode.
*/
Tdjson.prototype.checkAuthenticationEmailCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationEmailCode' }))];
});
});
};
/**
Checks the authentication code. Works only when the current authorization state is authorizationStateWaitCode.
*/
Tdjson.prototype.checkAuthenticationCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationCode' }))];
});
});
};
/**
Requests QR code authentication by scanning a QR code on another logged in device. Works only when the current
authorization state is authorizationStateWaitPhoneNumber, or if there is no pending authentication query and the current
authorization state is authorizationStateWaitPremiumPurchase, authorizationStateWaitEmailAddress,
authorizationStateWaitEmailCode, authorizationStateWaitCode, authorizationStateWaitRegistration, or
authorizationStateWaitPassword.
*/
Tdjson.prototype.requestQrCodeAuthentication = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'requestQrCodeAuthentication' }))];
});
});
};
/**
Finishes user registration. Works only when the current authorization state is authorizationStateWaitRegistration.
*/
Tdjson.prototype.registerUser = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'registerUser' }))];
});
});
};
/**
Resets the login email address. May return an error with a message "TASK_ALREADY_EXISTS" if reset is still pending.
Works only when the current authorization state is authorizationStateWaitEmailCode and
authorization_state.can_reset_email_address == true.
*/
Tdjson.prototype.resetAuthenticationEmailAddress = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'resetAuthenticationEmailAddress',
})];
});
});
};
/**
Checks the 2-step verification password for correctness. Works only when the current authorization state is
authorizationStateWaitPassword.
*/
Tdjson.prototype.checkAuthenticationPassword = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationPassword' }))];
});
});
};
/**
Requests to send a 2-step verification password recovery code to an email address that was previously set up. Works only
when the current authorization state is authorizationStateWaitPassword.
*/
Tdjson.prototype.requestAuthenticationPasswordRecovery = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'requestAuthenticationPasswordRecovery',
})];
});
});
};
/**
Checks whether a 2-step verification password recovery code sent to an email address is valid. Works only when the
current authorization state is authorizationStateWaitPassword.
*/
Tdjson.prototype.checkAuthenticationPasswordRecoveryCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationPasswordRecoveryCode' }))];
});
});
};
/**
Recovers the 2-step verification password with a password recovery code sent to an email address that was previously set
up. Works only when the current authorization state is authorizationStateWaitPassword.
*/
Tdjson.prototype.recoverAuthenticationPassword = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'recoverAuthenticationPassword' }))];
});
});
};
/**
Sends Firebase Authentication SMS to the phone number of the user. Works only when the current authorization state is
authorizationStateWaitCode and the server returned code of the type authenticationCodeTypeFirebaseAndroid or
authenticationCodeTypeFirebaseIos.
*/
Tdjson.prototype.sendAuthenticationFirebaseSms = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'sendAuthenticationFirebaseSms' }))];
});
});
};
/**
Reports that authentication code wasn't delivered via SMS; for official mobile applications only. Works only when the
current authorization state is authorizationStateWaitCode.
*/
Tdjson.prototype.reportAuthenticationCodeMissing = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'reportAuthenticationCodeMissing' }))];
});
});
};
/**
Checks the authentication token of a bot; to log in as a bot. Works only when the current authorization state is
authorizationStateWaitPhoneNumber. Can be used instead of setAuthenticationPhoneNumber and checkAuthenticationCode to
log in.
*/
Tdjson.prototype.checkAuthenticationBotToken = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkAuthenticationBotToken' }))];
});
});
};
/**
Closes the TDLib instance after a proper logout. Requires an available network connection. All local data will be
destroyed. After the logout completes, updateAuthorizationState with authorizationStateClosed will be sent.
*/
Tdjson.prototype.logOut = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'logOut',
})];
});
});
};
/**
Closes the TDLib instance. All databases will be flushed to disk and properly closed. After the close completes,
updateAuthorizationState with authorizationStateClosed will be sent. Can be called before initialization.
*/
Tdjson.prototype.close = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'close',
})];
});
});
};
/**
Closes the TDLib instance, destroying all local data without a proper logout. The current user session will remain in
the list of all active sessions. All local data will be destroyed. After the destruction completes
updateAuthorizationState with authorizationStateClosed will be sent. Can be called before authorization.
*/
Tdjson.prototype.destroy = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'destroy',
})];
});
});
};
/**
Confirms QR code authentication on another device. Returns created session on success.
*/
Tdjson.prototype.confirmQrCodeAuthentication = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'confirmQrCodeAuthentication' }))];
});
});
};
/**
Returns all updates needed to restore current TDLib state, i.e. all actual
updateAuthorizationState/updateUser/updateNewChat and others. This is especially useful if TDLib is run in a separate
process. Can be called before initialization.
*/
Tdjson.prototype.getCurrentState = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getCurrentState',
})];
});
});
};
/**
Changes the database encryption key. Usually the encryption key is never changed and is stored in some OS keychain.
*/
Tdjson.prototype.setDatabaseEncryptionKey = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setDatabaseEncryptionKey' }))];
});
});
};
/**
Returns the current state of 2-step verification.
*/
Tdjson.prototype.getPasswordState = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getPasswordState',
})];
});
});
};
/**
Changes the 2-step verification password for the current user. If a new recovery email address is specified, then the
change will not be applied until the new recovery email address is confirmed.
*/
Tdjson.prototype.setPassword = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setPassword' }))];
});
});
};
/**
Checks whether the current user is required to set login email address.
*/
Tdjson.prototype.isLoginEmailAddressRequired = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'isLoginEmailAddressRequired',
})];
});
});
};
/**
Changes the login email address of the user. The email address can be changed only if the current user already has login
email and passwordState.login_email_address_pattern is non-empty, or the user received
suggestedActionSetLoginEmailAddress and isLoginEmailAddressRequired succeeds. The change will not be applied until the
new login email address is confirmed with checkLoginEmailAddressCode. To use Apple ID/Google ID instead of an email
address, call checkLoginEmailAddressCode directly.
*/
Tdjson.prototype.setLoginEmailAddress = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setLoginEmailAddress' }))];
});
});
};
/**
Resends the login email address verification code.
*/
Tdjson.prototype.resendLoginEmailAddressCode = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'resendLoginEmailAddressCode',
})];
});
});
};
/**
Checks the login email address authentication.
*/
Tdjson.prototype.checkLoginEmailAddressCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkLoginEmailAddressCode' }))];
});
});
};
/**
Returns a 2-step verification recovery email address that was previously set up. This method can be used to verify a
password provided by the user.
*/
Tdjson.prototype.getRecoveryEmailAddress = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getRecoveryEmailAddress' }))];
});
});
};
/**
Changes the 2-step verification recovery email address of the user. If a new recovery email address is specified, then
the change will not be applied until the new recovery email address is confirmed. If new_recovery_email_address is the
same as the email address that is currently set up, this call succeeds immediately and aborts all other requests waiting
for an email confirmation.
*/
Tdjson.prototype.setRecoveryEmailAddress = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'setRecoveryEmailAddress' }))];
});
});
};
/**
Checks the 2-step verification recovery email address verification code.
*/
Tdjson.prototype.checkRecoveryEmailAddressCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkRecoveryEmailAddressCode' }))];
});
});
};
/**
Resends the 2-step verification recovery email address verification code.
*/
Tdjson.prototype.resendRecoveryEmailAddressCode = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'resendRecoveryEmailAddressCode',
})];
});
});
};
/**
Cancels verification of the 2-step verification recovery email address.
*/
Tdjson.prototype.cancelRecoveryEmailAddressVerification = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'cancelRecoveryEmailAddressVerification',
})];
});
});
};
/**
Requests to send a 2-step verification password recovery code to an email address that was previously set up.
*/
Tdjson.prototype.requestPasswordRecovery = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'requestPasswordRecovery',
})];
});
});
};
/**
Checks whether a 2-step verification password recovery code sent to an email address is valid.
*/
Tdjson.prototype.checkPasswordRecoveryCode = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkPasswordRecoveryCode' }))];
});
});
};
/**
Recovers the 2-step verification password using a recovery code sent to an email address that was previously set up.
*/
Tdjson.prototype.recoverPassword = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'recoverPassword' }))];
});
});
};
/**
Removes 2-step verification password without previous password and access to recovery email address. The password can't
be reset immediately and the request needs to be repeated after the specified time.
*/
Tdjson.prototype.resetPassword = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'resetPassword',
})];
});
});
};
/**
Cancels reset of 2-step verification password. The method can be called if passwordState.pending_reset_date > 0.
*/
Tdjson.prototype.cancelPasswordReset = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'cancelPasswordReset',
})];
});
});
};
/**
Creates a new temporary password for processing payments.
*/
Tdjson.prototype.createTemporaryPassword = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'createTemporaryPassword' }))];
});
});
};
/**
Returns information about the current temporary password.
*/
Tdjson.prototype.getTemporaryPasswordState = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getTemporaryPasswordState',
})];
});
});
};
/**
Returns the current user.
*/
Tdjson.prototype.getMe = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getMe',
})];
});
});
};
/**
Returns information about a user by their identifier. This is an offline method if the current user is not a bot.
*/
Tdjson.prototype.getUser = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getUser' }))];
});
});
};
/**
Returns full information about a user by their identifier.
*/
Tdjson.prototype.getUserFullInfo = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getUserFullInfo' }))];
});
});
};
/**
Returns information about a basic group by its identifier. This is an offline method if the current user is not a bot.
*/
Tdjson.prototype.getBasicGroup = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getBasicGroup' }))];
});
});
};
/**
Returns full information about a basic group by its identifier.
*/
Tdjson.prototype.getBasicGroupFullInfo = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getBasicGroupFullInfo' }))];
});
});
};
/**
Returns information about a supergroup or a channel by its identifier. This is an offline method if the current user is
not a bot.
*/
Tdjson.prototype.getSupergroup = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getSupergroup' }))];
});
});
};
/**
Returns full information about a supergroup or a channel by its identifier, cached for up to 1 minute.
*/
Tdjson.prototype.getSupergroupFullInfo = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getSupergroupFullInfo' }))];
});
});
};
/**
Returns information about a secret chat by its identifier. This is an offline method.
*/
Tdjson.prototype.getSecretChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getSecretChat' }))];
});
});
};
/**
Returns information about a chat by its identifier. This is an offline method if the current user is not a bot.
*/
Tdjson.prototype.getChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getChat' }))];
});
});
};
/**
Returns information about a message. Returns a 404 error if the message doesn't exist.
*/
Tdjson.prototype.getMessage = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessage' }))];
});
});
};
/**
Returns information about a message, if it is available without sending network request. Returns a 404 error if message
isn't available locally. This is an offline method.
*/
Tdjson.prototype.getMessageLocally = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageLocally' }))];
});
});
};
/**
Returns information about a non-bundled message that is replied by a given message. Also, returns the pinned message for
messagePinMessage, the game message for messageGameScore, the invoice message for messagePaymentSuccessful, the message
with a previously set same background for messageChatSetBackground, the giveaway message for messageGiveawayCompleted,
the checklist message for messageChecklistTasksDone, messageChecklistTasksAdded, the message with suggested post
information for messageSuggestedPostApprovalFailed, messageSuggestedPostApproved, messageSuggestedPostDeclined,
messageSuggestedPostPaid, messageSuggestedPostRefunded, the message with the regular gift that was upgraded for
messageUpgradedGift with origin of the type upgradedGiftOriginUpgrade, and the topic creation message for topic messages
without non-bundled replied message. Returns a 404 error if the message doesn't exist.
*/
Tdjson.prototype.getRepliedMessage = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getRepliedMessage' }))];
});
});
};
/**
Returns information about a newest pinned message in the chat. Returns a 404 error if the message doesn't exist.
*/
Tdjson.prototype.getChatPinnedMessage = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getChatPinnedMessage' }))];
});
});
};
/**
Returns information about a message with the callback button that originated a callback query; for bots only.
*/
Tdjson.prototype.getCallbackQueryMessage = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getCallbackQueryMessage' }))];
});
});
};
/**
Returns information about messages. If a message is not found, returns null on the corresponding position of the result.
*/
Tdjson.prototype.getMessages = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessages' }))];
});
});
};
/**
Returns properties of a message. This is an offline method.
*/
Tdjson.prototype.getMessageProperties = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageProperties' }))];
});
});
};
/**
Returns information about a message thread. Can be used only if messageProperties.can_get_message_thread == true.
*/
Tdjson.prototype.getMessageThread = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageThread' }))];
});
});
};
/**
Returns read date of a recent outgoing message in a private chat. The method can be called if
messageProperties.can_get_read_date == true.
*/
Tdjson.prototype.getMessageReadDate = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageReadDate' }))];
});
});
};
/**
Returns viewers of a recent outgoing message in a basic group or a supergroup chat. For video notes and voice notes only
users, opened content of the message, are returned. The method can be called if messageProperties.can_get_viewers ==
true.
*/
Tdjson.prototype.getMessageViewers = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageViewers' }))];
});
});
};
/**
Returns information about actual author of a message sent on behalf of a channel. The method can be called if
messageProperties.can_get_author == true.
*/
Tdjson.prototype.getMessageAuthor = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getMessageAuthor' }))];
});
});
};
/**
Returns information about a file. This is an offline method.
*/
Tdjson.prototype.getFile = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getFile' }))];
});
});
};
/**
Returns information about a file by its remote identifier. This is an offline method. Can be used to register a URL as a
file for further uploading, or sending as a message. Even the request succeeds, the file can be used only if it is still
accessible to the user. For example, if the file is from a message, then the message must be not deleted and accessible
to the user. If the file database is disabled, then the corresponding object with the file must be preloaded by the
application.
*/
Tdjson.prototype.getRemoteFile = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getRemoteFile' }))];
});
});
};
/**
Loads more chats from a chat list. The loaded chats and their positions in the chat list will be sent through updates.
Chats are sorted by the pair (chat.position.order, chat.id) in descending order. Returns a 404 error if all chats have
been loaded.
*/
Tdjson.prototype.loadChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'loadChats' }))];
});
});
};
/**
Returns an ordered list of chats from the beginning of a chat list. For informational purposes only. Use loadChats and
updates processing instead to maintain chat lists in a consistent state.
*/
Tdjson.prototype.getChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getChats' }))];
});
});
};
/**
Searches a public chat by its username. Currently, only private chats, supergroups and channels can be public. Returns
the chat if found; otherwise, an error is returned.
*/
Tdjson.prototype.searchPublicChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'searchPublicChat' }))];
});
});
};
/**
Searches public chats by looking for specified query in their username and title. Currently, only private chats,
supergroups and channels can be public. Returns a meaningful number of results. Excludes private chats with contacts and
chats from the chat list from the results.
*/
Tdjson.prototype.searchPublicChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'searchPublicChats' }))];
});
});
};
/**
Searches for the specified query in the title and username of already known chats. This is an offline method. Returns
chats in the order seen in the main chat list.
*/
Tdjson.prototype.searchChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'searchChats' }))];
});
});
};
/**
Searches for the specified query in the title and username of already known chats via request to the server. Returns
chats in the order seen in the main chat list.
*/
Tdjson.prototype.searchChatsOnServer = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'searchChatsOnServer' }))];
});
});
};
/**
Returns a list of channel chats recommended to the current user.
*/
Tdjson.prototype.getRecommendedChats = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getRecommendedChats',
})];
});
});
};
/**
Returns a list of chats similar to the given chat.
*/
Tdjson.prototype.getChatSimilarChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getChatSimilarChats' }))];
});
});
};
/**
Returns approximate number of chats similar to the given chat.
*/
Tdjson.prototype.getChatSimilarChatCount = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getChatSimilarChatCount' }))];
});
});
};
/**
Informs TDLib that a chat was opened from the list of similar chats. The method is independent of openChat and closeChat
methods.
*/
Tdjson.prototype.openChatSimilarChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'openChatSimilarChat' }))];
});
});
};
/**
Returns a list of bots similar to the given bot.
*/
Tdjson.prototype.getBotSimilarBots = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getBotSimilarBots' }))];
});
});
};
/**
Returns approximate number of bots similar to the given bot.
*/
Tdjson.prototype.getBotSimilarBotCount = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getBotSimilarBotCount' }))];
});
});
};
/**
Informs TDLib that a bot was opened from the list of similar bots.
*/
Tdjson.prototype.openBotSimilarBot = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'openBotSimilarBot' }))];
});
});
};
/**
Returns a list of frequently used chats.
*/
Tdjson.prototype.getTopChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getTopChats' }))];
});
});
};
/**
Removes a chat from the list of frequently used chats. Supported only if the chat info database is enabled.
*/
Tdjson.prototype.removeTopChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'removeTopChat' }))];
});
});
};
/**
Searches for the specified query in the title and username of up to 50 recently found chats. This is an offline method.
*/
Tdjson.prototype.searchRecentlyFoundChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'searchRecentlyFoundChats' }))];
});
});
};
/**
Adds a chat to the list of recently found chats. The chat is added to the beginning of the list. If the chat is already
in the list, it will be removed from the list first.
*/
Tdjson.prototype.addRecentlyFoundChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'addRecentlyFoundChat' }))];
});
});
};
/**
Removes a chat from the list of recently found chats.
*/
Tdjson.prototype.removeRecentlyFoundChat = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'removeRecentlyFoundChat' }))];
});
});
};
/**
Clears the list of recently found chats.
*/
Tdjson.prototype.clearRecentlyFoundChats = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'clearRecentlyFoundChats',
})];
});
});
};
/**
Returns recently opened chats. This is an offline method. Returns chats in the order of last opening.
*/
Tdjson.prototype.getRecentlyOpenedChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getRecentlyOpenedChats' }))];
});
});
};
/**
Checks whether a username can be set for a chat.
*/
Tdjson.prototype.checkChatUsername = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkChatUsername' }))];
});
});
};
/**
Returns a list of public chats of the specified type, owned by the user.
*/
Tdjson.prototype.getCreatedPublicChats = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'getCreatedPublicChats' }))];
});
});
};
/**
Checks whether the maximum number of owned public chats has been reached. Returns corresponding error if the limit was
reached. The limit can be increased with Telegram Premium.
*/
Tdjson.prototype.checkCreatedPublicChatsLimit = function (options) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request(__assign(__assign({}, options), { '@type': 'checkCreatedPublicChatsLimit' }))];
});
});
};
/**
Returns a list of basic group and supergroup chats, which can be used as a discussion group for a channel. Returned
basic group chats must be first upgraded to supergroups before they can be set as a discussion group. To set a returned
supergroup as a discussion group, access to its old messages must be enabled using toggleSupergroupIsAllHistoryAvailable
first.
*/
Tdjson.prototype.getSuitableDiscussionChats = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getSuitableDiscussionChats',
})];
});
});
};
/**
Returns a list of recently inactive supergroups and channels. Can be used when user reaches limit on the number of
joined supergroups and channels and receives the error "CHANNELS_TOO_MUCH". Also, the limit can be increased with
Telegram Premium.
*/
Tdjson.prototype.getInactiveSupergroupChats = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getInactiveSupergroupChats',
})];
});
});
};
/**
Returns a list of channel chats, which can be used as a personal chat.
*/
Tdjson.prototype.getSuitablePersonalChats = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this._request({
'@type': 'getSuitablePersonalChats',
})];
});
});
};
/**
Loads more topics in a channel direct messages chat administered by the current user. The loaded topics will be sent
through updateDirectMessagesChatTopic. Topics are sorted by their topic.order in descending order. Returns a 404 error
if all topics have been loaded.
*/
Tdjson.prototype.loadDirectMessagesC