Skip to content

Commit

Permalink
added final interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
naseif committed Feb 15, 2022
1 parent 95a1464 commit 33c9fa2
Show file tree
Hide file tree
Showing 12 changed files with 260 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/structure/TelegramAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class TelegramAPI extends EventEmitter {
async getUpdates(
options?: IUpdateOptions,
callback?: (updates: IUpdate[]) => void
) {
): Promise<IUpdate[]> {
if (!options) {
options = {};
return await this.sendRequest(this.endpoint + "getUpdates");
Expand Down
44 changes: 44 additions & 0 deletions src/types/IAudio.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { IPhotoSize } from "./IIPhotoSize";

/**
* This object represents an audio file to be treated as music by the Telegram clients.
*/

export interface IAudio {
/**
* Identifier for this file, which can be used to download or reuse the file
*/
file_id: string;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
*/
file_unique_id: string;
/**
* Duration of the audio in seconds as defined by sender
*/
duration: number;
/**
* Optional. Performer of the audio as defined by sender or by audio tags
*/
performer?: string;
/**
* Optional. Title of the audio as defined by sender or by audio tags
*/
title?: string;
/**
* Optional. Original filename as defined by sender
*/
file_name?: string;
/**
* Optional. MIME type of the file as defined by sender
*/
mime_type?: string;
/**
* Optional. File size in bytes
*/
file_size?: number;
/**
* Optional. Thumbnail of the album cover to which the music file belongs
*/
thumb?: IPhotoSize;
}
5 changes: 5 additions & 0 deletions src/types/ICallbackGame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* A placeholder, currently holds no information. Use BotFather to set up your game.
*/

export interface ICallbackGame {}
27 changes: 27 additions & 0 deletions src/types/IContact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* This object represents a phone contact.
*/

export interface IContact {
/**
* Contact's phone number
*/
phone_number: string;
/**
* Contact's first name
*/
first_name: string;
/**
* Optional. Contact's last name
*/
last_name?: string;
/**
* Optional. Contact's user identifier in Telegram. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier.
*/
user_id?: number;

/**
* Optional. Additional data about the contact in the form of a vCard
*/
vcard?: string;
}
14 changes: 14 additions & 0 deletions src/types/IDice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* This object represents an animated emoji that displays a random value.
*/

export interface IDice {
/**
* Emoji on which the dice throw animation is based
*/
emoji: string;
/**
* Value of the dice, 1-6 for “🎲”, “🎯” and “🎳” base emoji, 1-5 for “🏀” and “⚽” base emoji, 1-64 for “🎰” base emoji
*/
value: number;
}
18 changes: 18 additions & 0 deletions src/types/IEncryptedCredentials.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Contains data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes.
*/

export interface IEncryptedCredentials {
/**
* Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication
*/
data: string;
/**
* Base64-encoded data hash for data authentication
*/
hash: string;
/**
* Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption
*/
secret: string;
}
25 changes: 25 additions & 0 deletions src/types/IIPhotoSize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* This object represents one size of a photo or a file / sticker thumbnail.
*/
export interface IPhotoSize {
/**
* Identifier for this file, which can be used to download or reuse the file
*/
file_id: string;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
*/
file_unique_id: string;
/**
* Photo width
*/
width: number;
/**
* Photo height
*/
height: number;
/**
* Optional. File size in bytes
*/
file_size?: number;
}
25 changes: 25 additions & 0 deletions src/types/IInvoice.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* This object contains basic information about an invoice.
*/
export interface IInvoice {
/**
* Product name
*/
title: string;
/**
* Product description
*/
description: string;
/**
* Unique bot deep-linking parameter that can be used to generate this invoice
*/
start_parameter: string;
/**
* Three-letter ISO 4217 currency code
*/
currency: string;
/**
* Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
*/
total_amount: number;
}
21 changes: 21 additions & 0 deletions src/types/IMaskPosition.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This object describes the position on faces where a mask should be placed by default.
*/
export interface IMaskPosition {
/**
* The part of the face relative to which the mask should be placed. One of “forehead”, “eyes”, “mouth”, or “chin”.
*/
point: string;
/**
* Shift by X-axis measured in widths of the mask scaled to the face size, from left to right. For example, choosing -1.0 will place mask just to the left of the default mask position.
*/
x_shift: number;
/**
* Shift by Y-axis measured in heights of the mask scaled to the face size, from top to bottom. For example, 1.0 will place the mask just below the default mask position.
*/
y_shift: number;
/**
* Mask scaling coefficient. For example, 2.0 means double size.
*/
scale: number;
}
24 changes: 24 additions & 0 deletions src/types/IMessage.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
import { IChat } from "./IChat";
import { IMessageEntity } from "./IMessageEntity";
import { IUser } from "./IUser";
import { IAnimation } from "./IIAnimation";
import { IPhotoSize } from "./IIPhotoSize";
import { IAudio } from "./IAudio";
import { IDocument } from "./IDocument";
import { ISticker } from "./ISticker";
import { IVideo } from "./IVideo";
import { IVideoNote } from "./IVideoNote";
import { IVoice } from "./IVoice";
import { IContact } from "./IContact";
import { IDice } from "./IDice";
import { IGame } from "./IGame";
import { IPoll } from "./IPoll";
import { IVenue } from "./IVenue";
import { ILocation } from "./ILocation";
import { IMessageAutoDeleteTimerChanged } from "./IMessageAutoDeleteTimerChanged";
import { IInvoice } from "./IInvoice";
import { ISuccessfulPayment } from "./ISuccessfulPayment";
import { IPassportData } from "./IPassportData";
import { IProximityAlertTriggered } from "./IProximityAlertTriggered";
import { IVoiceChatScheduled } from "./IVoiceChatScheduled";
import { IVoiceChatStarted } from "./IVoiceChatStarted";
import { IVoiceChatEnded } from "./IVoiceChatEnded";
import { IVoiceChatParticipantsInvited } from "./IVoiceChatParticipantsInvited";
import { IInlineKeyboardMarkup } from "./IInlineKeyboardMarkup";

export type Message = (message: IMessage) => void;

Expand Down
21 changes: 21 additions & 0 deletions src/types/IPassportFile.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB.
*/
export interface IPassportFile {
/**
* Identifier for this file, which can be used to download or reuse the file
*/
file_id: string;
/**
* Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file.
*/
file_unique_id: string;
/**
* File size in bytes
*/
file_size: number;
/**
* Unix time when the file was uploaded
*/
file_date: number;
}
35 changes: 35 additions & 0 deletions src/types/ISuccessfulPayment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { IOrderInfo } from "../../dist/types/IOrderInfo";
/**
* This object contains basic information about a successful payment.
*/

export interface ISuccessfulPayment {
/**
* Three-letter ISO 4217 currency code
*/
currency: string;
/**
* Total price in the smallest units of the currency (integer, not float/double). For example, for a price of US$ 1.45 pass amount = 145. See the exp parameter in currencies.json, it shows the number of digits past the decimal point for each currency (2 for the majority of currencies).
*/
total_amount: number;
/**
* Bot specified invoice payload
*/
invoice_payload: string;
/**
* Optional. Identifier of the shipping option chosen by the user
*/
shipping_option_id?: string;
/**
* Optional. Order info provided by the user
*/
order_info?: IOrderInfo;
/**
* Telegram payment identifier
*/
telegram_payment_charge_id: string;
/**
* Provider payment identifier
*/
provider_payment_charge_id: string;
}

0 comments on commit 33c9fa2

Please sign in to comment.