New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

11te

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

11te - npm Package Compare versions

Comparing version 1.0.13 to 1.0.91

@cfworker/json-schema/dist/deep-compare-strict.d.ts

58

package.json
{
"name": "11te",
"version": "1.0.13",
"main": "lib/index.js",
"scripts": {
"prepare": "npm run build && mjs-entry src/index.ts > lib/index.mjs",
"build": "tsc --build",
"pretest": "npm run build"
},
"type": "commonjs",
"types": "./typings/index.d.ts",
"dependencies": {
"debug": "^4.3.1",
"minimist": "^1.2.5",
"module-alias": "^2.2.2",
"node-fetch": "^2.6.1",
"p-timeout": "^4.1.0",
"safe-compare": "^1.1.4",
"typegram": "^3.2.0"
},
"devDependencies": {
"@types/debug": "^4.1.5",
"@types/node": "^14.14.20",
"@types/node-fetch": "^2.5.7",
"@types/safe-compare": "^1.1.0",
"mjs-entry": "gist:de6257751f54b3c66319bae8d2a8aea0",
"typescript": "~4.2.3"
}
}
"dependencies": {
"@cfworker/web": "^1.6.5",
"dateformat": "^4.5.1",
"debug": "^4.0.1",
"esm": "^3.2.25",
"firebase-firestore-lite": "^1.0.1",
"isomorphic-unfetch": "^3.1.0",
"minimist": "^1.2.0",
"module-alias": "^2.2.2",
"node-fetch": "^2.2.0",
"sandwich-stream": "^2.0.1",
"telegram-typings": "^3.6.0"
},
"devDependencies": {
"@types/node": "^13.1.0",
"typescript": "^3.0.1"
},
"main": "telegraf.js",
"name": "11te",
"scripts": {
"t": "nodemon -r esm test.js",
"precommit": "npm run lint && npm run typecheck && npm test",
"test": "ava test/*",
"typecheck": "tsc"
},
"type": "commonjs",
"types": "./typings/index.d.ts",
"version": "1.0.91"
}
{
"compilerOptions": {
"module": "commonjs",
"composite": true,
"declaration": true,
"declarationMap": true,
"declarationDir": "typings/",
"outDir": "lib/",
"rootDir": "src/",
"target": "ES2019",
"tsBuildInfoFile": "typings/tsconfig.tsbuildinfo"
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"baseUrl": "./",
"typeRoots": [
"./typings",
"./node_modules/@types"
],
"noEmit": true
},
"typedocOptions": {
"excludeExternals": true,
"includeVersion": true,
"name": "telegraf.js",
"out": "docs/build/",
"readme": "README.md",
"theme": "docs/theme/"
},
"include": ["src/"]
}
"include": [
"typings"
]
}
/** @format */
import * as tg from './core/types/typegram';
import * as tt from './telegram-types';
import { Middleware, MiddlewareFn, MiddlewareObj } from './middleware';
import Context from './context';
declare type MaybeArray<T> = T | T[];
export declare type MaybePromise<T> = T | Promise<T>;
declare type NonemptyReadonlyArray<T> = readonly [T, ...T[]];
declare type Triggers<C> = MaybeArray<string | RegExp | ((value: string, ctx: C) => RegExpExecArray | null)>;
declare type Predicate<T> = (t: T) => boolean;
declare type AsyncPredicate<T> = (t: T) => Promise<boolean>;
declare type MatchedMiddleware<C extends Context, T extends tt.UpdateType | tt.MessageSubType = 'message' | 'channel_post'> = NonemptyReadonlyArray<Middleware<MatchedContext<C & {
match: RegExpExecArray;
}, T>>>;
/** Takes: a context type and an update type (or message subtype).
Produces: a context that has some properties required, and some undefined.
The required ones are those that are always present when the given update (or message) arrives.
The undefined ones are those that are always absent when the given update (or message) arrives. */
declare type MatchedContext<C extends Context, T extends tt.UpdateType | tt.MessageSubType> = NarrowedContext<C, MountMap[T]>;
/**
* Narrows down `C['update']` (and derived getters)
* to specific update type `U`.
*
* Used by [[`Composer`]],
* possibly useful for splitting a bot into multiple files.
*/
export declare type NarrowedContext<C extends Context, U extends tg.Update> = Context<U> & Omit<C, keyof Context>;
/**
* Maps [[`Composer.on`]]'s `updateType` to a `tt.Update` subtype.
*/
declare type MountMap = {
[T in tt.UpdateType]: Extract<tg.Update, Record<T, object>>;
} & {
[T in tt.MessageSubType]: {
message: Extract<tg.Update.MessageUpdate['message'], Record<T, unknown>>;
update_id: number;
};
};
interface GameQueryUpdate extends tg.Update.CallbackQueryUpdate {
callback_query: tg.CallbackQuery.GameShortGameCallbackQuery;
import * as tt from './telegram-types.d'
import { TelegrafContext } from './context'
type HearsTriggers<TContext> = string[] | string | RegExp | RegExp[] | ((value: string, ctx: TContext) => RegExpExecArray | null)
type BranchPredicate<TContext> = boolean | ((ctx: TContext) => boolean | Promise<boolean>)
export interface MiddlewareFn<TContext extends TelegrafContext> {
/*
next's parameter is in a contravariant position, and thus, trying to type it
prevents assigning `MiddlewareFn<ContextMessageUpdate>`
to `MiddlewareFn<CustomContext>`.
Middleware passing the parameter should be a separate type instead.
*/
(ctx: TContext, next: () => Promise<void>): void | Promise<unknown>
}
export declare class Composer<C extends Context> implements MiddlewareObj<C> {
private handler;
constructor(...fns: ReadonlyArray<Middleware<C>>);
/**
* Registers a middleware.
*/
use(...fns: ReadonlyArray<Middleware<C>>): this;
/**
* Registers middleware for handling updates
* matching given type guard function.
*/
guard<U extends tg.Update>(guardFn: (update: tg.Update) => update is U, ...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, U>>>): this;
/**
* Registers middleware for handling provided update types.
*/
on<T extends tt.UpdateType | tt.MessageSubType>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): this;
/**
* Registers middleware for handling matching text messages.
*/
hears(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'text'>): this;
/**
* Registers middleware for handling specified commands.
*/
command(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, 'text'>>>): this;
/**
* Registers middleware for handling matching callback queries.
*/
action(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'callback_query'>): this;
/**
* Registers middleware for handling matching inline queries.
*/
inlineQuery(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'inline_query'>): this;
/**
* Registers middleware for handling game queries
*/
gameQuery(...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, GameQueryUpdate>>>): this;
/**
* Registers middleware for dropping matching updates.
*/
drop(predicate: Predicate<C>): this;
filter(predicate: Predicate<C>): this;
private entity;
email(email: Triggers<C>, ...fns: MatchedMiddleware<C>): this;
url(url: Triggers<C>, ...fns: MatchedMiddleware<C>): this;
textLink(link: Triggers<C>, ...fns: MatchedMiddleware<C>): this;
textMention(mention: Triggers<C>, ...fns: MatchedMiddleware<C>): this;
mention(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C>): this;
phone(number: Triggers<C>, ...fns: MatchedMiddleware<C>): this;
hashtag(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C>): this;
cashtag(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C>): this;
/**
* Registers a middleware for handling /start
*/
start(...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, 'text'> & {
startPayload: string;
}>>): this;
/**
* Registers a middleware for handling /help
*/
help(...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, 'text'>>>): this;
/**
* Registers a middleware for handling /settings
*/
settings(...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, 'text'>>>): this;
middleware(): MiddlewareFn<C>;
static reply(...args: Parameters<Context['reply']>): MiddlewareFn<Context>;
static catch<C extends Context>(errorHandler: (err: unknown, ctx: C) => void, ...fns: ReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware that runs in the background.
*/
static fork<C extends Context>(middleware: Middleware<C>): MiddlewareFn<C>;
static tap<C extends Context>(middleware: Middleware<C>): MiddlewareFn<C>;
/**
* Generates middleware that gives up control to the next middleware.
*/
static passThru(): MiddlewareFn<Context>;
static lazy<C extends Context>(factoryFn: (ctx: C) => MaybePromise<Middleware<C>>): MiddlewareFn<C>;
static log(logFn?: (s: string) => void): MiddlewareFn<Context>;
/**
* @param trueMiddleware middleware to run if the predicate returns true
* @param falseMiddleware middleware to run if the predicate returns false
*/
static branch<C extends Context>(predicate: Predicate<C> | AsyncPredicate<C>, trueMiddleware: Middleware<C>, falseMiddleware: Middleware<C>): MiddlewareFn<C>;
/**
* Generates optional middleware.
* @param predicate predicate to decide on a context object whether to run the middleware
* @param middleware middleware to run if the predicate returns true
*/
static optional<C extends Context>(predicate: Predicate<C> | AsyncPredicate<C>, ...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
static filter<C extends Context>(predicate: Predicate<C>): MiddlewareFn<C>;
/**
* Generates middleware for dropping matching updates.
*/
static drop<C extends Context>(predicate: Predicate<C>): MiddlewareFn<C>;
static dispatch<C extends Context, Handlers extends Record<string | number | symbol, Middleware<C>>>(routeFn: (ctx: C) => MaybePromise<keyof Handlers>, handlers: Handlers): Middleware<C>;
/**
* Generates optional middleware based on a predicate that only operates on `ctx.update`.
*
* Example:
* ```ts
* import { Composer, Update } from 'telegraf'
*
* const predicate = (u): u is Update.MessageUpdate => 'message' in u
* const middleware = Composer.guard(predicate, (ctx) => {
* const message = ctx.update.message
* })
* ```
*
* Note that `Composer.mount('message')` is preferred over this.
*
* @param guardFn predicate to decide whether to run the middleware based on the `ctx.update` object
* @param fns middleware to run if the predicate returns true
* @see `Composer.optional` for a more generic version of this method that allows the predicate to operate on `ctx` itself
*/
static guard<C extends Context, U extends tg.Update>(guardFn: (u: tg.Update) => u is U, ...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, U>>>): MiddlewareFn<C>;
/**
* Generates middleware for handling provided update types.
* @deprecated use `Composer.on`
*/
static mount<C extends Context, T extends tt.UpdateType | tt.MessageSubType>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): MiddlewareFn<C>;
/**
* Generates middleware for handling provided update types.
*/
static on<C extends Context, T extends tt.UpdateType | tt.MessageSubType>(updateType: MaybeArray<T>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, T>>>): MiddlewareFn<C>;
private static entity;
static entityText<C extends Context>(entityType: MaybeArray<string>, predicate: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static email<C extends Context>(email: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static phone<C extends Context>(number: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static url<C extends Context>(url: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static textLink<C extends Context>(link: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static textMention<C extends Context>(mention: Triggers<C>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static mention<C extends Context>(mention: MaybeArray<string>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static hashtag<C extends Context>(hashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
static cashtag<C extends Context>(cashtag: MaybeArray<string>, ...fns: MatchedMiddleware<C>): MiddlewareFn<C>;
private static match;
/**
* Generates middleware for handling matching text messages.
*/
static hears<C extends Context>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'text'>): MiddlewareFn<C>;
/**
* Generates middleware for handling specified commands.
*/
static command<C extends Context>(command: MaybeArray<string>, ...fns: NonemptyReadonlyArray<Middleware<MatchedContext<C, 'text'>>>): MiddlewareFn<C>;
/**
* Generates middleware for handling matching callback queries.
*/
static action<C extends Context>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'callback_query'>): MiddlewareFn<C>;
/**
* Generates middleware for handling matching inline queries.
*/
static inlineQuery<C extends Context>(triggers: Triggers<C>, ...fns: MatchedMiddleware<C, 'inline_query'>): MiddlewareFn<C>;
/**
* Generates middleware responding only to specified users.
*/
static acl<C extends Context>(userId: MaybeArray<number>, ...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
private static memberStatus;
/**
* Generates middleware responding only to chat admins and chat creator.
*/
static admin<C extends Context>(...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware responding only to chat creator.
*/
static creator<C extends Context>(...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware running only in specified chat types.
*/
static chatType<C extends Context>(type: MaybeArray<tg.Chat['type']>, ...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware running only in private chats.
*/
static privateChat<C extends Context>(...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware running only in groups and supergroups.
*/
static groupChat<C extends Context>(...fns: NonemptyReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
/**
* Generates middleware for handling game queries.
*/
static gameQuery<C extends Context>(...fns: NonemptyReadonlyArray<Middleware<NarrowedContext<C, GameQueryUpdate>>>): MiddlewareFn<C>;
static unwrap<C extends Context>(handler: Middleware<C>): MiddlewareFn<C>;
static compose<C extends Context>(middlewares: ReadonlyArray<Middleware<C>>): MiddlewareFn<C>;
export interface MiddlewareObj<TContext extends TelegrafContext> {
middleware(): MiddlewareFn<TContext>
}
export default Composer;
//# sourceMappingURL=composer.d.ts.map
export type Middleware<TContext extends TelegrafContext> =
| MiddlewareFn<TContext>
| MiddlewareObj<TContext>
export declare class Composer<TContext extends TelegrafContext>
implements MiddlewareObj<TContext> {
/**
* Registers a middleware.
*/
use(...middlewares: ReadonlyArray<Middleware<TContext>>): this
/**
* Registers middleware for provided update type.
*/
on(
updateTypes:
| tt.UpdateType
| tt.UpdateType[]
| tt.MessageSubTypes
| tt.MessageSubTypes[],
...middlewares: ReadonlyArray<Middleware<TContext>>
): this
/**
* Return the middleware created by this Composer
*/
middleware(): MiddlewareFn<TContext>
/**
* Registers middleware for handling text messages.
*/
hears(
triggers: HearsTriggers<TContext>,
...middlewares: ReadonlyArray<Middleware<TContext>>
): this
/**
* Registers middleware for handling callbackQuery data with regular expressions
*/
action(
triggers: HearsTriggers<TContext>,
...middlewares: ReadonlyArray<Middleware<TContext>>
): this
/**
* Registers middleware for handling specified commands.
*/
command(
command: string | string[],
...middlewares: ReadonlyArray<Middleware<TContext>>
): this
/**
* Registers middleware for handling callback_data actions with game query.
*/
gameQuery(...middlewares: ReadonlyArray<Middleware<TContext>>): this
/**
* Registers middleware for handling /start command.
*/
start(...middlewares: ReadonlyArray<Middleware<TContext>>): this
/**
* Registers middleware for handling /help command.
*/
help(...middlewares: ReadonlyArray<Middleware<TContext>>): this
constructor(...middlewares: ReadonlyArray<Middleware<TContext>>)
static unwrap<TContext extends TelegrafContext>(
middleware: Middleware<TContext>
): MiddlewareFn<TContext>
/**
* Compose middlewares returning a fully valid middleware comprised of all those which are passed.
*/
static compose<TContext extends TelegrafContext>(
middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates middleware for handling provided update types.
*/
static mount<TContext extends TelegrafContext>(
updateTypes: tt.UpdateType | tt.UpdateType[],
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates middleware for handling matching text messages.
*/
static hears<TContext extends TelegrafContext>(
triggers: HearsTriggers<TContext>,
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates middleware for handling matching callback queries.
*/
static action<TContext extends TelegrafContext>(
triggers: HearsTriggers<TContext>,
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates pass thru middleware.
*/
static passThru(): MiddlewareFn<TelegrafContext>
/**
* Generates safe version of pass thru middleware.
*/
static safePassThru(): MiddlewareFn<TelegrafContext>
/**
* Generates optional middleware.
* @param middleware middleware to run if the predicate returns true
*/
static optional<TContext extends TelegrafContext>(
predicate: BranchPredicate<TContext>,
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates filter middleware.
*/
static filter<TContext extends TelegrafContext>(
predicate: BranchPredicate<TContext>
): MiddlewareFn<TContext>
/**
* Generates drop middleware.
*/
static drop<TContext extends TelegrafContext>(
predicate: BranchPredicate<TContext>
): Middleware<TContext>
/**
* @param trueMiddleware middleware to run if the predicate returns true
* @param falseMiddleware middleware to run if the predicate returns false
*/
static branch<TContext extends TelegrafContext>(
predicate: BranchPredicate<TContext>,
trueMiddleware: Middleware<TContext>,
falseMiddleware: Middleware<TContext>
): MiddlewareFn<TContext>
static reply(
text: string,
extra?: tt.ExtraReplyMessage
): MiddlewareFn<TelegrafContext>
/**
* Generates middleware that runs in the background.
*/
static fork<TContext extends TelegrafContext>(
middleware: Middleware<TContext>
): MiddlewareFn<TContext>
static log(logFn?: (s: string) => void): MiddlewareFn<TelegrafContext>
/**
* Generates middleware running only in given chat types.
*/
static chatType<TContext extends TelegrafContext>(
type: tt.ChatType | tt.ChatType[],
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates middleware running only in private chats.
*/
static privateChat<TContext extends TelegrafContext>(
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
/**
* Generates middleware running only in groups and supergroups.
*/
static groupChat<TContext extends TelegrafContext>(
...middlewares: ReadonlyArray<Middleware<TContext>>
): MiddlewareFn<TContext>
}

@@ -1,117 +0,524 @@

import * as tg from './core/types/typegram';
import * as tt from './telegram-types';
import { Deunionize, PropOr, UnionKeys } from './deunionize';
import ApiClient from './core/network/client';
import Telegram from './telegram';
declare type Tail<T> = T extends [unknown, ...infer U] ? U : never;
declare type Shorthand<FName extends Exclude<keyof Telegram, keyof ApiClient>> = Tail<Parameters<Telegram[FName]>>;
export declare class Context<U extends Deunionize<tg.Update> = tg.Update> {
readonly update: U;
readonly tg: Telegram;
readonly botInfo: tg.UserFromGetMe;
readonly state: Record<string | symbol, any>;
constructor(update: U, tg: Telegram, botInfo: tg.UserFromGetMe);
get updateType(): Extract<UnionKeys<U>, tt.UpdateType>;
get me(): string;
get telegram(): Telegram;
get message(): PropOr<U, "message", undefined>;
get editedMessage(): PropOr<U, "edited_message", undefined>;
get inlineQuery(): PropOr<U, "inline_query", undefined>;
get shippingQuery(): PropOr<U, "shipping_query", undefined>;
get preCheckoutQuery(): PropOr<U, "pre_checkout_query", undefined>;
get chosenInlineResult(): PropOr<U, "chosen_inline_result", undefined>;
get channelPost(): PropOr<U, "channel_post", undefined>;
get editedChannelPost(): PropOr<U, "edited_channel_post", undefined>;
get callbackQuery(): PropOr<U, "callback_query", undefined>;
get poll(): PropOr<U, "poll", undefined>;
get pollAnswer(): PropOr<U, "poll_answer", undefined>;
get myChatMember(): PropOr<U, "my_chat_member", undefined>;
get chatMember(): PropOr<U, "chat_member", undefined>;
get chat(): Getter<U, 'chat'>;
get senderChat(): PropOr<GetUpdateContent<U>, "sender_chat", undefined>;
get from(): PropOr<GetUpdateContent<U>, "from", undefined>;
get inlineMessageId(): string;
get passportData(): any;
/** @deprecated use `ctx.telegram.webhookReply` */
get webhookReply(): boolean;
set webhookReply(enable: boolean);
private assert;
answerInlineQuery(...args: Shorthand<'answerInlineQuery'>): Promise<true>;
answerCbQuery(...args: Shorthand<'answerCbQuery'>): Promise<true>;
answerGameQuery(...args: Shorthand<'answerGameQuery'>): Promise<true>;
answerShippingQuery(...args: Shorthand<'answerShippingQuery'>): Promise<true>;
answerPreCheckoutQuery(...args: Shorthand<'answerPreCheckoutQuery'>): Promise<true>;
editMessageText(text: string, extra?: tt.ExtraEditMessageText): Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
editMessageCaption(caption: string | undefined, extra?: tt.ExtraEditMessageCaption): Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
editMessageMedia(media: tg.InputMedia, extra?: tt.ExtraEditMessageMedia): Promise<true | (tg.Update.Edited & tg.Message.AnimationMessage) | (tg.Update.Edited & tg.Message.AudioMessage) | (tg.Update.Edited & tg.Message.DocumentMessage) | (tg.Update.Edited & tg.Message.PhotoMessage) | (tg.Update.Edited & tg.Message.VideoMessage)>;
editMessageReplyMarkup(markup: tg.InlineKeyboardMarkup | undefined): Promise<true | (tg.Update.Edited & tg.Message)>;
editMessageLiveLocation(latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
stopMessageLiveLocation(markup?: tg.InlineKeyboardMarkup): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
reply(...args: Shorthand<'sendMessage'>): Promise<tg.Message.TextMessage>;
getChat(...args: Shorthand<'getChat'>): Promise<tg.ChatFromGetChat>;
exportChatInviteLink(...args: Shorthand<'exportChatInviteLink'>): Promise<string>;
createChatInviteLink(...args: Shorthand<'createChatInviteLink'>): Promise<tg.ChatInviteLink>;
editChatInviteLink(...args: Shorthand<'editChatInviteLink'>): Promise<tg.ChatInviteLink>;
revokeChatInviteLink(...args: Shorthand<'revokeChatInviteLink'>): Promise<tg.ChatInviteLink>;
kickChatMember(...args: Shorthand<'kickChatMember'>): Promise<true>;
unbanChatMember(...args: Shorthand<'unbanChatMember'>): Promise<true>;
restrictChatMember(...args: Shorthand<'restrictChatMember'>): Promise<true>;
promoteChatMember(...args: Shorthand<'promoteChatMember'>): Promise<true>;
setChatAdministratorCustomTitle(...args: Shorthand<'setChatAdministratorCustomTitle'>): Promise<true>;
setChatPhoto(...args: Shorthand<'setChatPhoto'>): Promise<true>;
deleteChatPhoto(...args: Shorthand<'deleteChatPhoto'>): Promise<true>;
setChatTitle(...args: Shorthand<'setChatTitle'>): Promise<true>;
setChatDescription(...args: Shorthand<'setChatDescription'>): Promise<true>;
pinChatMessage(...args: Shorthand<'pinChatMessage'>): Promise<true>;
unpinChatMessage(...args: Shorthand<'unpinChatMessage'>): Promise<true>;
unpinAllChatMessages(...args: Shorthand<'unpinAllChatMessages'>): Promise<true>;
leaveChat(...args: Shorthand<'leaveChat'>): Promise<true>;
setChatPermissions(...args: Shorthand<'setChatPermissions'>): Promise<true>;
getChatAdministrators(...args: Shorthand<'getChatAdministrators'>): Promise<tg.ChatMember[]>;
getChatMember(...args: Shorthand<'getChatMember'>): Promise<tg.ChatMember>;
getChatMembersCount(...args: Shorthand<'getChatMembersCount'>): Promise<number>;
setPassportDataErrors(errors: readonly tg.PassportElementError[]): Promise<true>;
replyWithPhoto(...args: Shorthand<'sendPhoto'>): Promise<tg.Message.PhotoMessage>;
replyWithMediaGroup(...args: Shorthand<'sendMediaGroup'>): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
replyWithAudio(...args: Shorthand<'sendAudio'>): Promise<tg.Message.AudioMessage>;
replyWithDice(...args: Shorthand<'sendDice'>): Promise<tg.Message.DiceMessage>;
replyWithDocument(...args: Shorthand<'sendDocument'>): Promise<tg.Message.DocumentMessage>;
replyWithSticker(...args: Shorthand<'sendSticker'>): Promise<tg.Message.StickerMessage>;
replyWithVideo(...args: Shorthand<'sendVideo'>): Promise<tg.Message.VideoMessage>;
replyWithAnimation(...args: Shorthand<'sendAnimation'>): Promise<tg.Message.AnimationMessage>;
replyWithVideoNote(...args: Shorthand<'sendVideoNote'>): Promise<tg.Message.VideoNoteMessage>;
replyWithInvoice(...args: Shorthand<'sendInvoice'>): Promise<tg.Message.InvoiceMessage>;
replyWithGame(...args: Shorthand<'sendGame'>): Promise<tg.Message.GameMessage>;
replyWithVoice(...args: Shorthand<'sendVoice'>): Promise<tg.Message.VoiceMessage>;
replyWithPoll(...args: Shorthand<'sendPoll'>): Promise<tg.Message.PollMessage>;
replyWithQuiz(...args: Shorthand<'sendQuiz'>): Promise<tg.Message.PollMessage>;
stopPoll(...args: Shorthand<'stopPoll'>): Promise<tg.Poll>;
replyWithChatAction(...args: Shorthand<'sendChatAction'>): Promise<true>;
replyWithLocation(...args: Shorthand<'sendLocation'>): Promise<tg.Message.LocationMessage>;
replyWithVenue(...args: Shorthand<'sendVenue'>): Promise<tg.Message.VenueMessage>;
replyWithContact(...args: Shorthand<'sendContact'>): Promise<tg.Message.ContactMessage>;
getStickerSet(setName: string): Promise<tg.StickerSet>;
setChatStickerSet(setName: string): Promise<true>;
deleteChatStickerSet(): Promise<true>;
setStickerPositionInSet(sticker: string, position: number): Promise<true>;
setStickerSetThumb(...args: Parameters<Telegram['setStickerSetThumb']>): Promise<true>;
deleteStickerFromSet(sticker: string): Promise<true>;
uploadStickerFile(...args: Shorthand<'uploadStickerFile'>): Promise<tg.File>;
createNewStickerSet(...args: Shorthand<'createNewStickerSet'>): Promise<true>;
addStickerToSet(...args: Shorthand<'addStickerToSet'>): Promise<true>;
getMyCommands(): Promise<tg.BotCommand[]>;
setMyCommands(commands: readonly tg.BotCommand[]): Promise<true>;
replyWithMarkdown(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
replyWithMarkdownV2(markdown: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
replyWithHTML(html: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
deleteMessage(messageId?: number): Promise<true>;
forwardMessage(chatId: string | number, extra?: {
disable_notification?: boolean;
}): Promise<tg.Message>;
copyMessage(chatId: string | number, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
/** @format */
import * as tt from './telegram-types'
import { Telegram } from './telegram'
export declare class TelegrafContext {
updateType: tt.UpdateType
updateSubTypes: tt.MessageSubTypes[]
update: tt.Update
tg: Telegram
botInfo?: tt.User
telegram: Telegram
callbackQuery?: tt.CallbackQuery
channelPost?: tt.Message
chat?: tt.Chat
chosenInlineResult?: tt.ChosenInlineResult
editedChannelPost?: tt.Message
editedMessage?: tt.Message
from?: tt.User
inlineQuery?: tt.InlineQuery
match?: RegExpExecArray | null
me?: string
message?: tt.IncomingMessage
poll?: tt.Poll
pollAnswer?: tt.PollAnswer
preCheckoutQuery?: tt.PreCheckoutQuery
shippingQuery?: tt.ShippingQuery
constructor(
update: tt.Update,
telegram: Telegram,
options?: { username?: string }
)
/**
* Use this method to add a new sticker to a set created by the bot
* @param ownerId User identifier of sticker set owner
* @param name Sticker set name
* @param stickerData Sticker object
* @param isMasks https://github.com/telegraf/telegraf/blob/87882c42f6c2496576fdb57ca622690205c3e35e/lib/telegram.js#L304
* @returns Returns True on success.
*/
addStickerToSet(
ownerId: number,
name: string,
stickerData: tt.StickerData,
isMasks: boolean
): Promise<boolean>
/**
* Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set
* @param ownerId User identifier of created sticker set owner
* @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
* @param title Sticker set title, 1-64 characters
* @param stickerData Sticker object
* @returns Returns True on success.
*/
createNewStickerSet(
ownerId: number,
name: string,
title: string,
stickerData: tt.StickerData
): Promise<boolean>
/**
* Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* @returns True on success
*/
deleteChatPhoto(): Promise<boolean>
/**
* Use this method to delete a sticker from a set created by the bot.
* @param sticker File identifier of the sticker
* @returns Returns True on success
*/
deleteStickerFromSet(sticker: string): Promise<boolean>
/**
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* @returns exported invite link as String on success.
*/
exportChatInviteLink(): Promise<string>
/**
* Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.)
* @returns a Chat object on success.
*/
getChat(): Promise<tt.Chat>
/**
* Use this method to get a list of administrators in a chat.
* @returns On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
*/
getChatAdministrators(): Promise<Array<tt.ChatMember>>
/**
* Use this method to get information about a member of a chat.
* @param userId Unique identifier of the target user
* @returns a ChatMember object on success
*/
getChatMember(userId: number): Promise<tt.ChatMember>
/**
* Use this method to get the number of members in a chat
* @returns Number on success
*/
getChatMembersCount(): Promise<number>
/**
* Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
* @param user_id Unique identifier of the target user
* @param extra Additional params for restrict chat member
* @returns True on success
*/
restrictChatMember(
userId: number,
extra?: tt.ExtraRestrictChatMember
): Promise<boolean>
/**
* Use this method to get a sticker set
* @param setName Name of the sticker set
* @returns On success, a StickerSet object is returned.
*/
getStickerSet(setName: string): Promise<tt.StickerSet>
/**
* Use this method for your bot to leave a group, supergroup or channel
* @returns True on success
*/
leaveChat(): Promise<boolean>
/**
* Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param messageId Identifier of a message to pin
* @param extra Pass `{ disable_notification: true }`, if it is not necessary to send a notification to all group members about the new pinned message
* @returns True on success
*/
pinChatMessage(
messageId: number,
extra?: { disable_notification?: boolean }
): Promise<boolean>
/**
* Use this method to unpin a message in a group, a supergroup, or a channel.
* @returns True on success
*/
unpinChatMessage(): Promise<boolean>
/**
* Use this method to reply on messages in the same chat.
* @param text Text of the message to be sent
* @param extra SendMessage additional params
* @returns sent Message if Success
*/
reply(text: string, extra?: tt.ExtraReplyMessage): Promise<tt.Message>
/**
* Use this method to send audio files to the same chat, if you want Telegram clients to display them in the music player.
* Your audio must be in the .mp3 format.
* Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
* @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data
* @param extra Audio extra parameters
* @returns On success, the sent Message is returned.
*/
replyWithAudio(
audio: tt.InputFile,
extra?: tt.ExtraAudio
): Promise<tt.MessageAudio>
/**
* Use this method when you need to tell the user that something is happening on the bot's side.
* The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
* Choose one, depending on what the user is about to receive:
* - typing for text messages,
* - upload_photo for photos,
* - record_video or upload_video for videos,
* - record_audio or upload_audio for audio files,
* - upload_document for general files,
* - find_location for location data,
* - record_video_note or upload_video_note for video notes.
* @param action Type of action to broadcast.
* @returns True on success
*/
replyWithChatAction(action: tt.ChatAction): Promise<boolean>
/**
* Use this method to send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
* @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params for send document
* @returns a Message on success
*/
replyWithDocument(
document: tt.InputFile,
extra?: tt.ExtraDocument
): Promise<tt.MessageDocument>
/**
* Use this method to send a game
* @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
* @param extra Additional params for send game
* @returns a Message on success
*/
replyWithGame(
gameShortName: string,
extra?: tt.ExtraGame
): Promise<tt.MessageGame>
/**
* The Bot API supports basic formatting for messages
* @param html You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages.
* @param extra Additional params to send message
* @returns a Message on success
*/
replyWithHTML(html: string, extra?: tt.ExtraReplyMessage): Promise<tt.Message>
/**
* Use this method to send invoices
* @param invoice Object with new invoice params
* @param extra Additional params for send invoice
* @returns a Message on success
*/
replyWithInvoice(
invoice: tt.NewInvoiceParameters,
extra?: tt.ExtraInvoice
): Promise<tt.MessageInvoice>
/**
* Use this method to send point on the map
* @param latitude Latitude of location
* @param longitude Longitude of location
* @param extra Additional params for send location
* @returns a Message on success
*/
replyWithLocation(
latitude: number,
longitude: number,
extra?: tt.ExtraLocation
): Promise<tt.MessageLocation>
/**
* The Bot API supports basic formatting for messages
* @param markdown You can use bold and italic text, as well as inline links and pre-formatted code in your bots' messages.
* @param extra Additional params to send message
* @returns a Message on success
*/
replyWithMarkdown(
markdown: string,
extra?: tt.ExtraReplyMessage
): Promise<tt.Message>
/**
* Use this method to send photos
* @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
* @param extra Additional params to send photo
* @returns a Message on success
*/
replyWithPhoto(
photo: tt.InputFile,
extra?: tt.ExtraPhoto
): Promise<tt.MessagePhoto>
/**
* Use this method to send a group of photos or videos as an album
* @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
* @param extra Additional params to send media group
* @returns On success, an array of the sent Messages is returned
*/
replyWithMediaGroup(
media: tt.MessageMedia[],
extra?: tt.ExtraMediaGroup
): Promise<Array<tt.Message>>
/**
* Use this method to send a native poll.
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @param extra Additional params to send poll
* @returns On success, the sent Message is returned.
*/
replyWithPoll(
question: string,
options: string[],
extra: tt.ExtraPoll
): Promise<tt.MessagePoll>
/**
* Use this method to send a native quiz.
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @param extra Additional params to send quiz
* @returns On success, the sent Message is returned.
*/
replyWithQuiz(
question: string,
options: string[],
extra: tt.ExtraPoll
): Promise<tt.MessagePoll>
/**
* Use this method to send a native quiz.
* @param messageId Identifier of the original message with the poll
* @param extra Additional params to stop poll
* @returns On success, the stopped Poll with the final results is returned.
*/
stopPoll(messageId: number, extra: tt.ExtraStopPoll): Promise<tt.Poll>
/**
* Use this method to send .webp stickers
* @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params to send sticker
* @returns a Message on success
*/
replyWithSticker(
sticker: tt.InputFile,
extra?: tt.ExtraSticker
): Promise<tt.MessageSticker>
/**
* Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document)
* Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
* @param video video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data
* @param extra Additional params to send video
* @returns a Message on success
*/
replyWithVideo(
video: tt.InputFile,
extra?: tt.ExtraVideo
): Promise<tt.MessageVideo>
/**
* Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
* @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params to send voice
* @returns a Message on success
*/
replyWithVoice(
voice: tt.InputFile,
extra?: tt.ExtraVoice
): Promise<tt.MessageVoice>
/**
* Use this method to send a dice, which will have a random value from 1 to 6. On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param extra Additional params to send dice
* @returns a Message on success
*/
replyWithDice(extra?: tt.ExtraDice): Promise<tt.MessageDice>
// ------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------ //
// ------------------------------------------------------------------------------------------ //
answerCbQuery(
text?: string,
showAlert?: boolean,
extra?: object
): Promise<boolean>
/**
* Use this method to send answers to game query.
* @param url Notification text
*/
answerGameQuery(url: string): Promise<boolean>
/**
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.
* @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
* @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
* @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
*/
answerShippingQuery(
ok: boolean,
shippingOptions: tt.ShippingOption[],
errorMessage: string
): Promise<boolean>
/**
* Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query. Use this method to respond to such pre-checkout queries. On success, True is returned. Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
* @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
* @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
*/
answerPreCheckoutQuery(ok: boolean, errorMessage?: string): Promise<boolean>
/**
* Use this method to send answers to an inline query.
* No more than 50 results per query are allowed.
* @returns On success, True is returned.
* @param results Array of results for the inline query
* @param extra Extra optional parameters
*/
answerInlineQuery(
results: tt.InlineQueryResult[],
extra?: tt.ExtraAnswerInlineQuery
): Promise<boolean>
/**
* Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
* @returns On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param text New text of the message
* @param extra Extra params
*/
editMessageText(
text: string,
extra?: tt.ExtraEditMessage
): Promise<tt.Message | boolean>
/**
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param caption New caption of the message
* @param markup Markup of inline keyboard
*/
editMessageCaption(
caption?: string,
markup?: tt.InlineKeyboardMarkup
): Promise<tt.Message | boolean>
/**
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
* @returns On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param markup Markup of inline keyboard
*/
editMessageReplyMarkup(
markup?: tt.InlineKeyboardMarkup
): Promise<tt.Message | boolean>
/**
* Use this method to edit animation, audio, document, photo, or video messages.
* @returns On success, if the edited message was sent by the bot, the edited Message is returned, otherwise True is returned.
* @param media New media of message
* @param markup Markup of inline keyboard
*/
editMessageMedia(
media: tt.MessageMedia,
extra?: tt.ExtraEditMessage
): Promise<tt.Message | boolean>
/**
* Use this method to edit live location messages.
* @returns On success, if the edited message was sent by the bot, the edited message is returned, otherwise True is returned.
* @param lat New latitude
* @param lon New longitude
*/
editMessageLiveLocation(
lat: number,
lon: number,
extra?: tt.ExtraLocation
): Promise<tt.MessageLocation | boolean>
/**
* Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param userId Unique identifier of the target user
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
* @returns True on success
*/
kickChatMember(userId: number, untilDate?: number): Promise<boolean>
/**
* Use this method to unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param userId Unique identifier of the target user
* @returns True on success
*/
unbanChatMember(userId: number): Promise<boolean>
/**
* Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @returns True on success
*/
promoteChatMember(
userId: number,
extra: tt.ExtraPromoteChatMember
): Promise<boolean>
/**
* Use this method to stop updating a live location message before live_period expires.
* @returns On success, if the message was sent by the bot, the sent Message is returned, otherwise True is returned.
* @param extra Extra params
*/
stopMessageLiveLocation(
extra?: tt.ExtraLocation
): Promise<tt.MessageLocation | boolean>
/**
* Use this method to delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots granted can_post_messages permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
* @returns Returns True on success.
*/
deleteMessage(messageId?: number): Promise<boolean>
/**
* Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
* https://core.telegram.org/bots/api#sending-files
* @param ownerId User identifier of sticker file owner
* @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
* @returns Returns the uploaded File on success
*/
uploadStickerFile(
ownerId: number,
stickerFile: tt.InputFile
): Promise<tt.File>
/**
* Use this method to move a sticker in a set created by the bot to a specific position
* @param sticker File identifier of the sticker
* @param position New sticker position in the set, zero-based
* @returns Returns True on success.
*/
setStickerPositionInSet(sticker: string, position: number): Promise<boolean>
/**
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param title New chat title, 1-255 characters
* @returns True on success
*/
setChatTitle(title: string): Promise<boolean>
}
export default Context;
declare type UpdateTypes<U extends Deunionize<tg.Update>> = Extract<UnionKeys<U>, tt.UpdateType>;
export declare type GetUpdateContent<U extends tg.Update> = U extends tg.Update.CallbackQueryUpdate ? U['callback_query']['message'] : U[UpdateTypes<U>];
declare type Getter<U extends Deunionize<tg.Update>, P extends string> = PropOr<GetUpdateContent<U>, P>;
//# sourceMappingURL=context.d.ts.map

@@ -1,13 +0,11 @@

export { Telegraf } from './telegraf';
export { Context } from './context';
export { Composer, NarrowedContext } from './composer';
export { Middleware, MiddlewareFn } from './middleware';
export { Router } from './router';
export { TelegramError } from './core/network/error';
export { Telegram } from './telegram';
export * as Types from './telegram-types';
export * as Markup from './markup';
export { deunionize } from './deunionize';
export { session, MemorySessionStore } from './session';
export * as Scenes from './scenes';
//# sourceMappingURL=index.d.ts.map
/** @format */
export { BaseScene, Stage } from './stage'
export { Composer, Middleware } from './composer'
export { Extra } from './extra'
export { Markup } from './markup'
export { Router } from './router'
export { session } from './session'
export { Telegraf, Telegraf as default } from './telegraf'
export { TelegrafContext as Context } from './context'
export { Telegram } from './telegram'

@@ -1,25 +0,225 @@

import { ForceReply, InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove } from './core/types/typegram';
declare type Hideable<B> = B & {
hide?: boolean;
};
declare type HideableKBtn = Hideable<KeyboardButton>;
declare type HideableIKBtn = Hideable<InlineKeyboardButton>;
declare class Markup<T extends InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply> {
readonly reply_markup: T;
constructor(reply_markup: T);
selective<T extends ForceReply | ReplyKeyboardMarkup>(this: Markup<T>, value?: boolean): Markup<T>;
resize(this: Markup<ReplyKeyboardMarkup>, value?: boolean): Markup<ReplyKeyboardMarkup>;
oneTime(this: Markup<ReplyKeyboardMarkup>, value?: boolean): Markup<ReplyKeyboardMarkup>;
/** @format */
import * as tt from './telegram-types.d'
export interface Button {
text: string
hide: boolean
}
export * as button from './button';
export declare function removeKeyboard(): Markup<ReplyKeyboardRemove>;
export declare function forceReply(): Markup<ForceReply>;
export declare function keyboard(buttons: HideableKBtn[][]): Markup<ReplyKeyboardMarkup>;
export declare function keyboard(buttons: HideableKBtn[], options?: Partial<KeyboardBuildingOptions<HideableKBtn>>): Markup<ReplyKeyboardMarkup>;
export declare function inlineKeyboard(buttons: HideableIKBtn[][]): Markup<InlineKeyboardMarkup>;
export declare function inlineKeyboard(buttons: HideableIKBtn[], options?: Partial<KeyboardBuildingOptions<HideableIKBtn>>): Markup<InlineKeyboardMarkup>;
interface KeyboardBuildingOptions<B extends HideableKBtn | HideableIKBtn> {
wrap?: (btn: B, index: number, currentRow: B[]) => boolean;
columns: number;
export interface ContactRequestButton {
text: string
hide: boolean
request_contact: boolean
}
//# sourceMappingURL=markup.d.ts.map
export interface LocationRequestButton {
text: string
hide: boolean
request_location: boolean
}
type PollType = 'poll' | 'quiz'
export interface PollRequestButton {
text: string
request_poll: { type?: PollType }
}
export type KeyboardButton =
| Button
| ContactRequestButton
| LocationRequestButton
| PollRequestButton
| string
export interface UrlButton {
url: string
text: string
hide?: boolean
}
export interface CallbackButton {
text: string
hide: boolean
callback_data: string
}
export interface SwitchToChatButton {
text: string
hide: boolean
switch_inline_query: string
}
export interface SwitchToCurrentChatButton {
text: string
hide: boolean
switch_inline_query_current_chat: string
}
export interface GameButton {
text: string
hide: boolean
callback_game: tt.CallbackGame
}
export interface PayButton {
pay: boolean
text: string
hide: boolean
}
export interface LoginUrl {
url: string
forward_text?: string
bot_username?: string
request_write_access?: boolean
}
export interface LoginButton {
text: string
login_url: LoginUrl
hide: boolean
}
export type InlineKeyboardButton =
| UrlButton
| CallbackButton
| SwitchToChatButton
| SwitchToCurrentChatButton
| GameButton
| PayButton
| LoginButton
export interface KeyboardOptions<TBtn> {
columns?: number
wrap?(btn: TBtn, index: number, currentRow: TBtn[]): boolean
}
export declare class Markup {
forceReply(value?: boolean): this
removeKeyboard(value?: boolean): this
selective(value?: boolean): this
extra(options?: tt.ExtraReplyMessage): tt.ExtraReplyMessage
keyboard(
buttons: KeyboardButton[] | KeyboardButton[][],
options?: KeyboardOptions<KeyboardButton>
): this & tt.ReplyKeyboardMarkup
resize(value?: boolean): this
oneTime(value?: boolean): this
inlineKeyboard(
buttons: InlineKeyboardButton[] | InlineKeyboardButton[][],
options: KeyboardOptions<InlineKeyboardButton>
): this & tt.InlineKeyboardMarkup
button(text: string, hide?: boolean): Button
contactRequestButton(text: string, hide?: boolean): ContactRequestButton
locationRequestButton(text: string, hide?: boolean): LocationRequestButton
urlButton(text: string, url: string, hide?: boolean): UrlButton
callbackButton(text: string, data: string, hide?: boolean): CallbackButton
switchToChatButton(
text: string,
value: string,
hide?: boolean
): SwitchToChatButton
switchToCurrentChatButton(
text: string,
value: string,
hide?: boolean
): SwitchToCurrentChatButton
gameButton(text: string, hide?: boolean): GameButton
payButton(text: string, hide?: boolean): PayButton
loginButton(
text: string,
url: string,
opts: Omit<LoginUrl, 'url'>,
hide?: boolean
): LoginButton
static removeKeyboard(value?: string): Markup
static forceReply(value?: string): Markup
static keyboard(
buttons: KeyboardButton[] | KeyboardButton[][],
options?: KeyboardOptions<KeyboardButton>
): Markup & tt.ReplyKeyboardMarkup
static inlineKeyboard(
buttons: InlineKeyboardButton[] | InlineKeyboardButton[][],
options?: KeyboardOptions<InlineKeyboardButton>
): Markup & tt.InlineKeyboardMarkup
static resize(value?: boolean): Markup
static selective(value?: boolean): Markup
static oneTime(value?: boolean): Markup
static button(text: string, hide?: boolean): Button
static contactRequestButton(
text: string,
hide?: boolean
): ContactRequestButton
static locationRequestButton(
text: string,
hide?: boolean
): LocationRequestButton
static pollRequestButton(
text: string,
type: PollType,
hide?: boolean
): PollRequestButton
static urlButton(text: string, url: string, hide?: boolean): UrlButton
static callbackButton(
text: string,
data: string,
hide?: boolean
): CallbackButton
static switchToChatButton(
text: string,
value: string,
hide?: boolean
): SwitchToChatButton
static switchToCurrentChatButton(
text: string,
value: string,
hide?: boolean
): SwitchToCurrentChatButton
static gameButton(text: string, hide?: boolean): GameButton
static payButton(text: string, hide?: boolean): PayButton
static loginButton(
text: string,
url: string,
opts: Omit<LoginUrl, 'url'>,
hide?: boolean
): LoginButton
static formatHTML(text: string, entities: Array<tt.MessageEntity>): string
}
/** @format */
import { Middleware, MiddlewareObj } from './middleware';
import Context from './context';
declare type NonemptyReadonlyArray<T> = readonly [T, ...T[]];
declare type RouteFn<TContext extends Context> = (ctx: TContext) => {
route: string;
context?: Partial<TContext>;
state?: Partial<TContext['state']>;
} | null;
export declare class Router<C extends Context> implements MiddlewareObj<C> {
private readonly routeFn;
handlers: Map<string, Middleware<C>>;
private otherwiseHandler;
constructor(routeFn: RouteFn<C>, handlers?: Map<string, Middleware<C>>);
on(route: string, ...fns: NonemptyReadonlyArray<Middleware<C>>): this;
otherwise(...fns: NonemptyReadonlyArray<Middleware<C>>): this;
middleware(): import("./middleware").MiddlewareFn<C>;
import { MiddlewareObj, Middleware, MiddlewareFn } from './composer'
import { TelegrafContext } from './context'
type TRoute = string
type MaybePromise<T> = T | Promise<T>
export type RouteFn<TContext extends TelegrafContext> = (
ctx: TContext
) => MaybePromise<{
route?: TRoute
} | null>
type HandlersMap<TContext extends TelegrafContext> = Map<
TRoute,
Middleware<TContext>
>
declare class Router<TContext extends TelegrafContext>
implements MiddlewareObj<TContext> {
routeFn: RouteFn<TContext>
handlers: HandlersMap<TContext>
otherwiseHandler: Middleware<TContext>
constructor(routeFn: RouteFn<TContext>, handlers?: HandlersMap<TContext>)
on(
route: TRoute,
fn: Middleware<TContext>,
...fns: Middleware<TContext>[]
): this
otherwise(fn: Middleware<TContext>, ...fns: Middleware<TContext>[]): this
middleware(): MiddlewareFn<TContext>
}
export {};
//# sourceMappingURL=router.d.ts.map

@@ -1,43 +0,11 @@

import { Context } from './context';
import { MaybePromise } from './composer';
import { MiddlewareFn } from './middleware';
export interface SessionStore<T> {
get: (name: string) => MaybePromise<T | undefined>;
set: (name: string, value: T) => MaybePromise<void>;
delete: (name: string) => MaybePromise<void>;
}
interface SessionOptions<S extends object> {
getSessionKey?: (ctx: Context) => Promise<string | undefined>;
store?: SessionStore<S>;
}
export interface SessionContext<S extends object> extends Context {
session?: S;
}
/**
* Returns middleware that adds `ctx.session` for storing arbitrary state per session key.
*
* The default `getSessionKey` is <code>\`${ctx.from.id}:${ctx.chat.id}\`</code>.
* If either `ctx.from` or `ctx.chat` is `undefined`, default session key and thus `ctx.session` are also `undefined`.
*
* Session data is kept only in memory by default,
* which means that all data will be lost when the process is terminated.
* If you want to store data across restarts, or share it among workers,
* you can [install persistent session middleware from npm](https://www.npmjs.com/search?q=telegraf-session),
* or pass custom `storage`.
*
* @example https://github.com/telegraf/telegraf/blob/develop/docs/examples/session-bot.ts
* @deprecated https://github.com/telegraf/telegraf/issues/1372#issuecomment-782668499
*/
export declare function session<S extends object>(options?: SessionOptions<S>): MiddlewareFn<SessionContext<S>>;
/** @deprecated https://github.com/telegraf/telegraf/issues/1372#issuecomment-782668499 */
export declare class MemorySessionStore<T> implements SessionStore<T> {
private readonly ttl;
private readonly store;
constructor(ttl?: number);
get(name: string): T | undefined;
set(name: string, value: T): void;
delete(name: string): void;
}
export declare function isSessionContext<S extends object>(ctx: Context): ctx is SessionContext<S>;
export {};
//# sourceMappingURL=session.d.ts.map
/** @format */
import { TelegrafContext } from './context'
import { Middleware } from './composer'
export declare function session<TContext extends TelegrafContext>(opts?: {
property?: string
store?: Map<string, any>
getSessionKey?: (ctx: TContext) => string
ttl?: number
}): Middleware<TContext>

@@ -0,64 +1,217 @@

/** @format */
/// <reference types="node" />
import * as http from 'http';
import * as tg from './core/types/typegram';
import * as tt from './telegram-types';
import { Composer, MaybePromise } from './composer';
import ApiClient from './core/network/client';
import Context from './context';
import Telegram from './telegram';
import { TlsOptions } from 'tls';
export declare namespace Telegraf {
interface Options<TContext extends Context> {
contextType: new (...args: ConstructorParameters<typeof Context>) => TContext;
handlerTimeout: number;
telegram?: Partial<ApiClient.Options>;
}
interface LaunchOptions {
dropPendingUpdates?: boolean;
/** List the types of updates you want your bot to receive */
allowedUpdates?: tt.UpdateType[];
/** Configuration options for when the bot is run via webhooks */
webhook?: {
/** Public domain for webhook. If domain is not specified, hookPath should contain a domain name as well (not only path component). */
domain?: string;
/** Webhook url path; will be automatically generated if not specified */
hookPath?: string;
host?: string;
port?: number;
/** TLS server options. Omit to use http. */
tlsOptions?: TlsOptions;
cb?: http.RequestListener;
};
}
import { IncomingMessage, ServerResponse } from 'http'
import * as https from 'https'
import * as http from 'http'
import { TlsOptions } from 'tls'
import * as tt from './telegram-types.d'
import { TelegrafContext } from './context'
import { Composer } from './composer'
import { Telegram, TelegramOptions } from './telegram'
export interface TelegrafOptions {
/**
* Telegram options
*/
telegram?: TelegramOptions
/**
* Bot username
*/
username?: string
}
export declare class Telegraf<C extends Context = Context> extends Composer<C> {
private readonly options;
private webhookServer?;
private polling?;
/** Set manually to avoid implicit `getMe` call in `launch` or `webhookCallback` */
botInfo?: tg.UserFromGetMe;
telegram: Telegram;
readonly context: Partial<C>;
private handleError;
constructor(token: string, options?: Partial<Telegraf.Options<C>>);
private get token();
/** @deprecated use `ctx.telegram.webhookReply` */
set webhookReply(webhookReply: boolean);
get webhookReply(): boolean;
export interface LaunchPollingOptions {
/**
* Poll timeout in seconds
*/
timeout?: number
/**
* Limits the number of updates to be retrieved
*/
limit?: number
/**
* List the types of updates you want your bot to receive
*/
allowedUpdates?: tt.UpdateType[] | tt.UpdateType | null
/**
* Polling stop callback
*/
stopCallback?: () => void | null
}
export interface LaunchWebhookOptions {
/**
* Public domain for webhook. If domain is not specified, hookPath should contain a domain name as well (not only path component).
*/
domain?: string
/**
* Webhook url path; will be automatically generated if not specified
*/
hookPath?: string
/**
* The port to listen on for Telegram calls. If port is omitted or is 0, the operating system will assign an arbitrary unused port.
*/
port?: number
/**
* The host to listen on for Telegram calls. If host is omitted, the server will accept connections on the unspecified IPv6 address (::) when IPv6 is available, or the unspecified IPv4 address (0.0.0.0) otherwise.
*/
host?: string
/**
* TLS server options. Pass null (or omit) to use http.
*/
tlsOptions?: TlsOptions | null
/**
* A callback function suitable for the http[s].createServer() method to handle a request.
*/
cb?: (req: IncomingMessage, res: ServerResponse) => void
}
export declare class Telegraf<
TContext extends TelegrafContext
> extends Composer<TContext> {
/**
* Use this property to get/set bot token
*/
token: string
/**
* Use this property to control reply via webhook feature.
*/
webhookReply: boolean
/**
* Use this property to get telegram instance
*/
telegram: Telegram
/**
* Use this property to extend context and support your custom interface
*/
context: TContext
/**
* Telegraf options
*/
options: TOptions
/**
* Initialize new Telegraf app.
* @param token Bot token
* @param options options
* @example
* new Telegraf(token, options)
*/
constructor(token: string, options?: TelegrafOptions)
/**
* Launch bot in long-polling or webhook mode.
*
* @param options [See reference to get more]{@link https://telegraf.js.org/#/?id=launch}
*/
launch(options?: {
polling?: LaunchPollingOptions
webhook?: LaunchWebhookOptions
}): Promise<void>
/**
* Start poll updates.
* @param timeout Poll timeout in seconds
* @param limit Limits the number of updates to be retrieved
* @param allowedUpdates List the types of updates you want your bot to receive
* @param stopCallback Polling stop callback
*/
startPolling(
timeout?: number,
limit?: number,
allowedUpdates?: tt.UpdateType[] | tt.UpdateType | null,
stopCallback?: () => void | null
): Telegraf<TContext>
/**
* Start listening @ https://host:port/hookPath for Telegram calls.
* @param hookPath Webhook url path (see Telegraf.setWebhook)
* @param tlsOptions TLS server options. Pass null to use http
* @param port Port number
* @param host Hostname
* @param cb A callback function suitable for the http[s].createServer() method to handle a request.
*/
startWebhook(
hookPath: string,
tlsOptions?: TlsOptions | null,
port?: number,
host?: string,
cb?: (req: IncomingMessage, res: ServerResponse) => void
): Telegraf<TContext>
/**
* Stop Webhook and polling
*/
stop(cb?: () => void): Promise<void>
/**
* Return a callback function suitable for the http[s].createServer() method to handle a request.
* You may also use this callback function to mount your telegraf app in a Koa/Connect/Express app.
* @param hookPath Webhook url path (see Telegraf.setWebhook)
*/
webhookCallback(
hookPath: string
): (req: IncomingMessage, res: ServerResponse) => void
handleUpdates(updates: tt.Update[]): Promise<unknown[]>
/**
* Handle raw Telegram update. In case you use centralized webhook server, queue, etc.
*/
handleUpdate(
update: tt.Update,
webhookResponse?: ServerResponse
): Promise<unknown>
private fetchUpdates(): void
catch(logFn?: Function): void
}
export interface TOptions {
/**
* Telegram options
*/
telegram?: {
/**
* _Override_ error handling
* https.Agent or http.Agent instance, allows custom proxy, certificate, keep alive, etc.
*/
catch(handler: (err: unknown, ctx: C) => MaybePromise<void>): this;
webhookCallback(path?: string): (req: http.IncomingMessage, res: http.ServerResponse, next?: () => void) => Promise<void>;
private startPolling;
private startWebhook;
agent: https.Agent | http.Agent
/**
* @see https://github.com/telegraf/telegraf/discussions/1344#discussioncomment-335700
* Reply via webhook
*/
launch(config?: Telegraf.LaunchOptions): Promise<void>;
stop(reason?: string): void;
private handleUpdates;
private botInfoCall?;
handleUpdate(update: tg.Update, webhookResponse?: http.ServerResponse): Promise<void>;
webhookReply: boolean
}
/**
* Bot username
*/
username?: string
/**
* Handle `channel_post` updates as messages
*/
channelMode?: boolean
retryAfter?: number
handlerTimeout?: number
}
//# sourceMappingURL=telegraf.d.ts.map

@@ -1,50 +0,803 @@

/** @format */
import { Message, Opts, Telegram, Update } from './core/types/typegram';
import { UnionKeys } from './deunionize';
export declare type ChatAction = Opts<'sendChatAction'>['action'];
import * as TT from "telegram-typings";
export * from "telegram-typings";
export type ParseMode = 'Markdown' | 'MarkdownV2' | 'HTML'
export type ChatAction =
'typing' |
'upload_photo' |
'record_video' |
'upload_video' |
'record_audio' |
'upload_audio' |
'upload_document' |
'find_location' |
'record_video_note' |
'upload_video_note'
export type ChatType =
'private' |
'group' |
'supergroup' |
'channel'
export type UpdateType =
'callback_query' |
'channel_post' |
'chosen_inline_result' |
'edited_channel_post' |
'edited_message' |
'inline_query' |
'message' |
'pre_checkout_query' |
'shipping_query' |
'poll' |
'poll_answer'
export type MessageSubTypes =
'voice' |
'video_note' |
'video' |
'venue' |
'text' |
'supergroup_chat_created' |
'successful_payment' |
'sticker' |
'pinned_message' |
'photo' |
'new_chat_title' |
'new_chat_photo' |
'new_chat_members' |
'migrate_to_chat_id' |
'migrate_from_chat_id' |
'location' |
'left_chat_member' |
'invoice' |
'group_chat_created' |
'game' |
'document' |
'delete_chat_photo' |
'contact' |
'channel_chat_created' |
'audio' |
'passport_data' |
'connected_website' |
'animation'
export type InlineQueryResult =
TT.InlineQueryResultCachedAudio |
TT.InlineQueryResultCachedDocument |
TT.InlineQueryResultCachedGif |
TT.InlineQueryResultCachedMpeg4Gif |
TT.InlineQueryResultCachedPhoto |
TT.InlineQueryResultCachedSticker |
TT.InlineQueryResultCachedVideo |
TT.InlineQueryResultCachedVoice |
TT.InlineQueryResultArticle |
TT.InlineQueryResultAudio |
TT.InlineQueryResultContact |
TT.InlineQueryResultGame |
TT.InlineQueryResultDocument |
TT.InlineQueryResultGif |
TT.InlineQueryResultLocation |
TT.InlineQueryResultMpeg4Gif |
TT.InlineQueryResultPhoto |
TT.InlineQueryResultVenue |
TT.InlineQueryResultVideo |
TT.InlineQueryResultVoice
export type MessageMedia =
InputMediaPhoto |
InputMediaVideo |
InputMediaAnimation |
InputMediaAudio |
InputMediaDocument
export interface InputMediaPhoto {
type: string
media: InputFile
caption?: string
parse_mode?: string
}
export interface InputMediaVideo {
type: string
media: InputFile
thumb?: string | InputFile
caption?: string
parse_mode?: string
width?: number
height?: number
duration?: number
supports_streaming?: boolean
}
export interface InputMediaAnimation {
type: string
media: InputFile
thumb?: string | InputFile
caption?: string
parse_mode?: string
width?: number
height?: number
duration?: number
supports_streaming?: boolean
}
export interface InputMediaAudio {
type: string
media: InputFile
thumb?: string | InputFile
caption?: string
parse_mode?: string
performer?: string
title?: string
duration?: number
supports_streaming?: boolean
}
export interface InputMediaDocument {
type: string
media: InputFile
thumb?: string | InputFile
caption?: string
parse_mode?: string
}
export interface StickerData {
png_sticker: string | Buffer
emojis: string
mask_position: TT.MaskPosition
}
type FileId = string
export interface InputFileByPath {
source: string
}
export interface InputFileByReadableStream {
source: NodeJS.ReadableStream
}
export interface InputFileByBuffer {
source: Buffer
}
export interface InputFileByURL {
url: string
filename: string
}
export type InputFile =
FileId |
InputFileByPath |
InputFileByReadableStream |
InputFileByBuffer |
InputFileByURL
/**
* Create an `Extra*` type from the arguments of a given method `M extends keyof Telegram` but `Omit`ting fields with key `K` from it.
*
* Note that `chat_id` may not be specified in `K` because it is `Omit`ted by default.
* Sending video notes by a URL is currently unsupported
*/
declare type MakeExtra<M extends keyof Telegram, K extends keyof Omit<Opts<M>, 'chat_id'> = never> = Omit<Opts<M>, 'chat_id' | K>;
export declare type ExtraAddStickerToSet = MakeExtra<'addStickerToSet', 'name' | 'user_id'>;
export declare type ExtraAnimation = MakeExtra<'sendAnimation', 'animation'>;
export declare type ExtraAnswerCbQuery = MakeExtra<'answerCallbackQuery', 'text' | 'callback_query_id'>;
export declare type ExtraAnswerInlineQuery = MakeExtra<'answerInlineQuery', 'inline_query_id' | 'results'>;
export declare type ExtraAudio = MakeExtra<'sendAudio', 'audio'>;
export declare type ExtraContact = MakeExtra<'sendContact', 'phone_number' | 'first_name'>;
export declare type ExtraCopyMessage = MakeExtra<'copyMessage', 'from_chat_id' | 'message_id'>;
export declare type ExtraCreateChatInviteLink = MakeExtra<'createChatInviteLink'>;
export declare type ExtraCreateNewStickerSet = MakeExtra<'createNewStickerSet', 'name' | 'title' | 'user_id'>;
export declare type ExtraDice = MakeExtra<'sendDice'>;
export declare type ExtraDocument = MakeExtra<'sendDocument', 'document'>;
export declare type ExtraEditChatInviteLink = MakeExtra<'editChatInviteLink', 'invite_link'>;
export declare type ExtraEditMessageCaption = MakeExtra<'editMessageCaption', 'message_id' | 'inline_message_id' | 'caption'>;
export declare type ExtraEditMessageLiveLocation = MakeExtra<'editMessageLiveLocation', 'message_id' | 'inline_message_id' | 'latitude' | 'longitude'>;
export declare type ExtraEditMessageMedia = MakeExtra<'editMessageMedia', 'message_id' | 'inline_message_id' | 'media'>;
export declare type ExtraEditMessageText = MakeExtra<'editMessageText', 'message_id' | 'inline_message_id' | 'text'>;
export declare type ExtraGame = MakeExtra<'sendGame', 'game_short_name'>;
export declare type NewInvoiceParameters = MakeExtra<'sendInvoice', 'disable_notification' | 'reply_to_message_id' | 'allow_sending_without_reply' | 'reply_markup'>;
export declare type ExtraInvoice = MakeExtra<'sendInvoice', keyof NewInvoiceParameters>;
export declare type ExtraKickChatMember = MakeExtra<'kickChatMember', 'user_id' | 'until_date'>;
export declare type ExtraLocation = MakeExtra<'sendLocation', 'latitude' | 'longitude'>;
export declare type ExtraMediaGroup = MakeExtra<'sendMediaGroup', 'media'>;
export declare type ExtraPhoto = MakeExtra<'sendPhoto', 'photo'>;
export declare type ExtraPoll = MakeExtra<'sendPoll', 'question' | 'options' | 'type'>;
export declare type ExtraPromoteChatMember = MakeExtra<'promoteChatMember', 'user_id'>;
export declare type ExtraReplyMessage = MakeExtra<'sendMessage', 'text'>;
export declare type ExtraRestrictChatMember = MakeExtra<'restrictChatMember', 'user_id'>;
export declare type ExtraSetWebhook = MakeExtra<'setWebhook', 'url'>;
export declare type ExtraSticker = MakeExtra<'sendSticker', 'sticker'>;
export declare type ExtraStopPoll = MakeExtra<'stopPoll', 'message_id'>;
export declare type ExtraVenue = MakeExtra<'sendVenue', 'latitude' | 'longitude' | 'title' | 'address'>;
export declare type ExtraVideo = MakeExtra<'sendVideo', 'video'>;
export declare type ExtraVideoNote = MakeExtra<'sendVideoNote', 'video_note'>;
export declare type ExtraVoice = MakeExtra<'sendVoice', 'voice'>;
/** Possible update types */
export declare type UpdateType = Exclude<UnionKeys<Update>, keyof Update>;
/** Possible message subtypes. Same as the properties on a message object */
export declare type MessageSubType = 'forward_date' | Exclude<UnionKeys<Message>, keyof Message.CaptionableMessage | 'entities' | 'media_group_id'>;
export {};
//# sourceMappingURL=telegram-types.d.ts.map
export type InputFileVideoNote = Exclude<InputFile, InputFileByURL>
export interface ChatPermissions {
/** True, if the user is allowed to send text messages, contacts, locations and venues */
can_send_messages?: boolean
/** True, if the user is allowed to send audios, documents, photos, videos, video notes and voice notes, implies can_send_messages */
can_send_media_messages?: boolean
/** True, if the user is allowed to send polls, implies can_send_messages */
can_send_polls?: boolean
/** True, if the user is allowed to send animations, games, stickers and use inline bots, implies can_send_media_messages */
can_send_other_messages?: boolean
/** True, if the user is allowed to add web page previews to their messages, implies can_send_media_messages */
can_add_web_page_previews?: boolean
/** True, if the user is allowed to change the chat title, photo and other settings. Ignored in public supergroups */
can_change_info?: boolean
/** True, if the user is allowed to invite new users to the chat */
can_invite_users?: boolean
/** True, if the user is allowed to pin messages. Ignored in public supergroups */
can_pin_messages?: boolean
}
export interface ExtraRestrictChatMember {
/** New user permissions */
permissions: ChatPermissions
/** Date when restrictions will be lifted for the user, unix time. If user is restricted for more than 366 days or less than 30 seconds from the current time, they are considered to be restricted forever */
until_date?: number
}
export interface ExtraPromoteChatMember {
/** Pass True, if the administrator can change chat title, photo and other settings */
can_change_info?: boolean
/** Pass True, if the administrator can create channel posts, channels only */
can_post_messages?: boolean
/** Pass True, if the administrator can edit messages of other users and can pin messages, channels only */
can_edit_messages?: boolean
/** Pass True, if the administrator can delete messages of other users */
can_delete_messages?: boolean
/** Pass True, if the administrator can invite new users to the chat */
can_invite_users?: boolean
/** Pass True, if the administrator can restrict, ban or unban chat members */
can_restrict_members?: boolean
/** Pass True, if the administrator can pin messages, supergroups only */
can_pin_messages?: boolean
/** Pass True, if the administrator can add new administrators with a subset of his own privileges or demote administrators that he has promoted, directly or indirectly (promoted by administrators that were appointed by him) */
can_promote_members?: boolean
}
export interface ExtraReplyMessage {
/**
* Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
*/
parse_mode?: ParseMode
/**
* Disables link previews for links in this message
*/
disable_web_page_preview?: boolean
/**
* Sends the message silently. Users will receive a notification with no sound.
*/
disable_notification?: boolean
/**
* If the message is a reply, ID of the original message
*/
reply_to_message_id?: number
/**
* Additional interface options. An object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
*/
reply_markup?: TT.InlineKeyboardMarkup | TT.ReplyKeyboardMarkup | TT.ReplyKeyboardRemove | TT.ForceReply
}
export interface ExtraEditMessage extends ExtraReplyMessage {
// no specified properties
}
export interface ExtraAudio extends ExtraReplyMessage {
/**
* Audio caption, 0-1024 characters
*/
caption?: string
/**
* Duration of the audio in seconds
*/
duration?: number
/**
* Performer
*/
performer?: string
/**
* Track name
*/
title?: string
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile
/**
* Does not exist, see https://core.telegram.org/bots/api#sendaudio
*/
disable_web_page_preview?: never
}
export interface ExtraDocument extends ExtraReplyMessage {
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile
/**
* Document caption (may also be used when resending documents by file_id), 0-1024 characters
*/
caption?: string
/**
* Does not exist, see https://core.telegram.org/bots/api#senddocument
*/
disable_web_page_preview?: never
}
export interface ExtraGame extends ExtraReplyMessage {
/**
* Inline keyboard. If empty, one ‘Play game_title’ button will be shown. If not empty, the first button must launch the game.
*/
reply_markup?: TT.InlineKeyboardMarkup
/**
* Does not exist, see https://core.telegram.org/bots/api#sendgame
*/
disable_web_page_preview?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendgame
*/
parse_mode?: never
}
export interface ExtraInvoice extends ExtraReplyMessage {
/**
* Inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
*/
reply_markup?: TT.InlineKeyboardMarkup
/**
* Does not exist, see https://core.telegram.org/bots/api#sendinvoice
*/
disable_web_page_preview?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendinvoice
*/
parse_mode?: never
}
export interface ExtraLocation extends ExtraReplyMessage {
/**
* Period in seconds for which the location will be updated (should be between 60 and 86400)
*/
live_period?: number
/**
* Does not exist, see https://core.telegram.org/bots/api#sendlocation
*/
disable_web_page_preview?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendlocation
*/
parse_mode?: never
}
export interface ExtraPhoto extends ExtraReplyMessage {
/**
* Photo caption (may also be used when resending photos by file_id), 0-1024 characters
*/
caption?: string
/**
* Does not exist, see https://core.telegram.org/bots/api#sendphoto
*/
disable_web_page_preview?: never
}
export interface ExtraMediaGroup extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
disable_web_page_preview?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
parse_mode?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendmediagroup
*/
reply_markup?: never
}
export interface ExtraAnimation extends ExtraReplyMessage {
/**
* Animation caption (may also be used when resending animation by file_id), 0-200 characters
*/
caption?: string
}
export interface ExtraSticker extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#sendsticker
*/
disable_web_page_preview?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#sendsticker
*/
parse_mode?: never
}
export interface ExtraVideo extends ExtraReplyMessage {
/**
* Duration of sent video in seconds
*/
duration?: number
/**
* Video width
*/
width?: number
/**
* Video height
*/
height?: number
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile
/**
* Video caption (may also be used when resending videos by file_id), 0-1024 characters
*/
caption?: string
/**
* Pass True, if the uploaded video is suitable for streaming
*/
supports_streaming?: boolean
/**
* Does not exist, see https://core.telegram.org/bots/api#sendvideo
*/
disable_web_page_preview?: never
}
export interface ExtraVideoNote extends ExtraReplyMessage {
/**
* Duration of sent video in seconds
*/
duration?: number
/**
* Video width and height, i.e. diameter of the video message
*/
length?: number
/**
* Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.
* The thumbnail should be in JPEG format and less than 200 kB in size. A thumbnail‘s width and height should not exceed 320.
* Ignored if the file is not uploaded using multipart/form-data. Thumbnails can’t be reused and can be only uploaded as a new file,
* so you can pass “attach://<file_attach_name>” if the thumbnail was uploaded using multipart/form-data under <file_attach_name>.
*/
thumb?: InputFile
}
export interface ExtraVoice extends ExtraReplyMessage {
/**
* Voice message caption, 0-1024 characters
*/
caption?: string
/**
* Duration of the voice message in seconds
*/
duration?: number
/**
* Does not exist, see https://core.telegram.org/bots/api#sendvoice
*/
disable_web_page_preview?: never
}
export interface ExtraDice extends ExtraReplyMessage {
/**
* Does not exist, see https://core.telegram.org/bots/api#senddice
*/
parse_mode?: never
/**
* Does not exist, see https://core.telegram.org/bots/api#senddice
*/
disable_web_page_preview?: never
}
export interface ExtraPoll {
/** True, if the poll needs to be anonymous, defaults to True */
is_anonymous?: boolean
/** True, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to False */
allows_multiple_answers?: boolean
/** 0-based identifier of the correct answer option, required for polls in quiz mode */
correct_option_id?: number
/** Pass True, if the poll needs to be immediately closed. This can be useful for poll preview. */
is_closed?: boolean
/** Sends the message silently. Users will receive a notification with no sound. */
disable_notification?: boolean
/** If the message is a reply, ID of the original message */
reply_to_message_id?: number
/** Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user. */
reply_markup?:
| TT.InlineKeyboardMarkup
| TT.ReplyKeyboardMarkup
| TT.ReplyKeyboardRemove
| TT.ForceReply
}
export interface ExtraStopPoll {
/** A JSON-serialized object for a new message inline keyboard. */
reply_markup?: TT.InlineKeyboardMarkup
}
export interface IncomingMessage extends TT.Message {
audio?: TT.Audio
entities?: TT.MessageEntity[]
caption?: string
document?: TT.Document
game?: TT.Game
photo?: TT.PhotoSize[]
animation?: TT.Animation
sticker?: TT.Sticker
video?: TT.Video
video_note?: TT.VideoNote
contact?: TT.Contact
location?: TT.Location
venue?: TT.Venue
pinned_message?: TT.Message
invoice?: TT.Invoice
successful_payment?: TT.SuccessfulPayment
dice?: Dice
}
export interface MessageAudio extends TT.Message {
audio: TT.Audio
}
export interface MessageDocument extends TT.Message {
document: TT.Document
}
export interface MessageGame extends TT.Message {
game: TT.Game
}
export interface MessageInvoice extends TT.Message {
invoice: TT.Invoice
}
export interface MessageLocation extends TT.Message {
location: TT.Location
}
export interface MessagePhoto extends TT.Message {
photo: TT.PhotoSize[]
}
export interface MessageAnimation extends TT.Message {
animation: TT.Animation
}
export interface MessageSticker extends TT.Message {
sticker: TT.Sticker
}
export interface MessageVideo extends TT.Message {
video: TT.Video
}
export interface MessageVideoNote extends TT.Message {
video_note: TT.VideoNote
}
export interface MessageVoice extends TT.Message {
voice: TT.Voice
}
export interface MessageDice extends TT.Message {
dice: Dice
}
export interface MessagePoll extends TT.Message {
poll: Poll
}
export interface NewInvoiceParameters {
/**
* Product name, 1-32 characters
*/
title: string
/**
* Product description, 1-255 characters
*/
description: string
/**
* Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
*/
payload: string
/**
* Payments provider token, obtained via Botfather
*/
provider_token: string
/**
* Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
*/
start_parameter: string
/**
* Three-letter ISO 4217 currency code, see more on currencies
*/
currency: string
/**
* Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
*/
prices: TT.LabeledPrice[]
/**
* URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
*/
photo_url?: string
/**
* Photo size
*/
photo_size?: number
/**
* Photo width
*/
photo_width?: number
/**
* Photo height
*/
photo_height?: number
/**
* Pass True, if you require the user's full name to complete the order
*/
need_name?: true
/**
* Pass True, if you require the user's phone number to complete the order
*/
need_phone_number?: true
/**
* Pass True, if you require the user's email to complete the order
*/
need_email?: true
/**
* Pass True, if you require the user's shipping address to complete the order
*/
need_shipping_address?: true
/**
* Pass True, if the final price depends on the shipping method
*/
is_flexible?: true
}
export interface ExtraAnswerInlineQuery {
/**
* The maximum amount of time in seconds that the result of the inline query may be cached on the server. Defaults to 300.
*/
cache_time?: number
/**
* Pass True, if results may be cached on the server side only for the user that sent the query. By default, results may be returned to any user who sends the same query
*/
is_personal?: boolean
/**
* Pass the offset that a client should send in the next query with the same text to receive more results. Pass an empty string if there are no more results or if you don‘t support pagination. Offset length can’t exceed 64 bytes.
*/
next_offset?: string
/**
* If passed, clients will display a button with specified text that switches the user to a private chat with the bot and sends the bot a start message with the parameter switch_pm_parameter
*/
switch_pm_text?: string
/**
* Deep-linking parameter for the /start message sent to the bot when user presses the switch button. 1-64 characters, only A-Z, a-z, 0-9, _ and - are allowed.
*/
switch_pm_parameter?: string
}
/**
* This object represents a bot command
*/
export interface BotCommand {
/**
* Text of the command, 1-32 characters. Can contain only lowercase English letters, digits and underscores.
*/
command: string
/**
* Description of the command, 3-256 characters.
*/
description: string
}
/**
* This object represents a dice with random value from 1 to 6. (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
*/
export interface Dice {
/**
* Value of the dice, 1-6
*/
value: number
}
export interface PollOption {
/** Option text, 1-100 characters */
text: string
/** Number of users that voted for this option */
voter_count: number
}
export interface PollAnswer {
/** Unique poll identifier */
poll_id: string
/** The user, who changed the answer to the poll */
user: TT.User
/** 0-based identifiers of answer options, chosen by the user. May be empty if the user retracted their vote. */
option_ids: number[]
}
export interface Poll {
/** Unique poll identifier */
id: string
/** Poll question, 1-255 characters */
question: string
/** List of poll options */
options: PollOption[]
/** Total number of users that voted in the poll */
total_voter_count: number
/** True, if the poll is closed */
is_closed: boolean
/** True, if the poll is anonymous */
is_anonymous: boolean
/** Poll type, currently can be “regular” or “quiz” */
type: 'regular' | 'quiz'
/** True, if the poll allows multiple answers */
allows_multiple_answers: boolean
/** 0-based identifier of the correct answer option. Available only for polls in the quiz mode, which are closed, or was sent (not forwarded) by the bot or to the private chat with the bot. */
correct_option_id?: number
}

@@ -1,380 +0,686 @@

/// <reference types="node" />
import * as tg from './core/types/typegram';
import * as tt from './telegram-types';
import ApiClient from './core/network/client';
import { URL } from 'url';
/** @format */
import * as tt from './telegram-types.d'
import * as https from 'https'
import * as http from 'http'
export interface TelegramOptions {
/**
* https.Agent or http.Agent instance, allows custom proxy, certificate, keep alive, etc.
*/
agent?: https.Agent | http.Agent
/**
* Reply via webhook
*/
webhookReply?: boolean
/**
* Path to API. default: https://api.telegram.org
*/
apiRoot?: string
}
declare class ApiClient {
protected constructor(token: string, options: object, webhookResponse: any)
callApi(method: string, data: object): Promise<unknown>
}
export declare class Telegram extends ApiClient {
/**
* Get basic information about the bot
*/
getMe(): Promise<tg.UserFromGetMe>;
/**
* Get basic info about a file and prepare it for downloading
* @param fileId Id of file to get link to
*/
getFile(fileId: string): Promise<tg.File>;
/**
* Get download link to a file
*/
getFileLink(fileId: string | tg.File): Promise<URL>;
/**
* Directly request incoming updates.
* You should probably use `Telegraf::launch` instead.
*/
getUpdates(timeout: number, limit: number, offset: number, allowedUpdates: readonly tt.UpdateType[] | undefined): Promise<tg.Update[]>;
getWebhookInfo(): Promise<tg.WebhookInfo>;
getGameHighScores(userId: number, inlineMessageId: string | undefined, chatId: number | undefined, messageId: number | undefined): Promise<tg.GameHighScore[]>;
setGameScore(userId: number, score: number, inlineMessageId: string | undefined, chatId: number | undefined, messageId: number | undefined, editMessage?: boolean, force?: boolean): Promise<true | (tg.Update.Edited & tg.Message.GameMessage)>;
/**
* Specify a url to receive incoming updates via an outgoing webhook
* @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
*/
setWebhook(url: string, extra?: tt.ExtraSetWebhook): Promise<true>;
/**
* Remove webhook integration
*/
deleteWebhook(extra?: {
drop_pending_updates?: boolean;
}): Promise<true>;
/**
* Send a text message
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param text Text of the message to be sent
*/
sendMessage(chatId: number | string, text: string, extra?: tt.ExtraReplyMessage): Promise<tg.Message.TextMessage>;
/**
* Forward existing message.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param messageId Message identifier in the chat specified in from_chat_id
*/
forwardMessage(chatId: number | string, fromChatId: number | string, messageId: number, extra?: {
disable_notification?: boolean;
}): Promise<tg.Message>;
/**
* Use this method when you need to tell the user that something is happening on the bot's side.
* The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendChatAction(chatId: number | string, action: tt.ChatAction): Promise<true>;
getUserProfilePhotos(userId: number, offset?: number, limit?: number): Promise<tg.UserProfilePhotos>;
/**
* Send point on the map
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendLocation(chatId: number | string, latitude: number, longitude: number, extra?: tt.ExtraLocation): Promise<tg.Message.LocationMessage>;
sendVenue(chatId: number | string, latitude: number, longitude: number, title: string, address: string, extra?: tt.ExtraVenue): Promise<tg.Message.VenueMessage>;
/**
* @param chatId Unique identifier for the target private chat
*/
sendInvoice(chatId: number, invoice: tt.NewInvoiceParameters, extra?: tt.ExtraInvoice): Promise<tg.Message.InvoiceMessage>;
sendContact(chatId: number | string, phoneNumber: string, firstName: string, extra?: tt.ExtraContact): Promise<tg.Message.ContactMessage>;
/**
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendPhoto(chatId: number | string, photo: tg.Opts<'sendPhoto'>['photo'], extra?: tt.ExtraPhoto): Promise<tg.Message.PhotoMessage>;
/**
* Send a dice, which will have a random value from 1 to 6.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendDice(chatId: number | string, extra?: tt.ExtraDice): Promise<tg.Message.DiceMessage>;
/**
* Send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendDocument(chatId: number | string, document: tg.Opts<'sendDocument'>['document'], extra?: tt.ExtraDocument): Promise<tg.Message.DocumentMessage>;
/**
* Send audio files, if you want Telegram clients to display them in the music player.
* Your audio must be in the .mp3 format.
* Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendAudio(chatId: number | string, audio: tg.Opts<'sendAudio'>['audio'], extra?: tt.ExtraAudio): Promise<tg.Message.AudioMessage>;
/**
* Send .webp stickers
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendSticker(chatId: number | string, sticker: tg.Opts<'sendSticker'>['sticker'], extra?: tt.ExtraSticker): Promise<tg.Message.StickerMessage>;
/**
* Send video files, Telegram clients support mp4 videos (other formats may be sent as Document)
* Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendVideo(chatId: number | string, video: tg.Opts<'sendVideo'>['video'], extra?: tt.ExtraVideo): Promise<tg.Message.VideoMessage>;
/**
* Send .gif animations
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendAnimation(chatId: number | string, animation: tg.Opts<'sendAnimation'>['animation'], extra?: tt.ExtraAnimation): Promise<tg.Message.AnimationMessage>;
/**
* Send video messages
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendVideoNote(chatId: number | string, videoNote: string | tg.InputFileVideoNote, extra?: tt.ExtraVideoNote): Promise<tg.Message.VideoNoteMessage>;
/**
* Send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
sendVoice(chatId: number | string, voice: tg.Opts<'sendVoice'>['voice'], extra?: tt.ExtraVoice): Promise<tg.Message.VoiceMessage>;
/**
* @param chatId Unique identifier for the target chat
* @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
*/
sendGame(chatId: number, gameName: string, extra?: tt.ExtraGame): Promise<tg.Message.GameMessage>;
/**
* Send a group of photos or videos as an album
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
*/
sendMediaGroup(chatId: number | string, media: ReadonlyArray<tg.InputMediaPhoto | tg.InputMediaVideo> | readonly tg.InputMediaAudio[] | readonly tg.InputMediaDocument[], extra?: tt.ExtraMediaGroup): Promise<(tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage)[]>;
/**
* Send a native poll.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
*/
sendPoll(chatId: number | string, question: string, options: readonly string[], extra?: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
/**
* Send a native quiz.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
*/
sendQuiz(chatId: number | string, question: string, options: readonly string[], extra: tt.ExtraPoll): Promise<tg.Message.PollMessage>;
/**
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Identifier of the original message with the poll
*/
stopPoll(chatId: number | string, messageId: number, extra?: tt.ExtraStopPoll): Promise<tg.Poll>;
/**
* Get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.)
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
*/
getChat(chatId: number | string): Promise<tg.ChatFromGetChat>;
/**
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
*/
getChatAdministrators(chatId: number | string): Promise<tg.ChatMember[]>;
/**
* Get information about a member of a chat.
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*/
getChatMember(chatId: string | number, userId: number): Promise<tg.ChatMember>;
/**
* Get the number of members in a chat
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
*/
getChatMembersCount(chatId: string | number): Promise<number>;
/**
* Send answers to an inline query.
* No more than 50 results per query are allowed.
*/
answerInlineQuery(inlineQueryId: string, results: readonly tg.InlineQueryResult[], extra?: tt.ExtraAnswerInlineQuery): Promise<true>;
setChatPermissions(chatId: number | string, permissions: tg.ChatPermissions): Promise<true>;
/**
* Kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
*/
kickChatMember(chatId: number | string, userId: number, untilDate?: number, extra?: tt.ExtraKickChatMember): Promise<true>;
/**
* Promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
*/
promoteChatMember(chatId: number | string, userId: number, extra: tt.ExtraPromoteChatMember): Promise<true>;
/**
* Restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user.
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*/
restrictChatMember(chatId: string | number, userId: number, extra: tt.ExtraRestrictChatMember): Promise<true>;
setChatAdministratorCustomTitle(chatId: number | string, userId: number, title: string): Promise<true>;
/**
* Export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
exportChatInviteLink(chatId: number | string): Promise<string>;
createChatInviteLink(chatId: number | string, extra?: tt.ExtraCreateChatInviteLink): Promise<tg.ChatInviteLink>;
editChatInviteLink(chatId: number | string, inviteLink: string, extra?: tt.ExtraEditChatInviteLink): Promise<tg.ChatInviteLink>;
revokeChatInviteLink(chatId: number | string, inviteLink: string): Promise<tg.ChatInviteLink>;
setChatPhoto(chatId: number | string, photo: tg.Opts<'setChatPhoto'>['photo']): Promise<true>;
deleteChatPhoto(chatId: number | string): Promise<true>;
/**
* Change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param title New chat title, 1-255 characters
*/
setChatTitle(chatId: number | string, title: string): Promise<true>;
setChatDescription(chatId: number | string, description?: string): Promise<true>;
/**
* Pin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
*/
pinChatMessage(chatId: number | string, messageId: number, extra?: {
disable_notification?: boolean;
}): Promise<true>;
/**
* Unpin a message in a group, a supergroup, or a channel. The bot must be an administrator in the chat for this to work and must have the 'can_pin_messages' admin right in the supergroup or 'can_edit_messages' admin right in the channel.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
unpinChatMessage(chatId: number | string, messageId?: number): Promise<true>;
/**
* Clear the list of pinned messages in a chat
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
unpinAllChatMessages(chatId: number | string): Promise<true>;
/**
* Use this method for your bot to leave a group, supergroup or channel
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
*/
leaveChat(chatId: number | string): Promise<true>;
/**
* Unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
* @param userId Unique identifier of the target user
*/
unbanChatMember(chatId: number | string, userId: number, extra?: {
only_if_banned?: boolean;
}): Promise<true>;
answerCbQuery(callbackQueryId: string, text?: string, extra?: tt.ExtraAnswerCbQuery): Promise<true>;
answerGameQuery(callbackQueryId: string, url: string): Promise<true>;
/**
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
* the Bot API will send an Update with a shipping_query field to the bot.
* Reply to shipping queries.
* @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
* @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
* @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
*/
answerShippingQuery(shippingQueryId: string, ok: boolean, shippingOptions: readonly tg.ShippingOption[] | undefined, errorMessage: string | undefined): Promise<true>;
/**
* Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query.
* Respond to such pre-checkout queries. On success, True is returned.
* Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
* @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
* @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
*/
answerPreCheckoutQuery(preCheckoutQueryId: string, ok: boolean, errorMessage?: string): Promise<true>;
/**
* Edit text and game messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param text New text of the message
*/
editMessageText(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, text: string, extra?: tt.ExtraEditMessageText): Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
/**
* Edit captions of messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param caption New caption of the message
* @param markup A JSON-serialized object for an inline keyboard.
*/
editMessageCaption(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, caption: string | undefined, extra?: tt.ExtraEditMessageCaption): Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
/**
* Edit animation, audio, document, photo, or video messages.
* If a message is a part of a message album, then it can be edited only to a photo or a video.
* Otherwise, message type can be changed arbitrarily.
* When inline message is edited, new file can't be uploaded.
* Use previously uploaded file via its file_id or specify a URL.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param media New media of message
* @param markup Markup of inline keyboard
*/
editMessageMedia(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, media: tg.InputMedia, extra?: tt.ExtraEditMessageMedia): Promise<true | (tg.Update.Edited & tg.Message.AnimationMessage) | (tg.Update.Edited & tg.Message.AudioMessage) | (tg.Update.Edited & tg.Message.DocumentMessage) | (tg.Update.Edited & tg.Message.PhotoMessage) | (tg.Update.Edited & tg.Message.VideoMessage)>;
/**
* Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param markup A JSON-serialized object for an inline keyboard.
* @returns If edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
*/
editMessageReplyMarkup(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, markup: tg.InlineKeyboardMarkup | undefined): Promise<true | (tg.Update.Edited & tg.Message)>;
editMessageLiveLocation(chatId: number | undefined, messageId: number | undefined, inlineMessageId: string | undefined, latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
stopMessageLiveLocation(chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, markup?: tg.InlineKeyboardMarkup): Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
/**
* Delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots granted can_post_messages permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
deleteMessage(chatId: number | string, messageId: number): Promise<true>;
setChatStickerSet(chatId: number | string, setName: string): Promise<true>;
deleteChatStickerSet(chatId: number | string): Promise<true>;
getStickerSet(name: string): Promise<tg.StickerSet>;
/**
* Upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
* https://core.telegram.org/bots/api#sending-files
* @param ownerId User identifier of sticker file owner
* @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
*/
uploadStickerFile(ownerId: number, stickerFile: tg.Opts<'uploadStickerFile'>['png_sticker']): Promise<tg.File>;
/**
* Create new sticker set owned by a user. The bot will be able to edit the created sticker set
* @param ownerId User identifier of created sticker set owner
* @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
* @param title Sticker set title, 1-64 characters
*/
createNewStickerSet(ownerId: number, name: string, title: string, stickerData: tt.ExtraCreateNewStickerSet): Promise<true>;
/**
* Add a new sticker to a set created by the bot
* @param ownerId User identifier of sticker set owner
* @param name Sticker set name
*/
addStickerToSet(ownerId: number, name: string, stickerData: tt.ExtraAddStickerToSet): Promise<true>;
/**
* Move a sticker in a set created by the bot to a specific position
* @param sticker File identifier of the sticker
* @param position New sticker position in the set, zero-based
*/
setStickerPositionInSet(sticker: string, position: number): Promise<true>;
setStickerSetThumb(name: string, userId: number, thumb: tg.Opts<'setStickerSetThumb'>['thumb']): Promise<true>;
/**
* Delete a sticker from a set created by the bot.
* @param sticker File identifier of the sticker
*/
deleteStickerFromSet(sticker: string): Promise<true>;
/**
* Get the current list of the bot's commands.
*/
getMyCommands(): Promise<tg.BotCommand[]>;
/**
* Change the list of the bot's commands.
* @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
*/
setMyCommands(commands: readonly tg.BotCommand[]): Promise<true>;
setPassportDataErrors(userId: number, errors: readonly tg.PassportElementError[]): Promise<true>;
/**
* Send copy of existing message.
* @deprecated use `copyMessage` instead
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param message Received message object
*/
sendCopy(chatId: number | string, message: tg.Message, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
/**
* Send copy of existing message
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param messageId Message identifier in the chat specified in from_chat_id
*/
copyMessage(chatId: number | string, fromChatId: number | string, messageId: number, extra?: tt.ExtraCopyMessage): Promise<tg.MessageId>;
/**
* Log out from the cloud Bot API server before launching the bot locally
*/
logOut(): Promise<true>;
/**
* Close the bot instance before moving it from one local server to another
*/
close(): Promise<true>;
/**
* Initialize new Telegram app.
* @param token Bot token
* @param options Telegram options
*/
constructor(token: string, options?: TelegramOptions)
/**
* Use this property to control reply via webhook feature.
*/
webhookReply: boolean
/**
* Use this method to send answers to game query.
* @param callbackQueryId Query id
* @param url Notification text
*/
answerGameQuery(callbackQueryId: string, url: string): Promise<boolean>
/**
* If you sent an invoice requesting a shipping address and the parameter is_flexible was specified,
* the Bot API will send an Update with a shipping_query field to the bot.
* Use this method to reply to shipping queries.
* On success, True is returned.
* @param shippingQueryId Unique identifier for the query to be answered
* @param ok Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
* @param shippingOptions Required if ok is True. A JSON-serialized array of available shipping options.
* @param errorMessage Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
*/
answerShippingQuery(
shippingQueryId: string,
ok: boolean,
shippingOptions: Array<tt.ShippingOption>,
errorMessage: string
): Promise<boolean>
/**
* Once the user has confirmed their payment and shipping details, the Bot API sends the final confirmation in the form of an Update with the field pre_checkout_query.
* Use this method to respond to such pre-checkout queries. On success, True is returned.
* Note: The Bot API must receive an answer within 10 seconds after the pre-checkout query was sent.
* @param preCheckoutQueryId Unique identifier for the query to be answered
* @param ok Specify True if everything is alright (goods are available, etc.) and the bot is ready to proceed with the order. Use False if there are any problems.
* @param errorMessage Required if ok is False. Error message in human readable form that explains the reason for failure to proceed with the checkout (e.g. "Sorry, somebody just bought the last of our amazing black T-shirts while you were busy filling out your payment details. Please choose a different color or garment!"). Telegram will display this message to the user.
*/
answerPreCheckoutQuery(
preCheckoutQueryId: string,
ok: boolean,
errorMessage?: string
): Promise<boolean>
/**
* Use this method to send answers to an inline query. On success, True is returned.
* No more than 50 results per query are allowed.
* @param inlineQueryId Unique identifier for the answered query
* @param results Array of results for the inline query
* @param extra Extra optional parameters
*/
answerInlineQuery(
inlineQueryId: string,
results: Array<tt.InlineQueryResult>,
extra?: tt.ExtraAnswerInlineQuery
): Promise<boolean>
/**
* Use this method to forward exists message.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param fromChatId Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
* @param messageId Message identifier in the chat specified in from_chat_id
* @param extra Pass `{ disable_notification: true }`, if it is not necessary to send a notification for forwarded message
* @returns On success, the sent Message is returned.
*/
forwardMessage(
chatId: number | string,
fromChatId: number | string,
messageId: string | number,
extra?: { disable_notification?: boolean }
): Promise<tt.Message>
/**
* Use this method to edit text and game messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param text New text of the message
* @param extra Extra params
*/
editMessageText(
chatId: number | string | void,
messageId: number | void,
inlineMessageId: string | void,
text: string,
extra?: tt.ExtraEditMessage
): Promise<tt.Message | boolean>
/**
* Use this method to edit captions of messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param caption New caption of the message
* @param markup A JSON-serialized object for an inline keyboard.
*/
editMessageCaption(
chatId?: number | string,
messageId?: number,
inlineMessageId?: string,
caption?: string,
markup?: string
): Promise<tt.Message | boolean>
/**
* Use this method to edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
* On success, if edited message is sent by the bot, the edited Message is returned, otherwise True is returned.
* @param chatId Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Required if inlineMessageId is not specified. Identifier of the sent message
* @param inlineMessageId Required if chatId and messageId are not specified. Identifier of the inline message
* @param markup A JSON-serialized object for an inline keyboard.
*/
editMessageReplyMarkup(
chatId?: number | string,
messageId?: number,
inlineMessageId?: string,
markup?: string
): Promise<tt.Message | boolean>
/**
* Use this method to delete a message, including service messages, with the following limitations:
* - A message can only be deleted if it was sent less than 48 hours ago.
* - Bots can delete outgoing messages in groups and supergroups.
* - Bots granted can_post_messages permissions can delete outgoing messages in channels.
* - If the bot is an administrator of a group, it can delete any message there.
* - If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Identifier of the message to delete
* @returns Returns True on success.
*/
deleteMessage(chatId: number | string, messageId: number): Promise<boolean>
/**
* Use this method to get a sticker set
* @param setName Name of the sticker set
* @returns On success, a StickerSet object is returned.
*/
getStickerSet(setName: string): Promise<tt.StickerSet>
/**
* Use this method to upload a .png file with a sticker for later use in createNewStickerSet and addStickerToSet methods (can be used multiple times)
* https://core.telegram.org/bots/api#sending-files
* @param ownerId User identifier of sticker file owner
* @param stickerFile Png image with the sticker, must be up to 512 kilobytes in size, dimensions must not exceed 512px, and either width or height must be exactly 512px.
* @returns Returns the uploaded File on success
*/
uploadStickerFile(
ownerId: number,
stickerFile: tt.InputFile
): Promise<tt.File>
/**
* Use this method to create new sticker set owned by a user. The bot will be able to edit the created sticker set
* @param ownerId User identifier of created sticker set owner
* @param name Short name of sticker set, to be used in t.me/addstickers/ URLs (e.g., animals). Can contain only english letters, digits and underscores. Must begin with a letter, can't contain consecutive underscores and must end in “_by_<bot username>”. <bot_username> is case insensitive. 1-64 characters.
* @param title Sticker set title, 1-64 characters
* @param stickerData Sticker object
* @returns Returns True on success.
*/
createNewStickerSet(
ownerId: number,
name: string,
title: string,
stickerData: tt.StickerData
): Promise<boolean>
/**
* Use this method to add a new sticker to a set created by the bot
* @param ownerId User identifier of sticker set owner
* @param name Sticker set name
* @param stickerData Sticker object
* @param isMasks https://github.com/telegraf/telegraf/blob/87882c42f6c2496576fdb57ca622690205c3e35e/lib/telegram.js#L304
* @returns Returns True on success.
*/
addStickerToSet(
ownerId: number,
name: string,
stickerData: tt.StickerData,
isMasks: boolean
): Promise<boolean>
/**
* Use this method to move a sticker in a set created by the bot to a specific position
* @param sticker File identifier of the sticker
* @param position New sticker position in the set, zero-based
* @returns Returns True on success.
*/
setStickerPositionInSet(sticker: string, position: number): Promise<boolean>
/**
* Use this method to delete a sticker from a set created by the bot.
* @param sticker File identifier of the sticker
* @returns Returns True on success
*/
deleteStickerFromSet(sticker: string): Promise<boolean>
/**
* Use this method to send copy of exists message.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param message Received message object
* @param extra Specified params for message
* @returns On success, the sent Message is returned.
*/
sendCopy(
chatId: number | string,
message?: tt.Message,
extra?: object
): Promise<tt.Message>
/**
* Use this method to delete a chat photo. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @returns True on success
*/
deleteChatPhoto(chatId: number | string): Promise<boolean>
/**
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @returns exported invite link as String on success.
*/
exportChatInviteLink(chatId: number | string): Promise<string>
/**
* Use this method to get basic information about the bot
* @returns a User object on success.
*/
getMe(): Promise<tt.User>
/**
* Use this method to get up to date information about the chat (current name of the user for one-on-one conversations, current username of a user, group or channel, etc.)
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @returns a Chat object on success.
*/
getChat(chatId: number | string): Promise<tt.Chat>
/**
* Use this method to get a list of administrators in a chat.
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @returns On success, returns an Array of ChatMember objects that contains information about all chat administrators except other bots. If the chat is a group or a supergroup and no administrators were appointed, only the creator will be returned.
*/
getChatAdministrators(chatId: number | string): Promise<Array<tt.ChatMember>>
/**
* Use this method to get information about a member of a chat.
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @param userId Unique identifier of the target user
* @returns a ChatMember object on success
*/
getChatMember(chatId: string | number, userId: number): Promise<tt.ChatMember>
/**
* Use this method to get the number of members in a chat
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @returns Number on success
*/
getChatMembersCount(chatId: string | number): Promise<number>
/**
* Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param user_id Unique identifier of the target user
* @param extra Additional params for restrict chat member
* @returns True on success
*/
restrictChatMember(
chatId: string | number,
userId: number,
extra?: tt.ExtraRestrictChatMember
): Promise<boolean>
/**
* Use this method for your bot to leave a group, supergroup or channel
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @returns True on success
*/
leaveChat(chatId: number | string): Promise<boolean>
/**
* Use this method to pin a message in a supergroup. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param messageId Identifier of a message to pin
* @param extra Pass `{ disable_notification: true }`, if it is not necessary to send a notification to all group members about the new pinned message
* @returns True on success
*/
pinChatMessage(
chatId: number | string,
messageId: number,
extra?: { disable_notification?: boolean }
): Promise<boolean>
/**
* Use this method to unpin a message in a group, a supergroup, or a channel.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @returns True on success
*/
unpinChatMessage(chatId: number | string): Promise<boolean>
/**
* Use this method to send text messages
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param text Text of the message to be sent
* @param extra SendMessage additional params
* @returns sent Message if Success
*/
sendMessage(
chatId: number | string,
text: string,
extra?: tt.ExtraEditMessage
): Promise<tt.Message>
/**
* Use this method to send audio files, if you want Telegram clients to display them in the music player.
* Your audio must be in the .mp3 format.
* Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param audio Audio file to send. Pass a file_id as String to send an audio file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get an audio file from the Internet, or upload a new one using multipart/form-data
* @param extra Audio extra parameters
* @returns On success, the sent Message is returned.
*/
sendAudio(
chatId: number | string,
audio: tt.InputFile,
extra?: tt.ExtraAudio
): Promise<tt.MessageAudio>
/**
* Use this method when you need to tell the user that something is happening on the bot's side.
* The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).
* Choose one, depending on what the user is about to receive:
* - typing for text messages,
* - upload_photo for photos,
* - record_video or upload_video for videos,
* - record_audio or upload_audio for audio files,
* - upload_document for general files,
* - find_location for location data,
* - record_video_note or upload_video_note for video notes.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param action Type of action to broadcast.
* @returns True on success
*/
sendChatAction(
chatId: number | string,
action: tt.ChatAction
): Promise<boolean>
/**
* Use this method to send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param document File to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params for send document
* @returns a Message on success
*/
sendDocument(
chatId: number | string,
document: tt.InputFile,
extra?: tt.ExtraDocument
): Promise<tt.MessageDocument>
/**
* Use this method to send a game
* @param chatId Unique identifier for the target chat
* @param gameShortName Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
* @param extra Additional params for send game
* @returns a Message on success
*/
sendGame(
chatId: number | string,
gameShortName: string,
extra?: tt.ExtraGame
): Promise<tt.MessageGame>
/**
* Use this method to send invoices
* @param chatId Unique identifier for the target private chat
* @param invoice Object with new invoice params
* @param extra Additional params for send invoice
* @returns a Message on success
*/
sendInvoice(
chatId: number,
invoice: tt.NewInvoiceParameters,
extra?: tt.ExtraInvoice
): Promise<tt.MessageInvoice>
/**
* Use this method to send point on the map
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param latitude Latitude of location
* @param longitude Longitude of location
* @param extra Additional params for send location
* @returns a Message on success
*/
sendLocation(
chatId: number | string,
latitude: number,
longitude: number,
extra?: tt.ExtraLocation
): Promise<tt.MessageLocation>
/**
* Use this method to send photos
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param photo Photo to send. Pass a file_id as String to send a photo that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a photo from the Internet, or upload a new photo using multipart/form-data
* @param extra Additional params to send photo
* @returns a Message on success
*/
sendPhoto(
chatId: number | string,
photo: tt.InputFile,
extra?: tt.ExtraPhoto
): Promise<tt.MessagePhoto>
/**
* Use this method to send a group of photos or videos as an album
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param media A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
* @param extra Additional params to send media group
* @returns On success, an array of the sent Messages is returned
*/
sendMediaGroup(
chatId: number | string,
media: tt.MessageMedia[],
extra?: tt.ExtraMediaGroup
): Promise<Array<tt.Message>>
/**
* Use this method to send a native poll.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @param extra Additional params to send poll
* @returns On success, the sent Message is returned.
*/
sendPoll(
chatId: number | string,
question: string,
options: string[],
extra: tt.ExtraPoll
): Promise<tt.MessagePoll>
/**
* Use this method to send a native quiz.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param question Poll question, 1-255 characters
* @param options A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
* @param extra Additional params to send quiz
* @returns On success, the sent Message is returned.
*/
sendQuiz(
chatId: number | string,
question: string,
options: string[],
extra: tt.ExtraPoll
): Promise<tt.MessagePoll>
/**
* Use this method to send a native quiz.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param messageId Identifier of the original message with the poll
* @param extra Additional params to stop poll
* @returns On success, the stopped Poll with the final results is returned.
*/
stopPoll(
chatId: number | string,
messageId: number,
extra: tt.ExtraStopPoll
): Promise<tt.Poll>
/**
* Use this method to send .gif animations
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param animation Animation to send. Pass a file_id as String to send a GIF that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a GIF from the Internet, or upload a new GIF using multipart/form-data
* @param extra Additional params to send GIF
* @returns a Message on success
*/
sendAnimation(
chatId: number | string,
animation: tt.InputFile,
extra?: tt.ExtraAnimation
): Promise<tt.MessageAnimation>
/**
* Use this method to send .webp stickers
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param sticker Sticker to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a .webp file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params to send sticker
* @returns a Message on success
*/
sendSticker(
chatId: number | string,
sticker: tt.InputFile,
extra?: tt.ExtraSticker
): Promise<tt.MessageSticker>
/**
* Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document)
* Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param video video to send. Pass a file_id as String to send a video that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a video from the Internet, or upload a new video using multipart/form-data
* @param extra Additional params to send video
* @returns a Message on success
*/
sendVideo(
chatId: number | string,
video: tt.InputFile,
extra?: tt.ExtraVideo
): Promise<tt.MessageVideo>
/**
* Use this method to send video messages
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param videoNote video note to send. Pass a file_id as String to send a video note that exists on the Telegram servers (recommended) or upload a new video using multipart/form-data. Sending video notes by a URL is currently unsupported
* @param extra Additional params to send video note
* @returns a Message on success
*/
sendVideoNote(
chatId: number | string,
videoNote: tt.InputFileVideoNote,
extra?: tt.ExtraVideoNote
): Promise<tt.MessageVideoNote>
/**
* Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Audio or Document). On success, the sent Message is returned. Bots can currently send voice messages of up to 50 MB in size, this limit may be changed in the future.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param voice Audio file to send. Pass a file_id as String to send a file that exists on the Telegram servers (recommended), pass an HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using multipart/form-data
* @param extra Additional params to send voice
* @returns a Message on success
*/
sendVoice(
chatId: number | string,
voice: tt.InputFile,
extra?: tt.ExtraVoice
): Promise<tt.MessageVoice>
/**
* Use this method to send a dice, which will have a random value from 1 to 6. On success, the sent Message is returned. (Yes, we're aware of the “proper” singular of die. But it's awkward, and we decided to help it change. One dice at a time!)
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param extra Additional params to send dice
* @returns a Message on success
*/
sendDice(
chatId: number | string,
extra?: tt.ExtraDice
): Promise<tt.MessageDice>
/**
* Use this method to specify a url and receive incoming updates via an outgoing webhook
* @param url HTTPS url to send updates to. Use an empty string to remove webhook integration
* @param cert Upload your public key certificate so that the root certificate in use can be checked
* @param maxConnections Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100
* @param allowedUpdates List the types of updates you want your bot to receive
* @returns True on success
*/
setWebhook(
url: string,
cert?: tt.InputFile,
maxConnections?: number,
allowedUpdates?: string[]
): Promise<boolean>
/**
* Use this method to delete webhook
* @returns True on success
*/
deleteWebhook(): Promise<boolean>
/**
* Use this method to get information about set webhook
* @returns a WebhookInfo on success
*/
getWebhookInfo(): Promise<tt.WebhookInfo>
/**
* Use this method to get basic info about a file and prepare it for downloading
* @param fileId Id of file to get link to
* @returns a File object on success
*/
getFile(fileId: string): Promise<tt.File>
/**
* Use this method to get link to a file by file id
* @param fileId Id of file to get link to
* @returns a String with an url to the file
*/
getFileLink(fileId: string): Promise<string>
/**
* Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever
* @returns True on success
*/
kickChatMember(
chatId: number | string,
userId: number,
untilDate?: number
): Promise<boolean>
/**
* Use this method to unban a user from a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
* @param userId Unique identifier of the target user
* @returns True on success
*/
unbanChatMember(chatId: number | string, userId: number): Promise<boolean>
/**
* Use this method to promote or demote a user in a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. Pass False for all boolean parameters to demote a user.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @returns True on success
*/
promoteChatMember(
chatId: number | string,
userId: number,
extra: tt.ExtraPromoteChatMember
): Promise<boolean>
/**
* Use this method to get updates from Telegram server. Bot should be in `polling` mode
* @returns Array of updates
*/
getUpdates(): Promise<any[]>
/**
* Use this method to change the title of a chat. Titles can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param title New chat title, 1-255 characters
* @returns True on success
*/
setChatTitle(chatId: number | string, title: string): Promise<boolean>
/**
* Use this method to get the current list of the bot's commands. Requires no parameters.
* @returns Array of BotCommand on success.
*/
getMyCommands(): Promise<tt.BotCommand[]>
/**
* Use this method to change the list of the bot's commands.
* @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
* @returns True on success
*/
setMyCommands(commands: tt.BotCommand[]): Promise<boolean>
}
export default Telegram;
//# sourceMappingURL=telegram.d.ts.map
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc