telegraf
- Version 4.16.3
- Published
- 689 kB
- 8 dependencies
- MIT license
Install
npm i telegraf
yarn add telegraf
pnpm add telegraf
Overview
Modern Telegram Bot Framework
Index
Functions
Classes
Composer
- acl()
- action()
- admin()
- branch()
- cashtag()
- catch()
- chatType()
- command()
- compose()
- creator()
- dispatch()
- drop()
- email()
- entityText()
- filter()
- fork()
- gameQuery()
- groupChat()
- guard()
- hashtag()
- hears()
- help()
- inlineQuery()
- lazy()
- log()
- mention()
- middleware()
- mount
- on()
- optional()
- passThru()
- phone()
- privateChat()
- reaction()
- reply()
- settings()
- spoiler()
- start()
- tap()
- textLink()
- textMention()
- unwrap()
- url()
- use()
Context
- addStickerToSet()
- answerCbQuery()
- answerGameQuery()
- answerInlineQuery()
- answerPreCheckoutQuery()
- answerShippingQuery()
- approveChatJoinRequest()
- banChatMember()
- banChatSenderChat()
- botInfo
- callbackQuery
- channelPost
- chat
- chatBoost
- chatJoinRequest
- chatMember
- chosenInlineResult
- closeForumTopic()
- closeGeneralForumTopic()
- copyMessage()
- copyMessages()
- createChatInviteLink()
- createForumTopic()
- createNewStickerSet()
- declineChatJoinRequest()
- deleteChatPhoto()
- deleteChatStickerSet()
- deleteForumTopic()
- deleteMessage()
- deleteMessages()
- deleteStickerFromSet()
- deleteStickerSet()
- editChatInviteLink()
- editedChannelPost
- editedMessage
- editForumTopic()
- editGeneralForumTopic()
- editMessageCaption()
- editMessageLiveLocation()
- editMessageMedia()
- editMessageReplyMarkup()
- editMessageText()
- entities()
- exportChatInviteLink()
- forwardMessage()
- forwardMessages()
- from
- getChat()
- getChatAdministrators()
- getChatMember()
- getChatMembersCount()
- getChatMenuButton()
- getMyCommands()
- getMyDefaultAdministratorRights()
- getStickerSet()
- getUserChatBoosts()
- has()
- hideGeneralForumTopic()
- inlineMessageId
- inlineQuery
- kickChatMember
- leaveChat()
- me
- message
- messageReaction
- messageReactionCount
- msg
- msgId
- myChatMember
- passportData
- persistentChatAction()
- pinChatMessage()
- poll
- pollAnswer
- preCheckoutQuery
- promoteChatMember()
- react()
- reactions
- removedChatBoost
- reopenForumTopic()
- reopenGeneralForumTopic()
- reply()
- replyWithAnimation()
- replyWithAudio()
- replyWithChatAction()
- replyWithContact()
- replyWithDice()
- replyWithDocument()
- replyWithGame()
- replyWithHTML()
- replyWithInvoice()
- replyWithLocation()
- replyWithMarkdown()
- replyWithMarkdownV2()
- replyWithMediaGroup()
- replyWithPhoto()
- replyWithPoll()
- replyWithQuiz()
- replyWithSticker()
- replyWithVenue()
- replyWithVideo()
- replyWithVideoNote()
- replyWithVoice()
- restrictChatMember()
- revokeChatInviteLink()
- sendAnimation()
- sendAudio()
- sendChatAction()
- sendContact()
- sendDice()
- sendDocument()
- senderChat
- sendGame()
- sendInvoice()
- sendLocation()
- sendMediaGroup()
- sendMessage()
- sendPhoto()
- sendPoll()
- sendQuiz()
- sendSticker()
- sendVenue()
- sendVideo()
- sendVideoNote()
- sendVoice()
- setChatAdministratorCustomTitle()
- setChatDescription()
- setChatMenuButton()
- setChatPermissions()
- setChatPhoto()
- setChatStickerSet()
- setChatTitle()
- setCustomEmojiStickerSetThumbnail()
- setMyCommands()
- setMyDefaultAdministratorRights()
- setPassportDataErrors()
- setStickerEmojiList()
- setStickerKeywords()
- setStickerMaskPosition()
- setStickerPositionInSet()
- setStickerSetThumb()
- setStickerSetThumbnail()
- setStickerSetTitle()
- shippingQuery
- state
- stopMessageLiveLocation()
- stopPoll()
- telegram
- text
- tg
- unbanChatMember()
- unbanChatSenderChat()
- unhideGeneralForumTopic()
- unpinAllChatMessages()
- unpinAllForumTopicMessages()
- unpinAllGeneralForumTopicMessages()
- unpinChatMessage()
- update
- updateType
- uploadStickerFile()
- webAppData
- webhookReply
Telegram
- addStickerToSet()
- answerCbQuery()
- answerGameQuery()
- answerInlineQuery()
- answerPreCheckoutQuery()
- answerShippingQuery()
- answerWebAppQuery()
- approveChatJoinRequest()
- banChatMember()
- banChatSenderChat()
- close()
- closeForumTopic()
- closeGeneralForumTopic()
- copyMessage()
- copyMessages()
- createChatInviteLink()
- createForumTopic()
- createInvoiceLink()
- createNewStickerSet()
- declineChatJoinRequest()
- deleteChatPhoto()
- deleteChatStickerSet()
- deleteForumTopic()
- deleteMessage()
- deleteMessages()
- deleteMyCommands()
- deleteStickerFromSet()
- deleteStickerSet()
- deleteWebhook()
- editChatInviteLink()
- editForumTopic()
- editGeneralForumTopic()
- editMessageCaption()
- editMessageLiveLocation()
- editMessageMedia()
- editMessageReplyMarkup()
- editMessageText()
- exportChatInviteLink()
- forwardMessage()
- forwardMessages()
- getChat()
- getChatAdministrators()
- getChatMember()
- getChatMembersCount()
- getChatMenuButton()
- getCustomEmojiStickers()
- getFile()
- getFileLink()
- getForumTopicIconStickers()
- getGameHighScores()
- getMe()
- getMyCommands()
- getMyDefaultAdministratorRights()
- getMyDescription()
- getMyName()
- getMyShortDescription()
- getStickerSet()
- getUpdates()
- getUserChatBoosts()
- getUserProfilePhotos()
- getWebhookInfo()
- hideGeneralForumTopic()
- kickChatMember
- leaveChat()
- logOut()
- pinChatMessage()
- promoteChatMember()
- reopenForumTopic()
- reopenGeneralForumTopic()
- restrictChatMember()
- revokeChatInviteLink()
- sendAnimation()
- sendAudio()
- sendChatAction()
- sendContact()
- sendCopy()
- sendDice()
- sendDocument()
- sendGame()
- sendInvoice()
- sendLocation()
- sendMediaGroup()
- sendMessage()
- sendPhoto()
- sendPoll()
- sendQuiz()
- sendSticker()
- sendVenue()
- sendVideo()
- sendVideoNote()
- sendVoice()
- setChatAdministratorCustomTitle()
- setChatDescription()
- setChatMenuButton()
- setChatPermissions()
- setChatPhoto()
- setChatStickerSet()
- setChatTitle()
- setCustomEmojiStickerSetThumbnail()
- setGameScore()
- setMessageReaction()
- setMyCommands()
- setMyDefaultAdministratorRights()
- setMyDescription()
- setMyName()
- setMyShortDescription()
- setPassportDataErrors()
- setStickerEmojiList()
- setStickerKeywords()
- setStickerMaskPosition()
- setStickerPositionInSet()
- setStickerSetThumb
- setStickerSetThumbnail()
- setStickerSetTitle()
- setWebhook()
- stopMessageLiveLocation()
- stopPoll()
- unbanChatMember()
- unbanChatSenderChat()
- unhideGeneralForumTopic()
- unpinAllChatMessages()
- unpinAllForumTopicMessages()
- unpinAllGeneralForumTopicMessages()
- unpinChatMessage()
- uploadStickerFile()
Interfaces
Type Aliases
Namespaces
Types
- ChatAction
- CommandContextExtn
- ExtraAddStickerToSet
- ExtraAnimation
- ExtraAnswerCbQuery
- ExtraAnswerInlineQuery
- ExtraAudio
- ExtraBanChatMember
- ExtraBanChatSenderChat
- ExtraContact
- ExtraCopyMessage
- ExtraCopyMessages
- ExtraCreateChatInviteLink
- ExtraCreateForumTopic
- ExtraCreateNewStickerSet
- ExtraDice
- ExtraDocument
- ExtraEditChatInviteLink
- ExtraEditForumTopic
- ExtraEditMessageCaption
- ExtraEditMessageLiveLocation
- ExtraEditMessageMedia
- ExtraEditMessageText
- ExtraForwardMessage
- ExtraForwardMessages
- ExtraGame
- ExtraInvoice
- ExtraKickChatMember
- ExtraLocation
- ExtraMediaGroup
- ExtraPhoto
- ExtraPoll
- ExtraPromoteChatMember
- ExtraReplyMessage
- ExtraRestrictChatMember
- ExtraSendChatAction
- ExtraSetChatPermissions
- ExtraSetMyCommands
- ExtraSetWebhook
- ExtraSticker
- ExtraStopPoll
- ExtraVenue
- ExtraVideo
- ExtraVideoNote
- ExtraVoice
- Markup
- MediaGroup
- MessageSubType
- MountMap
- NewInvoiceLinkParameters
- NewInvoiceParameters
- UpdateType
- WrapCaption
Functions
function deunionize
deunionize: <T extends object>(t: T) => Deunionize<T, T>;
Expose properties from all union variants.
See Also
https://github.com/telegraf/telegraf/issues/1388#issuecomment-791573609
https://millsp.github.io/ts-toolbelt/modules/union_strict.html
function session
session: < S extends NonNullable<C[P]>, C extends Context<tg.Update> & { [key in P]?: C[P] }, P extends | (Exclude<keyof C, keyof Context<tg.Update>> & string) | 'session' = 'session'>( options?: SessionOptions<S, C, P>) => MiddlewareFn<C>;
Returns middleware that adds
ctx.session
for storing arbitrary state per session key.The default
getSessionKey
is${ctx.from.id}:${ctx.chat.id}
. If eitherctx.from
orctx.chat
isundefined
, default session key and thusctx.session
are alsoundefined
.> ⚠️ 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 persist data across process restarts, or share it among multiple instances, you should use [@telegraf/session](https://www.npmjs.com/package/@telegraf/session), or pass custom
storage
.See Also
Classes
class Composer
class Composer<C extends Context> implements MiddlewareObj<C> {}
constructor
constructor(...fns: readonly Middleware<C, Update>[]);
property mount
static mount: { < Ctx extends Context<tg.Update>, Filter extends Guard<Ctx['update'], Ctx['update']> >( filters: MaybeArray<Filter>, fns_0: Middleware<FilteredContext<Ctx, Filter>, Update>, ...fns_1: Middleware<FilteredContext<Ctx, Filter>, Update>[] ): MiddlewareFn<Ctx, Update>; <Ctx extends Context<tg.Update>, Filter extends 'forward_date'>( filters: MaybeArray<Filter>, fns_0: Middleware< NarrowedContext<Ctx, tt.MountMap[Filter]>, tt.MountMap[Filter] >, ...fns_1: Middleware< NarrowedContext<Ctx, tt.MountMap[Filter]>, tt.MountMap[Filter] >[] ): MiddlewareFn<Ctx, Update>;};
Generates middleware for handling provided update types.
Deprecated
use
Composer.on
instead
method acl
static acl: <C extends Context<tg.Update>>( userId: MaybeArray<number>, fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware responding only to specified users.
method action
static action: <C extends Context<tg.Update>>( triggers: Triggers<NarrowedContext<C, tt.MountMap['callback_query']>>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
Registers middleware for handling matching callback queries.
Generates middleware for handling matching callback queries.
method admin
static admin: <C extends Context<tg.Update>>( fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware responding only to chat admins and chat creator.
method branch
static branch: <C extends Context<tg.Update>>( predicate: boolean | Predicate<C> | AsyncPredicate<C>, trueMiddleware: Middleware<C>, falseMiddleware: Middleware<C>) => MiddlewareFn<C>;
Parameter trueMiddleware
middleware to run if the predicate returns true
Parameter falseMiddleware
middleware to run if the predicate returns false
method cashtag
static cashtag: <C extends Context<tg.Update>>( cashtag: MaybeArray<string>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method catch
static catch: <C extends Context<tg.Update>>( errorHandler: (err: unknown, ctx: C) => void, ...fns: ReadonlyArray<Middleware<C>>) => MiddlewareFn<C>;
method chatType
static chatType: <C extends Context<tg.Update>>( type: MaybeArray<tg.Chat['type']>, fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware running only in specified chat types.
method command
static command: <C extends Context<tg.Update>>( command: Triggers<NarrowedContext<C, tt.MountMap['text']>>, fns_0: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >, ...fns_1: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >[]) => MiddlewareFn<C>;
Registers middleware for handling specified commands.
Generates middleware for handling specified commands.
method compose
static compose: <C extends Context<tg.Update>>( middlewares: ReadonlyArray<Middleware<C>>) => MiddlewareFn<C>;
method creator
static creator: <C extends Context<tg.Update>>( fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware responding only to chat creator.
method dispatch
static dispatch: < C extends Context<tg.Update>, Handlers extends Record<string | number | symbol, Middleware<C, Update>>>( routeFn: (ctx: C) => MaybePromise<keyof Handlers>, handlers: Handlers) => Middleware<C>;
method drop
static drop: <C extends Context<tg.Update>>( predicate: Predicate<C>) => MiddlewareFn<C>;
Registers middleware for dropping matching updates.
Generates middleware for dropping matching updates.
method email
static email: <C extends Context<tg.Update>>( email: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method entityText
static entityText: <C extends Context<tg.Update>>( entityType: MaybeArray<string>, predicate: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method filter
static filter: <C extends Context<tg.Update>>( predicate: Predicate<C>) => MiddlewareFn<C>;
Deprecated
use
Composer::drop
Deprecated
use
Composer.drop
method fork
static fork: <C extends Context<tg.Update>>( middleware: Middleware<C>) => MiddlewareFn<C>;
Generates middleware that runs in the background.
method gameQuery
static gameQuery: <C extends Context<tg.Update>>( fns_0: Middleware< NarrowedContext< C, tg.Update.CallbackQueryUpdate<CallbackQuery.GameQuery> >, Update >, ...fns_1: Middleware< NarrowedContext< C, tg.Update.CallbackQueryUpdate<CallbackQuery.GameQuery> >, Update >[]) => MiddlewareFn<C>;
Registers middleware for handling game queries
Generates middleware for handling game queries.
method groupChat
static groupChat: <C extends Context<tg.Update>>( fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware running only in groups and supergroups.
method guard
static guard: <C extends Context<tg.Update>, U extends tg.Update>( guardFn: (u: tg.Update) => u is U, fns_0: Middleware<NarrowedContext<C, U>, U>, ...fns_1: Middleware<NarrowedContext<C, U>, U>[]) => MiddlewareFn<C>;
Registers middleware for handling updates matching given type guard function.
Deprecated
use
Composer::on
Generates optional middleware based on a predicate that only operates on
ctx.update
.Example:
import { Composer, Update } from 'telegraf'const predicate = (u): u is Update.MessageUpdate => 'message' in uconst middleware = Composer.guard(predicate, (ctx) => {const message = ctx.update.message})Note that
Composer.on('message')
is preferred over this.Parameter guardFn
predicate to decide whether to run the middleware based on the
ctx.update
objectParameter fns
middleware to run if the predicate returns true
See Also
Composer.optional
for a more generic version of this method that allows the predicate to operate onctx
itself
Deprecated
use
Composer.on
method hashtag
static hashtag: <C extends Context<tg.Update>>( hashtag: MaybeArray<string>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method hears
static hears: <C extends Context<tg.Update>>( triggers: Triggers<NarrowedContext<C, tt.MountMap['text']>>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
Registers middleware for handling matching text messages.
Generates middleware for handling matching text messages.
method help
help: ( fns_0: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >, ...fns_1: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >[]) => this;
Registers a middleware for handling /help
method inlineQuery
static inlineQuery: <C extends Context<tg.Update>>( triggers: Triggers<NarrowedContext<C, tt.MountMap['inline_query']>>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
Registers middleware for handling matching inline queries.
Generates middleware for handling matching inline queries.
method lazy
static lazy: <C extends Context<tg.Update>>( factoryFn: (ctx: C) => MaybePromise<Middleware<C>>) => MiddlewareFn<C>;
method log
static log: (logFn?: (s: string) => void) => MiddlewareFn<Context>;
method mention
static mention: <C extends Context<tg.Update>>( mention: MaybeArray<string>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method middleware
middleware: () => MiddlewareFn<C>;
method on
static on: { < Ctx extends Context<tg.Update>, Filter extends Guard<Ctx['update'], Ctx['update']> >( filters: MaybeArray<Filter>, fns_0: Middleware<FilteredContext<Ctx, Filter>, Update>, ...fns_1: Middleware<FilteredContext<Ctx, Filter>, Update>[] ): MiddlewareFn<Ctx>; <Ctx extends Context<tg.Update>, Filter extends 'forward_date'>( filters: MaybeArray<Filter>, fns_0: Middleware< NarrowedContext<Ctx, tt.MountMap[Filter]>, tt.MountMap[Filter] >, ...fns_1: Middleware< NarrowedContext<Ctx, tt.MountMap[Filter]>, tt.MountMap[Filter] >[] ): MiddlewareFn<Ctx, Update>;};
Registers middleware for handling updates narrowed by update types or filter queries.
Registers middleware for handling updates narrowed by update types or message subtypes.
Deprecated
Use filter utils instead. Support for Message subtype in
Composer::on
will be removed in Telegraf v5.Generates middleware for handling updates narrowed by update types or filter queries.
Generates middleware for handling updates narrowed by update types or message subtype.
Deprecated
Use filter utils instead. Support for Message subtype in
Composer.on
will be removed in Telegraf v5.
method optional
static optional: <C extends Context<tg.Update>>( predicate: Predicate<C> | AsyncPredicate<C>, fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates optional middleware.
Parameter predicate
predicate to decide on a context object whether to run the middleware
Parameter fns
middleware to run if the predicate returns true
method passThru
static passThru: () => MiddlewareFn<Context>;
Generates middleware that gives up control to the next middleware.
method phone
static phone: <C extends Context<tg.Update>>( number: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method privateChat
static privateChat: <C extends Context<tg.Update>>( fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => MiddlewareFn<C>;
Generates middleware running only in private chats.
method reaction
static reaction: <C extends Context<tg.Update>>( reaction: MaybeArray<ReactionAddedOrRemoved>, fns_0: Middleware< Context<tg.Update.MessageReactionUpdate> & Omit<C, keyof Context<tg.Update>> & { match: ReactionAddedOrRemoved; }, tg.Update.MessageReactionUpdate >, ...fns_1: Middleware< Context<tg.Update.MessageReactionUpdate> & Omit<C, keyof Context<tg.Update>> & { match: ReactionAddedOrRemoved; }, tg.Update.MessageReactionUpdate >[]) => MiddlewareFn<C>;
method reply
static reply: ( text: string | FmtString<string>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => MiddlewareFn<Context>;
method settings
settings: ( fns_0: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >, ...fns_1: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & tt.CommandContextExtn, Update >[]) => this;
Registers a middleware for handling /settings
method spoiler
static spoiler: <C extends Context<tg.Update>>( text: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method start
start: ( fns_0: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & StartContextExtn, Update >, ...fns_1: Middleware< Context<any> & Omit<C, keyof Context<tg.Update>> & StartContextExtn, Update >[]) => this;
Registers a middleware for handling /start
method tap
static tap: <C extends Context<tg.Update>>( middleware: Middleware<C>) => MiddlewareFn<C>;
method textLink
static textLink: <C extends Context<tg.Update>>( link: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method textMention
static textMention: <C extends Context<tg.Update>>( mention: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method unwrap
static unwrap: <C extends Context<tg.Update>>( handler: Middleware<C>) => MiddlewareFn<C>;
method url
static url: <C extends Context<tg.Update>>( url: Triggers<C>, fns_0: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >, ...fns_1: Middleware< Context<unknown> & Omit<C, keyof Context<tg.Update>> & { match: RegExpExecArray }, unknown >[]) => MiddlewareFn<C>;
method use
use: (...fns: ReadonlyArray<Middleware<C>>) => this;
Registers a middleware.
class Context
class Context<U extends Deunionize<tg.Update> = tg.Update> {}
constructor
constructor(update: {}, telegram: Telegram, botInfo: tg.UserFromGetMe);
property botInfo
readonly botInfo: tg.UserFromGetMe;
property callbackQuery
readonly callbackQuery: {};
property channelPost
readonly channelPost: {};
property chat
readonly chat: {};
property chatBoost
readonly chatBoost: {};
property chatJoinRequest
readonly chatJoinRequest: {};
property chatMember
readonly chatMember: {};
property chosenInlineResult
readonly chosenInlineResult: {};
property editedChannelPost
readonly editedChannelPost: {};
property editedMessage
readonly editedMessage: {};
property from
readonly from: tg.User;
property inlineMessageId
readonly inlineMessageId: string;
property inlineQuery
readonly inlineQuery: {};
property kickChatMember
readonly kickChatMember: ( userId: number, untilDate?: number | undefined, extra?: | Omit< { chat_id: string | number; user_id: number; until_date?: number | undefined; revoke_messages?: boolean | undefined; }, 'chat_id' | 'user_id' | 'until_date' > | undefined) => Promise<true>;
See Also
https://core.telegram.org/bots/api#banchatmember
Deprecated
since API 5.3. Use Context.banChatMember
property me
readonly me: string;
property message
readonly message: {};
property messageReaction
readonly messageReaction: {};
property messageReactionCount
readonly messageReactionCount: {};
property msg
readonly msg: Msg;
Shorthand for any
message
object present in the current update. One ofmessage
,edited_message
,channel_post
,edited_channel_post
orcallback_query.message
property msgId
readonly msgId: number;
Shorthand for any message_id present in the current update.
property myChatMember
readonly myChatMember: {};
property passportData
readonly passportData: any;
property poll
readonly poll: {};
property pollAnswer
readonly pollAnswer: {};
property preCheckoutQuery
readonly preCheckoutQuery: {};
property reactions
readonly reactions: MessageReactions;
property removedChatBoost
readonly removedChatBoost: {};
property senderChat
readonly senderChat: {};
property shippingQuery
readonly shippingQuery: {};
property state
readonly state: Record<string | symbol, any>;
property telegram
readonly telegram: Telegram;
property text
readonly text: string;
property tg
readonly tg: Telegram;
Deprecated
Use ctx.telegram instead
property update
readonly update: {};
property updateType
readonly updateType: never;
property webAppData
readonly webAppData: { data: { json<T>(): T; text(): string }; button_text: string;};
property webhookReply
webhookReply: boolean;
Deprecated
method addStickerToSet
addStickerToSet: ( name: string, stickerData: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#addstickertoset
method answerCbQuery
answerCbQuery: ( text?: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#answercallbackquery
method answerGameQuery
answerGameQuery: (url: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#answercallbackquery
method answerInlineQuery
answerInlineQuery: ( results: readonly tg.InlineQueryResult[], extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#answerinlinequery
method answerPreCheckoutQuery
answerPreCheckoutQuery: (ok: boolean, errorMessage?: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#answerprecheckoutquery
method answerShippingQuery
answerShippingQuery: ( ok: boolean, shippingOptions: readonly tg.ShippingOption[], errorMessage: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#answershippingquery
method approveChatJoinRequest
approveChatJoinRequest: (userId: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#approvechatjoinrequest
method banChatMember
banChatMember: ( userId: number, untilDate?: number, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#banchatmember
method banChatSenderChat
banChatSenderChat: (senderChatId: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#banchatsenderchat
method closeForumTopic
closeForumTopic: () => Promise<true>;
Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
See Also
https://core.telegram.org/bots/api#closeforumtopic
method closeGeneralForumTopic
closeGeneralForumTopic: () => Promise<true>;
Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
See Also
https://core.telegram.org/bots/api#closegeneralforumtopic
method copyMessage
copyMessage: ( chatId: string | number, extra?: tt.ExtraCopyMessage) => Promise<tg.MessageId>;
See Also
https://core.telegram.org/bots/api#copymessage
method copyMessages
copyMessages: ( chatId: number | string, messageIds: number[], extra?: tt.ExtraCopyMessages) => Promise<tg.MessageId[]>;
Context-aware shorthand for Telegram.copyMessages
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageIds
Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
method createChatInviteLink
createChatInviteLink: (extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>;}) => Promise<tg.ChatInviteLink>;
See Also
https://core.telegram.org/bots/api#createchatinvitelink
method createForumTopic
createForumTopic: ( name: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.ForumTopic>;
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.
See Also
https://core.telegram.org/bots/api#createforumtopic
method createNewStickerSet
createNewStickerSet: ( name: string, title: string, stickerData: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#createnewstickerset
method declineChatJoinRequest
declineChatJoinRequest: (userId: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#declinechatjoinrequest
method deleteChatPhoto
deleteChatPhoto: () => Promise<true>;
See Also
https://core.telegram.org/bots/api#deletechatphoto
method deleteChatStickerSet
deleteChatStickerSet: () => Promise<true>;
See Also
https://core.telegram.org/bots/api#deletechatstickerset
method deleteForumTopic
deleteForumTopic: () => Promise<true>;
Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
See Also
https://core.telegram.org/bots/api#deleteforumtopic
method deleteMessage
deleteMessage: (messageId?: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#deletemessage
method deleteMessages
deleteMessages: (messageIds: number[]) => Promise<true>;
Context-aware shorthand for Telegram.deleteMessages
Parameter messageIds
Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
method deleteStickerFromSet
deleteStickerFromSet: (sticker: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#deletestickerfromset
Deprecated
method deleteStickerSet
deleteStickerSet: (name: string) => Promise<true>;
method editChatInviteLink
editChatInviteLink: ( inviteLink: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.ChatInviteLink>;
See Also
https://core.telegram.org/bots/api#editchatinvitelink
method editForumTopic
editForumTopic: (extra: tt.ExtraEditForumTopic) => Promise<true>;
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
See Also
https://core.telegram.org/bots/api#editforumtopic
method editGeneralForumTopic
editGeneralForumTopic: (name: string) => Promise<true>;
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
See Also
https://core.telegram.org/bots/api#editgeneralforumtopic
method editMessageCaption
editMessageCaption: ( caption: string | FmtString | undefined, extra?: tt.ExtraEditMessageCaption) => Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
See Also
https://core.telegram.org/bots/api#editmessagecaption
method editMessageLiveLocation
editMessageLiveLocation: ( latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation) => Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
See Also
https://core.telegram.org/bots/api#editmessagelivelocation
method editMessageMedia
editMessageMedia: ( media: tt.WrapCaption<tg.InputMedia>, extra?: tt.ExtraEditMessageMedia) => Promise<true | (tg.Update.Edited & tg.Message)>;
See Also
https://core.telegram.org/bots/api#editmessagemedia
method editMessageReplyMarkup
editMessageReplyMarkup: ( markup: tg.InlineKeyboardMarkup | undefined) => Promise<true | (tg.Update.Edited & tg.Message)>;
See Also
https://core.telegram.org/bots/api#editmessagereplymarkup
method editMessageText
editMessageText: ( text: string | FmtString, extra?: tt.ExtraEditMessageText) => Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
See Also
https://core.telegram.org/bots/api#editmessagetext
method entities
entities: <EntityTypes extends tg.MessageEntity[]>( ...types: EntityTypes) => (tg.MessageEntity & { type: EntityTypes extends [] ? | 'mention' | 'hashtag' | 'cashtag' | 'bot_command' | 'url' | 'email' | 'phone_number' | 'bold' | 'blockquote' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' | 'custom_emoji' | 'pre' | 'text_link' | 'text_mention' : EntityTypes[number]; fragment: string;})[];
method exportChatInviteLink
exportChatInviteLink: () => Promise<string>;
See Also
https://core.telegram.org/bots/api#exportchatinvitelink
method forwardMessage
forwardMessage: ( chatId: string | number, extra?: Shorthand<'forwardMessage'>[2]) => Promise<tg.Message>;
See Also
https://core.telegram.org/bots/api#forwardmessage
method forwardMessages
forwardMessages: ( chatId: string | number, messageIds: number[], extra?: Shorthand<'forwardMessages'>[2]) => Promise<tg.MessageId[]>;
Shorthand for Telegram.forwardMessages
See Also
https://core.telegram.org/bots/api#forwardmessages
method getChat
getChat: () => Promise<tg.ChatFromGetChat>;
See Also
https://core.telegram.org/bots/api#getchat
method getChatAdministrators
getChatAdministrators: () => Promise< (tg.ChatMemberOwner | tg.ChatMemberAdministrator)[]>;
See Also
https://core.telegram.org/bots/api#getchatadministrators
method getChatMember
getChatMember: (userId: number) => Promise<tg.ChatMember>;
See Also
https://core.telegram.org/bots/api#getchatmember
method getChatMembersCount
getChatMembersCount: () => Promise<number>;
See Also
https://core.telegram.org/bots/api#getchatmembercount
method getChatMenuButton
getChatMenuButton: () => Promise<tg.MenuButton>;
Use this method to get the current value of the bot's menu button in the current private chat. Returns MenuButton on success.
See Also
https://core.telegram.org/bots/api#getchatmenubutton
method getMyCommands
getMyCommands: () => Promise<tg.BotCommand[]>;
See Also
https://core.telegram.org/bots/api#getmycommands
Deprecated
method getMyDefaultAdministratorRights
getMyDefaultAdministratorRights: ( extra?: Parameters<Telegram['getMyDefaultAdministratorRights']>[0]) => Promise<tg.ChatAdministratorRights>;
See Also
https://core.telegram.org/bots/api#getmydefaultadministratorrights
method getStickerSet
getStickerSet: (setName: string) => Promise<tg.StickerSet>;
See Also
https://core.telegram.org/bots/api#getstickerset
Deprecated
method getUserChatBoosts
getUserChatBoosts: () => Promise<tg.UserChatBoosts[]>;
Shorthand for Telegram.getUserChatBoosts
method has
has: <Filter extends Guard<tg.Update, tg.Update>>( filters: MaybeArray<Filter>) => this is FilteredContext<Context<tg.Update>, Filter>;
method hideGeneralForumTopic
hideGeneralForumTopic: () => Promise<true>;
Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
See Also
https://core.telegram.org/bots/api#hidegeneralforumtopic
method leaveChat
leaveChat: () => Promise<true>;
See Also
https://core.telegram.org/bots/api#leavechat
method persistentChatAction
persistentChatAction: ( action: Typegram.Opts<tg.InputFile>, callback: () => Promise<void>, { intervalDuration, ...extra }?: tt.ExtraSendChatAction & { intervalDuration?: number }) => Promise<void>;
Parameter action
chat action type.
Parameter callback
a function to run along with the chat action.
Parameter extra
extra parameters for sendChatAction.
Parameter
{number} [extra.intervalDuration=8000] - The duration (in milliseconds) between subsequent sendChatAction requests.
See Also
https://core.telegram.org/bots/api#sendchataction
Sends the sendChatAction request repeatedly, with a delay between requests, as long as the provided callback function is being processed.
The sendChatAction errors should be ignored, because the goal is the actual long process completing and performing an action.
method pinChatMessage
pinChatMessage: ( messageId: number, extra?: { disable_notification?: boolean }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#pinchatmessage
method promoteChatMember
promoteChatMember: ( userId: number, extra: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#promotechatmember
method react
react: ( reaction?: MaybeArray< tg.TelegramEmoji | `${Digit}${string}` | tg.ReactionType >, is_big?: boolean) => Promise<true>;
Shorthand for Telegram.setMessageReaction
Parameter reaction
An emoji or custom_emoji_id to set as reaction to current message. Leave empty to remove reactions.
Parameter is_big
Pass True to set the reaction with a big animation
method reopenForumTopic
reopenForumTopic: () => Promise<true>;
Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
See Also
https://core.telegram.org/bots/api#reopenforumtopic
method reopenGeneralForumTopic
reopenGeneralForumTopic: () => Promise<true>;
Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.
See Also
https://core.telegram.org/bots/api#reopengeneralforumtopic
method reply
reply: ( text: string | FmtString<string>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.TextMessage>;
See Also
https://core.telegram.org/bots/api#sendmessage
method replyWithAnimation
replyWithAnimation: ( animation: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.AnimationMessage>;
See Also
https://core.telegram.org/bots/api#sendanimation
method replyWithAudio
replyWithAudio: ( audio: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.AudioMessage>;
See Also
https://core.telegram.org/bots/api#sendaudio
method replyWithChatAction
replyWithChatAction: ( action: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#sendchataction
Deprecated
use Context.sendChatAction instead
method replyWithContact
replyWithContact: ( phoneNumber: string, firstName: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.ContactMessage>;
See Also
https://core.telegram.org/bots/api#sendcontact
method replyWithDice
replyWithDice: (extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>;}) => Promise<tg.Message.DiceMessage>;
See Also
https://core.telegram.org/bots/api#senddice
method replyWithDocument
replyWithDocument: ( document: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.DocumentMessage>;
See Also
https://core.telegram.org/bots/api#senddocument
method replyWithGame
replyWithGame: ( gameName: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.GameMessage>;
See Also
https://core.telegram.org/bots/api#sendgame
method replyWithHTML
replyWithHTML: ( html: string, extra?: tt.ExtraReplyMessage) => Promise<tg.Message.TextMessage>;
See Also
https://core.telegram.org/bots/api#sendmessage
method replyWithInvoice
replyWithInvoice: ( invoice: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }, extra?: { caption?: string | FmtString<string> }) => Promise<tg.Message.InvoiceMessage>;
See Also
https://core.telegram.org/bots/api#sendinvoice
method replyWithLocation
replyWithLocation: ( latitude: number, longitude: number, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.LocationMessage>;
See Also
https://core.telegram.org/bots/api#sendlocation
method replyWithMarkdown
replyWithMarkdown: ( markdown: string, extra?: tt.ExtraReplyMessage) => Promise<tg.Message.TextMessage>;
See Also
https://core.telegram.org/bots/api#sendmessage
Deprecated
method replyWithMarkdownV2
replyWithMarkdownV2: ( markdown: string, extra?: tt.ExtraReplyMessage) => Promise<tg.Message.TextMessage>;
See Also
https://core.telegram.org/bots/api#sendmessage
method replyWithMediaGroup
replyWithMediaGroup: ( media: tt.MediaGroup, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise< ( | tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage )[]>;
See Also
https://core.telegram.org/bots/api#sendmediagroup
method replyWithPhoto
replyWithPhoto: ( photo: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.PhotoMessage>;
See Also
https://core.telegram.org/bots/api#sendphoto
method replyWithPoll
replyWithPoll: ( question: string, options: readonly string[], extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.PollMessage>;
See Also
https://core.telegram.org/bots/api#sendpoll
method replyWithQuiz
replyWithQuiz: ( question: string, options: readonly string[], extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.PollMessage>;
See Also
https://core.telegram.org/bots/api#sendpoll
method replyWithSticker
replyWithSticker: ( sticker: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.StickerMessage>;
See Also
https://core.telegram.org/bots/api#sendsticker
method replyWithVenue
replyWithVenue: ( latitude: number, longitude: number, title: string, address: string, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.VenueMessage>;
See Also
https://core.telegram.org/bots/api#sendvenue
method replyWithVideo
replyWithVideo: ( video: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.VideoMessage>;
See Also
https://core.telegram.org/bots/api#sendvideo
method replyWithVideoNote
replyWithVideoNote: ( videoNote: string | tg.InputFileVideoNote, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.VideoNoteMessage>;
See Also
https://core.telegram.org/bots/api#sendvideonote
method replyWithVoice
replyWithVoice: ( voice: Typegram.Opts<tg.InputFile>, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Message.VoiceMessage>;
See Also
https://core.telegram.org/bots/api#sendvoice
method restrictChatMember
restrictChatMember: ( userId: number, extra: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#restrictchatmember
method revokeChatInviteLink
revokeChatInviteLink: (inviteLink: string) => Promise<tg.ChatInviteLink>;
See Also
https://core.telegram.org/bots/api#revokechatinvitelink
method sendAnimation
sendAnimation: ( animation: string | tg.InputFile, extra?: tt.ExtraAnimation) => Promise<tg.Message.AnimationMessage>;
See Also
https://core.telegram.org/bots/api#sendanimation
method sendAudio
sendAudio: ( audio: string | tg.InputFile, extra?: tt.ExtraAudio) => Promise<tg.Message.AudioMessage>;
See Also
https://core.telegram.org/bots/api#sendaudio
method sendChatAction
sendChatAction: ( action: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraSendChatAction) => Promise<true>;
See Also
https://core.telegram.org/bots/api#sendchataction
method sendContact
sendContact: ( phoneNumber: string, firstName: string, extra?: tt.ExtraContact) => Promise<tg.Message.ContactMessage>;
See Also
https://core.telegram.org/bots/api#sendcontact
method sendDice
sendDice: (extra?: tt.ExtraDice) => Promise<tg.Message.DiceMessage>;
See Also
https://core.telegram.org/bots/api#senddice
method sendDocument
sendDocument: ( document: string | tg.InputFile, extra?: tt.ExtraDocument) => Promise<tg.Message.DocumentMessage>;
See Also
https://core.telegram.org/bots/api#senddocument
method sendGame
sendGame: ( game: string, extra?: tt.ExtraGame) => Promise<tg.Message.GameMessage>;
See Also
https://core.telegram.org/bots/api#sendgame
method sendInvoice
sendInvoice: ( invoice: tt.NewInvoiceParameters, extra?: tt.ExtraInvoice) => Promise<tg.Message.InvoiceMessage>;
See Also
https://core.telegram.org/bots/api#sendinvoice
method sendLocation
sendLocation: ( latitude: number, longitude: number, extra?: tt.ExtraLocation) => Promise<tg.Message.LocationMessage>;
See Also
https://core.telegram.org/bots/api#sendlocation
method sendMediaGroup
sendMediaGroup: ( media: tt.MediaGroup, extra?: tt.ExtraMediaGroup) => Promise< ( | tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage )[]>;
See Also
https://core.telegram.org/bots/api#sendmediagroup
method sendMessage
sendMessage: ( text: string | FmtString, extra?: tt.ExtraReplyMessage) => Promise<tg.Message.TextMessage>;
See Also
https://core.telegram.org/bots/api#sendmessage
method sendPhoto
sendPhoto: ( photo: string | tg.InputFile, extra?: tt.ExtraPhoto) => Promise<tg.Message.PhotoMessage>;
See Also
https://core.telegram.org/bots/api#sendphoto
method sendPoll
sendPoll: ( poll: string, options: readonly string[], extra?: tt.ExtraPoll) => Promise<tg.Message.PollMessage>;
See Also
https://core.telegram.org/bots/api#sendpoll
method sendQuiz
sendQuiz: ( quiz: string, options: readonly string[], extra?: tt.ExtraPoll) => Promise<tg.Message.PollMessage>;
See Also
https://core.telegram.org/bots/api#sendpoll
method sendSticker
sendSticker: ( sticker: string | tg.InputFile, extra?: tt.ExtraSticker) => Promise<tg.Message.StickerMessage>;
See Also
https://core.telegram.org/bots/api#sendsticker
method sendVenue
sendVenue: ( latitude: number, longitude: number, title: string, address: string, extra?: tt.ExtraVenue) => Promise<tg.Message.VenueMessage>;
See Also
https://core.telegram.org/bots/api#sendvenue
method sendVideo
sendVideo: ( video: string | tg.InputFile, extra?: tt.ExtraVideo) => Promise<tg.Message.VideoMessage>;
See Also
https://core.telegram.org/bots/api#sendvideo
method sendVideoNote
sendVideoNote: ( videoNote: string | tg.InputFileVideoNote, extra?: tt.ExtraVideoNote) => Promise<tg.Message.VideoNoteMessage>;
See Also
https://core.telegram.org/bots/api#sendvideonote
method sendVoice
sendVoice: ( voice: string | tg.InputFile, extra?: tt.ExtraVoice) => Promise<tg.Message.VoiceMessage>;
See Also
https://core.telegram.org/bots/api#sendvoice
method setChatAdministratorCustomTitle
setChatAdministratorCustomTitle: ( userId: number, title: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchatadministratorcustomtitle
method setChatDescription
setChatDescription: (description?: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchatdescription
method setChatMenuButton
setChatMenuButton: (menuButton?: tg.MenuButton) => Promise<true>;
Use this method to change the bot's menu button in the current private chat. Returns true on success.
See Also
https://core.telegram.org/bots/api#setchatmenubutton
method setChatPermissions
setChatPermissions: ( permissions: tg.ChatPermissions, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchatpermissions
method setChatPhoto
setChatPhoto: (photo: Typegram.Opts<tg.InputFile>) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchatphoto
method setChatStickerSet
setChatStickerSet: (setName: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchatstickerset
method setChatTitle
setChatTitle: (title: string) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setchattitle
method setCustomEmojiStickerSetThumbnail
setCustomEmojiStickerSetThumbnail: ( name: string, custom_emoji_id: string) => Promise<true>;
method setMyCommands
setMyCommands: (commands: readonly tg.BotCommand[]) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setmycommands
Deprecated
method setMyDefaultAdministratorRights
setMyDefaultAdministratorRights: ( extra?: Parameters<Telegram['setMyDefaultAdministratorRights']>[0]) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setmydefaultadministratorrights
method setPassportDataErrors
setPassportDataErrors: ( errors: readonly tg.PassportElementError[]) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setpassportdataerrors
method setStickerEmojiList
setStickerEmojiList: (sticker: string, emoji_list: string[]) => Promise<true>;
method setStickerKeywords
setStickerKeywords: (sticker: string, keywords?: string[]) => Promise<true>;
method setStickerMaskPosition
setStickerMaskPosition: ( sticker: string, mask_position?: tg.MaskPosition) => Promise<true>;
method setStickerPositionInSet
setStickerPositionInSet: (sticker: string, position: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setstickerpositioninset
Deprecated
method setStickerSetThumb
setStickerSetThumb: ( name: string, userId: number, thumbnail?: Typegram.Opts<tg.InputFile>) => Promise<true>;
See Also
https://core.telegram.org/bots/api#setstickersetthumbnail
Deprecated
method setStickerSetThumbnail
setStickerSetThumbnail: ( name: string, userId: number, thumbnail?: Typegram.Opts<tg.InputFile>) => Promise<true>;
method setStickerSetTitle
setStickerSetTitle: (name: string, title: string) => Promise<true>;
method stopMessageLiveLocation
stopMessageLiveLocation: ( markup?: tg.InlineKeyboardMarkup) => Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
See Also
https://core.telegram.org/bots/api#stopmessagelivelocation
method stopPoll
stopPoll: ( messageId: number, extra?: { [x: string]: Typegram.Opts<tg.InputFile>; [x: number]: Typegram.Opts<tg.InputFile>; [x: symbol]: Typegram.Opts<tg.InputFile>; caption?: string | FmtString<string>; }) => Promise<tg.Poll>;
See Also
https://core.telegram.org/bots/api#stoppoll
method unbanChatMember
unbanChatMember: ( userId: number, extra?: { only_if_banned?: boolean }) => Promise<true>;
See Also
https://core.telegram.org/bots/api#unbanchatmember
method unbanChatSenderChat
unbanChatSenderChat: (senderChatId: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#unbanchatsenderchat
method unhideGeneralForumTopic
unhideGeneralForumTopic: () => Promise<true>;
Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
See Also
https://core.telegram.org/bots/api#unhidegeneralforumtopic
method unpinAllChatMessages
unpinAllChatMessages: () => Promise<true>;
See Also
https://core.telegram.org/bots/api#unpinallchatmessages
method unpinAllForumTopicMessages
unpinAllForumTopicMessages: () => Promise<true>;
Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
See Also
https://core.telegram.org/bots/api#unpinallforumtopicmessages
method unpinAllGeneralForumTopicMessages
unpinAllGeneralForumTopicMessages: () => Promise<true>;
Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
See Also
https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages
method unpinChatMessage
unpinChatMessage: (messageId?: number) => Promise<true>;
See Also
https://core.telegram.org/bots/api#unpinchatmessage
method uploadStickerFile
uploadStickerFile: ( sticker: Typegram.Opts<tg.InputFile>, sticker_format: Typegram.Opts<tg.InputFile>) => Promise<tg.File>;
See Also
https://core.telegram.org/bots/api#uploadstickerfile
class MemorySessionStore
class MemorySessionStore<T> implements SyncSessionStore<T> {}
Deprecated
Use
Map
constructor
constructor(ttl?: number);
method delete
delete: (name: string) => void;
method get
get: (name: string) => T | undefined;
method set
set: (name: string, value: T) => void;
class Router
class Router<C extends Context> implements MiddlewareObj<C> {}
Deprecated
in favor of Composer.dispatch
constructor
constructor(routeFn: RouteFn<C>, handlers?: Map<string, Middleware<C, Update>>);
property handlers
handlers: Map<string, Middleware<C, Update>>;
method middleware
middleware: () => import('./middleware').MiddlewareFn<C>;
method on
on: ( route: string, fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => this;
method otherwise
otherwise: ( fns_0: Middleware<C, Update>, ...fns_1: Middleware<C, Update>[]) => this;
class Telegraf
class Telegraf<C extends Context = Context> extends Composer<C> {}
constructor
constructor(token: string, options?: Partial<Telegraf.Options<C>>);
property botInfo
botInfo?: tg.UserFromGetMe;
Set manually to avoid implicit
getMe
call inlaunch
orwebhookCallback
property context
readonly context: Partial<C>;
property telegram
telegram: Telegram;
property webhookFilter
webhookFilter: ( this: { hookPath: string; path: string; secretToken?: string }, req: http.IncomingMessage) => boolean;
Assign to this to customise the webhook filter middleware.
{ path, secretToken }
will be bound to this rather than the Telegraf instance. Remember to assign a regular function and not an arrow function so it's bindable.
property webhookReply
webhookReply: boolean;
Deprecated
use
ctx.telegram.webhookReply
method catch
catch: (handler: (err: unknown, ctx: C) => MaybePromise<void>) => this;
_Override_ error handling
method createWebhook
createWebhook: ( opts: { domain: string; path?: string } & tt.ExtraSetWebhook) => Promise< ( req: http.IncomingMessage & { body?: tg.Update | undefined }, res: http.ServerResponse<http.IncomingMessage>, next?: () => void ) => Promise<void>>;
Specify a url to receive incoming updates via webhook. Returns an Express-style middleware you can pass to app.use()
method handleUpdate
handleUpdate: ( update: tg.Update, webhookResponse?: http.ServerResponse) => Promise<void>;
method launch
launch: { (onLaunch?: () => void): Promise<void>; (config: Telegraf.LaunchOptions, onLaunch?: () => void): Promise<void>;};
method secretPathComponent
secretPathComponent: () => string;
method stop
stop: (reason?: string) => void;
method webhookCallback
webhookCallback: ( path?: string, opts?: { secretToken?: string }) => ( req: http.IncomingMessage & { body?: tg.Update | undefined }, res: http.ServerResponse<http.IncomingMessage>, next?: () => void) => Promise<void>;
You must call
bot.telegram.setWebhook
for this to work. You should probably use Telegraf.createWebhook instead.
class Telegram
class Telegram extends ApiClient {}
property kickChatMember
readonly kickChatMember: ( chatId: string | number, userId: number, untilDate?: number | undefined, extra?: | Omit< { chat_id: string | number; user_id: number; until_date?: number | undefined; revoke_messages?: boolean | undefined; }, 'chat_id' | 'user_id' | 'until_date' > | undefined) => 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.
Parameter chatId
Unique identifier for the target group or username of the target supergroup or channel (in the format
@channelusername
)Parameter 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
Deprecated
since API 5.3. Use Telegram.banChatMember
property setStickerSetThumb
readonly setStickerSetThumb: ( name: string, userId: number, thumbnail?: string | tg.InputFile | undefined) => Promise<true>;
Deprecated
since API 6.8. Use Telegram.setStickerSetThumbnail
method addStickerToSet
addStickerToSet: ( ownerId: number, name: string, stickerData: tt.ExtraAddStickerToSet) => Promise<true>;
Add a new sticker to a set created by the bot.
Parameter ownerId
User identifier of sticker set owner
Parameter name
Sticker set name
method answerCbQuery
answerCbQuery: ( callbackQueryId: string, text?: string, extra?: tt.ExtraAnswerCbQuery) => Promise<true>;
method answerGameQuery
answerGameQuery: (callbackQueryId: string, url: string) => Promise<true>;
method answerInlineQuery
answerInlineQuery: ( inlineQueryId: string, results: readonly tg.InlineQueryResult[], extra?: tt.ExtraAnswerInlineQuery) => Promise<true>;
Send answers to an inline query. No more than 50 results per query are allowed.
method answerPreCheckoutQuery
answerPreCheckoutQuery: ( preCheckoutQueryId: string, ok: boolean, errorMessage?: string) => 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.
Parameter 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.
Parameter 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.
method answerShippingQuery
answerShippingQuery: ( shippingQueryId: string, ok: boolean, shippingOptions: readonly tg.ShippingOption[] | undefined, errorMessage: string | undefined) => 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.
Parameter 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)
Parameter shippingOptions
Required if ok is True. A JSON-serialized array of available shipping options.
Parameter 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.
method answerWebAppQuery
answerWebAppQuery: ( webAppQueryId: string, result: tg.InlineQueryResult) => Promise<tg.SentWebAppMessage>;
method approveChatJoinRequest
approveChatJoinRequest: ( chatId: number | string, userId: number) => Promise<true>;
Approve a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter userId
Unique identifier of the target user
method banChatMember
banChatMember: ( chatId: number | string, userId: number, untilDate?: number, extra?: tt.ExtraBanChatMember) => 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.
Parameter chatId
Unique identifier for the target group or username of the target supergroup or channel (in the format
@channelusername
)Parameter 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
method banChatSenderChat
banChatSenderChat: ( chatId: number | string, senderChatId: number, extra?: tt.ExtraBanChatSenderChat) => Promise<true>;
Ban a channel chat in a supergroup or a channel. The owner of the chat will not be able to send messages and join live streams on behalf of the chat, unless it is unbanned first. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter senderChatId
Unique identifier of the target sender chat
method close
close: () => Promise<true>;
Close the bot instance before moving it from one local server to another.
method closeForumTopic
closeForumTopic: ( chat_id: number | string, message_thread_id: number) => Promise<true>;
Use this method to close an open topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message_thread_id
Unique identifier for the target message thread of the forum topic
See Also
https://core.telegram.org/bots/api#closeforumtopic
method closeGeneralForumTopic
closeGeneralForumTopic: (chat_id: number | string) => Promise<true>;
Use this method to close an open 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
See Also
https://core.telegram.org/bots/api#closegeneralforumtopic
method copyMessage
copyMessage: ( chatId: number | string, fromChatId: number | string, messageId: number, extra?: tt.ExtraCopyMessage) => Promise<tg.MessageId>;
Send copy of existing message.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter fromChatId
Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
Parameter messageId
Message identifier in the chat specified in from_chat_id
method copyMessages
copyMessages: ( chatId: number | string, fromChatId: number | string, messageIds: number[], extra?: tt.ExtraCopyMessages) => Promise<tg.MessageId[]>;
Use this method to copy messages of any kind. If some of the specified messages can't be found or copied, they are skipped. Service messages, giveaway messages, giveaway winners messages, and invoice messages can't be copied. A quiz poll can be copied only if the value of the field correct_option_id is known to the bot. The method is analogous to the method forwardMessages, but the copied messages don't have a link to the original message. Album grouping is kept for copied messages.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter fromChatId
Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
Parameter messageIds
Identifiers of 1-100 messages in the chat from_chat_id to copy. The identifiers must be specified in a strictly increasing order.
method createChatInviteLink
createChatInviteLink: ( chatId: number | string, extra?: tt.ExtraCreateChatInviteLink) => Promise<tg.ChatInviteLink>;
method createForumTopic
createForumTopic: ( chat_id: number | string, name: string, extra?: tt.ExtraCreateForumTopic) => Promise<tg.ForumTopic>;
Use this method to create a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns information about the created topic as a ForumTopic object.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter name
Topic name, 1-128 characters
See Also
https://core.telegram.org/bots/api#createforumtopic
method createInvoiceLink
createInvoiceLink: (invoice: tt.NewInvoiceLinkParameters) => Promise<string>;
method createNewStickerSet
createNewStickerSet: ( ownerId: number, name: string, title: string, stickerData: tt.ExtraCreateNewStickerSet) => Promise<true>;
Create new sticker set owned by a user. The bot will be able to edit the created sticker set.
Parameter ownerId
User identifier of created sticker set owner
Parameter 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.
Parameter title
Sticker set title, 1-64 characters
method declineChatJoinRequest
declineChatJoinRequest: ( chatId: number | string, userId: number) => Promise<true>;
Decline a chat join request. The bot must be an administrator in the chat for this to work and must have the can_invite_users administrator right.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter userId
Unique identifier of the target user
method deleteChatPhoto
deleteChatPhoto: (chatId: number | string) => Promise<true>;
method deleteChatStickerSet
deleteChatStickerSet: (chatId: number | string) => Promise<true>;
method deleteForumTopic
deleteForumTopic: ( chat_id: number | string, message_thread_id: number) => Promise<true>;
Use this method to delete a forum topic along with all its messages in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_delete_messages administrator rights. Returns True on success.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message_thread_id
Unique identifier for the target message thread of the forum topic
See Also
https://core.telegram.org/bots/api#deleteforumtopic
method deleteMessage
deleteMessage: (chatId: number | string, messageId: number) => Promise<true>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Identifier of the message to delete
method deleteMessages
deleteMessages: (chatId: number | string, messageIds: number[]) => Promise<true>;
Use this method to delete multiple messages simultaneously. If some of the specified messages can't be found, they are skipped.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageIds
Identifiers of 1-100 messages to delete. See deleteMessage for limitations on which messages can be deleted
method deleteMyCommands
deleteMyCommands: (extra?: Typegram.Opts<tg.InputFile>) => Promise<true>;
method deleteStickerFromSet
deleteStickerFromSet: (sticker: string) => Promise<true>;
Delete a sticker from a set created by the bot.
Parameter sticker
File identifier of the sticker
method deleteStickerSet
deleteStickerSet: (name: string) => Promise<true>;
method deleteWebhook
deleteWebhook: (extra?: { drop_pending_updates?: boolean }) => Promise<true>;
Remove webhook integration.
method editChatInviteLink
editChatInviteLink: ( chatId: number | string, inviteLink: string, extra?: tt.ExtraEditChatInviteLink) => Promise<tg.ChatInviteLink>;
method editForumTopic
editForumTopic: ( chat_id: number | string, message_thread_id: number, extra: tt.ExtraEditForumTopic) => Promise<true>;
Use this method to edit name and icon of a topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message_thread_id
Unique identifier for the target message thread of the forum topic
See Also
https://core.telegram.org/bots/api#editforumtopic
method editGeneralForumTopic
editGeneralForumTopic: (chat_id: number | string, name: string) => Promise<true>;
Use this method to edit the name of the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have can_manage_topics administrator rights. Returns True on success.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
Parameter name
New topic name, 1-128 characters
See Also
https://core.telegram.org/bots/api#editgeneralforumtopic
method editMessageCaption
editMessageCaption: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, caption: string | FmtString | undefined, extra?: tt.ExtraEditMessageCaption) => Promise<true | (tg.Update.Edited & tg.Message.CaptionableMessage)>;
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.
Parameter chatId
Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Required if inlineMessageId is not specified. Identifier of the sent message
Parameter inlineMessageId
Required if chatId and messageId are not specified. Identifier of the inline message
Parameter caption
New caption of the message
Parameter markup
A JSON-serialized object for an inline keyboard.
method editMessageLiveLocation
editMessageLiveLocation: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, latitude: number, longitude: number, extra?: tt.ExtraEditMessageLiveLocation) => Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
method editMessageMedia
editMessageMedia: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, media: tt.WrapCaption<tg.InputMedia>, extra?: tt.ExtraEditMessageMedia) => Promise<true | (tg.Update.Edited & tg.Message)>;
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.
Parameter chatId
Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Required if inlineMessageId is not specified. Identifier of the sent message
Parameter inlineMessageId
Required if chatId and messageId are not specified. Identifier of the inline message
Parameter media
New media of message
Parameter extra
Additional parameters, such as reply_markup
method editMessageReplyMarkup
editMessageReplyMarkup: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, markup: tg.InlineKeyboardMarkup | undefined) => Promise<true | (tg.Update.Edited & tg.Message)>;
Edit only the reply markup of messages sent by the bot or via the bot (for inline bots).
Parameter chatId
Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Required if inlineMessageId is not specified. Identifier of the sent message
Parameter inlineMessageId
Required if chatId and messageId are not specified. Identifier of the inline message
Parameter 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.
method editMessageText
editMessageText: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, text: string | FmtString, extra?: tt.ExtraEditMessageText) => Promise<true | (tg.Update.Edited & tg.Message.TextMessage)>;
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.
Parameter chatId
Required if inlineMessageId is not specified. Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Required if inlineMessageId is not specified. Identifier of the sent message
Parameter inlineMessageId
Required if chatId and messageId are not specified. Identifier of the inline message
Parameter text
New text of the message
method exportChatInviteLink
exportChatInviteLink: (chatId: number | string) => Promise<string>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method forwardMessage
forwardMessage: ( chatId: number | string, fromChatId: number | string, messageId: number, extra?: tt.ExtraForwardMessage) => Promise<tg.Message>;
Forward existing message.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter fromChatId
Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
Parameter messageId
Message identifier in the chat specified in from_chat_id
method forwardMessages
forwardMessages: ( chatId: number | string, fromChatId: number | string, messageIds: number[], extra?: tt.ExtraForwardMessages) => Promise<tg.MessageId[]>;
Use this method to forward multiple messages of any kind. If some of the specified messages can't be found or forwarded, they are skipped. Service messages and messages with protected content can't be forwarded. Album grouping is kept for forwarded messages.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter fromChatId
Unique identifier for the chat where the original messages were sent (or channel username in the format @channelusername)
Parameter messageIds
Identifiers of 1-100 messages in the chat from_chat_id to forward. The identifiers must be specified in a strictly increasing order.
method getChat
getChat: (chatId: number | string) => Promise<tg.ChatFromGetChat>;
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.).
Parameter chatId
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
method getChatAdministrators
getChatAdministrators: ( chatId: number | string) => Promise<(tg.ChatMemberOwner | tg.ChatMemberAdministrator)[]>;
Parameter chatId
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
method getChatMember
getChatMember: ( chatId: string | number, userId: number) => Promise<tg.ChatMember>;
Get information about a member of a chat.
Parameter chatId
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
Parameter userId
Unique identifier of the target user
method getChatMembersCount
getChatMembersCount: (chatId: string | number) => Promise<number>;
Get the number of members in a chat.
Parameter chatId
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
method getChatMenuButton
getChatMenuButton: ({ chatId }?: { chatId?: number }) => Promise<tg.MenuButton>;
Use this method to get the current value of the bot's menu button in a private chat, or the default menu button. Returns MenuButton on success.
Parameter chatId
Unique identifier for the target private chat. If not specified, default bot's menu button will be returned.
method getCustomEmojiStickers
getCustomEmojiStickers: (custom_emoji_ids: string[]) => Promise<tg.Sticker[]>;
method getFile
getFile: (fileId: string) => Promise<tg.File>;
Get basic info about a file and prepare it for downloading.
Parameter fileId
Id of file to get link to
method getFileLink
getFileLink: (fileId: string | tg.File) => Promise<URL>;
Get download link to a file.
method getForumTopicIconStickers
getForumTopicIconStickers: () => Promise<tg.Sticker[]>;
Use this method to get custom emoji stickers, which can be used as a forum topic icon by any user. Requires no parameters. Returns an Array of Sticker objects.
See Also
https://core.telegram.org/bots/api#getforumtopiciconstickers
method getGameHighScores
getGameHighScores: ( userId: number, inlineMessageId: string | undefined, chatId: number | undefined, messageId: number | undefined) => Promise<tg.GameHighScore[]>;
method getMe
getMe: () => Promise<tg.UserFromGetMe>;
Get basic information about the bot
method getMyCommands
getMyCommands: (extra?: Typegram.Opts<tg.InputFile>) => Promise<tg.BotCommand[]>;
Get the current list of the bot's commands.
method getMyDefaultAdministratorRights
getMyDefaultAdministratorRights: ({ forChannels,}?: { forChannels?: boolean;}) => Promise<tg.ChatAdministratorRights>;
Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
Parameter forChannels
Pass true to get default administrator rights of the bot in channels. Otherwise, default administrator rights of the bot for groups and supergroups will be returned.
method getMyDescription
getMyDescription: (language_code?: string) => Promise<tg.BotDescription>;
Use this method to get the current bot description for the given user language.
Parameter language_code
A two-letter ISO 639-1 language code.
method getMyName
getMyName: (language_code?: string) => Promise<tg.BotName>;
Use this method to get the current bot name for the given user language.
Parameter language_code
A two-letter ISO 639-1 language code or an empty string
method getMyShortDescription
getMyShortDescription: ( language_code?: string) => Promise<tg.BotShortDescription>;
Use this method to get the current bot short description for the given user language.
Parameter language_code
A two-letter ISO 639-1 language code or an empty string
method getStickerSet
getStickerSet: (name: string) => Promise<tg.StickerSet>;
method getUpdates
getUpdates: ( timeout: number, limit: number, offset: number, allowedUpdates: readonly tt.UpdateType[] | undefined) => Promise<tg.Update[]>;
Directly request incoming updates. You should probably use
Telegraf::launch
instead.
method getUserChatBoosts
getUserChatBoosts: ( chat_id: number | string, user_id: number) => Promise<tg.UserChatBoosts[]>;
Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. Returns a UserChatBoosts object.
Parameter chat_id
Unique identifier for the chat or username of the channel (in the format
@channelusername
)Parameter user_id
Unique identifier of the target user
method getUserProfilePhotos
getUserProfilePhotos: ( userId: number, offset?: number, limit?: number) => Promise<tg.UserProfilePhotos>;
method getWebhookInfo
getWebhookInfo: () => Promise<tg.WebhookInfo>;
method hideGeneralForumTopic
hideGeneralForumTopic: (chat_id: number | string) => Promise<true>;
Use this method to hide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically closed if it was open. Returns True on success.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
See Also
https://core.telegram.org/bots/api#hidegeneralforumtopic
method leaveChat
leaveChat: (chatId: number | string) => Promise<true>;
Use this method for your bot to leave a group, supergroup or channel.
Parameter chatId
Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
method logOut
logOut: () => Promise<true>;
Log out from the cloud Bot API server before launching the bot locally.
method pinChatMessage
pinChatMessage: ( chatId: number | string, messageId: number, extra?: { disable_notification?: boolean }) => 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.
Parameter chatId
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
method promoteChatMember
promoteChatMember: ( chatId: number | string, userId: number, extra: tt.ExtraPromoteChatMember) => 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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format
@channelusername
)
method reopenForumTopic
reopenForumTopic: ( chat_id: number | string, message_thread_id: number) => Promise<true>;
Use this method to reopen a closed topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights, unless it is the creator of the topic. Returns True on success.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message_thread_id
Unique identifier for the target message thread of the forum topic
See Also
https://core.telegram.org/bots/api#reopenforumtopic
method reopenGeneralForumTopic
reopenGeneralForumTopic: (chat_id: number | string) => Promise<true>;
Use this method to reopen a closed 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. The topic will be automatically unhidden if it was hidden. Returns True on success.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
See Also
https://core.telegram.org/bots/api#reopengeneralforumtopic
method restrictChatMember
restrictChatMember: ( chatId: string | number, userId: number, extra: tt.ExtraRestrictChatMember) => 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.
Parameter chatId
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
method revokeChatInviteLink
revokeChatInviteLink: ( chatId: number | string, inviteLink: string) => Promise<tg.ChatInviteLink>;
method sendAnimation
sendAnimation: ( chatId: number | string, animation: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraAnimation) => Promise<tg.Message.AnimationMessage>;
Send .gif animations.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendAudio
sendAudio: ( chatId: number | string, audio: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraAudio) => Promise<tg.Message.AudioMessage>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendChatAction
sendChatAction: ( chat_id: number | string, action: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraSendChatAction) => Promise<true>;
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).
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendContact
sendContact: ( chatId: number | string, phoneNumber: string, firstName: string, extra?: tt.ExtraContact) => Promise<tg.Message.ContactMessage>;
method sendCopy
sendCopy: ( chatId: number | string, message: tg.Message, extra?: tt.ExtraCopyMessage) => Promise<tg.MessageId>;
Send copy of existing message.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message
Received message object
Deprecated
use
copyMessage
instead
method sendDice
sendDice: ( chatId: number | string, extra?: tt.ExtraDice) => Promise<tg.Message.DiceMessage>;
Send a dice, which will have a random value from 1 to 6.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendDocument
sendDocument: ( chatId: number | string, document: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraDocument) => Promise<tg.Message.DocumentMessage>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendGame
sendGame: ( chatId: number, gameName: string, extra?: tt.ExtraGame) => Promise<tg.Message.GameMessage>;
Parameter chatId
Unique identifier for the target chat
Parameter gameShortName
Short name of the game, serves as the unique identifier for the game. Set up your games via Botfather.
method sendInvoice
sendInvoice: ( chatId: number | string, invoice: tt.NewInvoiceParameters, extra?: tt.ExtraInvoice) => Promise<tg.Message.InvoiceMessage>;
Parameter chatId
Unique identifier for the target private chat
method sendLocation
sendLocation: ( chatId: number | string, latitude: number, longitude: number, extra?: tt.ExtraLocation) => Promise<tg.Message.LocationMessage>;
Send point on the map.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendMediaGroup
sendMediaGroup: ( chatId: number | string, media: tt.MediaGroup, extra?: tt.ExtraMediaGroup) => Promise< ( | tg.Message.DocumentMessage | tg.Message.AudioMessage | tg.Message.PhotoMessage | tg.Message.VideoMessage )[]>;
Send a group of photos or videos as an album.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter media
A JSON-serialized array describing photos and videos to be sent, must include 2–10 items
method sendMessage
sendMessage: ( chatId: number | string, text: string | FmtString, extra?: tt.ExtraReplyMessage) => Promise<tg.Message.TextMessage>;
Send a text message.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter text
Text of the message to be sent
method sendPhoto
sendPhoto: ( chatId: number | string, photo: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraPhoto) => Promise<tg.Message.PhotoMessage>;
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendPoll
sendPoll: ( chatId: number | string, question: string, options: readonly string[], extra?: tt.ExtraPoll) => Promise<tg.Message.PollMessage>;
Send a native poll.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter question
Poll question, 1-255 characters
Parameter options
A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
method sendQuiz
sendQuiz: ( chatId: number | string, question: string, options: readonly string[], extra?: tt.ExtraPoll) => Promise<tg.Message.PollMessage>;
Send a native quiz.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter question
Poll question, 1-255 characters
Parameter options
A JSON-serialized list of answer options, 2-10 strings 1-100 characters each
method sendSticker
sendSticker: ( chatId: number | string, sticker: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraSticker) => Promise<tg.Message.StickerMessage>;
Send .webp, animated .tgs, or video .webm stickers
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendVenue
sendVenue: ( chatId: number | string, latitude: number, longitude: number, title: string, address: string, extra?: tt.ExtraVenue) => Promise<tg.Message.VenueMessage>;
method sendVideo
sendVideo: ( chatId: number | string, video: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraVideo) => Promise<tg.Message.VideoMessage>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendVideoNote
sendVideoNote: ( chatId: number | string, videoNote: string | tg.InputFileVideoNote, extra?: tt.ExtraVideoNote) => Promise<tg.Message.VideoNoteMessage>;
Send video messages.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method sendVoice
sendVoice: ( chatId: number | string, voice: Typegram.Opts<tg.InputFile>, extra?: tt.ExtraVoice) => Promise<tg.Message.VoiceMessage>;
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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method setChatAdministratorCustomTitle
setChatAdministratorCustomTitle: ( chatId: number | string, userId: number, title: string) => Promise<true>;
method setChatDescription
setChatDescription: ( chatId: number | string, description?: string) => Promise<true>;
method setChatMenuButton
setChatMenuButton: ({ chatId, menuButton,}?: { chatId?: number | undefined; menuButton?: tg.MenuButton | undefined;}) => Promise<true>;
Use this method to change the bot's menu button in a private chat, or the default menu button. Returns true on success.
Parameter chatId
Unique identifier for the target private chat. If not specified, default bot's menu button will be changed.
Parameter menuButton
An object for the bot's new menu button.
method setChatPermissions
setChatPermissions: ( chatId: number | string, permissions: tg.ChatPermissions, extra?: tt.ExtraSetChatPermissions) => Promise<true>;
method setChatPhoto
setChatPhoto: ( chatId: number | string, photo: Typegram.Opts<tg.InputFile>) => Promise<true>;
method setChatStickerSet
setChatStickerSet: (chatId: number | string, setName: string) => Promise<true>;
method setChatTitle
setChatTitle: (chatId: number | string, title: 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.
Parameter chatId
Unique identifier for the target group or username of the target supergroup or channel (in the format
@channelusername
)Parameter title
New chat title, 1-255 characters
method setCustomEmojiStickerSetThumbnail
setCustomEmojiStickerSetThumbnail: ( name: string, custom_emoji_id: string) => Promise<true>;
method setGameScore
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)>;
method setMessageReaction
setMessageReaction: ( chat_id: number | string, message_id: number, reaction?: tg.ReactionType[], is_big?: boolean) => Promise<true>;
Use this method to change the chosen reactions on a message. Service messages can't be reacted to. Automatically forwarded messages from a channel to its discussion group have the same available reactions as messages in the channel. In albums, bots must react to the first message.
Parameter chat_id
Unique identifier for the target chat or username of the target channel (in the format
@channelusername
)Parameter message_id
Identifier of the target message
Parameter reaction
New list of reaction types to set on the message. Currently, as non-premium users, bots can set up to one reaction per message. A custom emoji reaction can be used if it is either already present on the message or explicitly allowed by chat administrators.
Parameter is_big
Pass True to set the reaction with a big animation
Returns
method setMyCommands
setMyCommands: ( commands: readonly tg.BotCommand[], extra?: tt.ExtraSetMyCommands) => Promise<true>;
Change the list of the bot's commands.
Parameter commands
A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
method setMyDefaultAdministratorRights
setMyDefaultAdministratorRights: ({ rights, forChannels,}?: { rights?: tg.ChatAdministratorRights; forChannels?: boolean;}) => Promise<true>;
Use this method to change the default administrator rights requested by the bot when it's added as an administrator to groups or channels. These rights will be suggested to users, but they are are free to modify the list before adding the bot.
method setMyDescription
setMyDescription: (description: string, language_code?: string) => Promise<true>;
Use this method to change the bot's description, which is shown in the chat with the bot if the chat is empty.
Parameter description
New bot description; 0-512 characters. Pass an empty string to remove the dedicated description for the given language.
Parameter language_code
A two-letter ISO 639-1 language code. If empty, the description will be applied to all users for whose language there is no dedicated description.
method setMyName
setMyName: (name: string, language_code?: string) => Promise<true>;
Use this method to change the bot's name.
Parameter name
New bot name; 0-64 characters. Pass an empty string to remove the dedicated name for the given language.
Parameter language_code
A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose language there is no dedicated name.
method setMyShortDescription
setMyShortDescription: ( short_description: string, language_code?: string) => Promise<true>;
Use this method to change the bot's short description, which is shown on the bot's profile page and is sent together with the link when users share the bot.
Parameter description
New short description for the bot; 0-120 characters. Pass an empty string to remove the dedicated short description for the given language.
Parameter language_code
A two-letter ISO 639-1 language code. If empty, the short description will be applied to all users for whose language there is no dedicated short description.
method setPassportDataErrors
setPassportDataErrors: ( userId: number, errors: readonly tg.PassportElementError[]) => Promise<true>;
method setStickerEmojiList
setStickerEmojiList: (sticker: string, emoji_list: string[]) => Promise<true>;
method setStickerKeywords
setStickerKeywords: (sticker: string, keywords?: string[]) => Promise<true>;
method setStickerMaskPosition
setStickerMaskPosition: ( sticker: string, mask_position?: tg.MaskPosition) => Promise<true>;
method setStickerPositionInSet
setStickerPositionInSet: (sticker: string, position: number) => Promise<true>;
Move a sticker in a set created by the bot to a specific position.
Parameter sticker
File identifier of the sticker
Parameter position
New sticker position in the set, zero-based
method setStickerSetThumbnail
setStickerSetThumbnail: ( name: string, userId: number, thumbnail?: Typegram.Opts<tg.InputFile>) => Promise<true>;
Use this method to set the thumbnail of a regular or mask sticker set. The format of the thumbnail file must match the format of the stickers in the set.
Parameter name
Sticker set name
Parameter userId
User identifier of the sticker set owner
Parameter thumbnail
A .WEBP or .PNG image with the thumbnail, must be up to 128 kilobytes in size and have a width and height of exactly 100px, or a .TGS animation with a thumbnail up to 32 kilobytes in size (see [animated sticker technical requirements](https://core.telegram.org/stickers#animated-sticker-requirements)), or a WEBM video with the thumbnail up to 32 kilobytes in size; see [video sticker technical requirements](https://core.telegram.org/stickers#video-sticker-requirements). Pass a file_id as a String to send a file that already exists on the Telegram servers, pass a HTTP URL as a String for Telegram to get a file from the Internet, or upload a new one using Input helpers. Animated and video sticker set thumbnails can't be uploaded via HTTP URL. If omitted, then the thumbnail is dropped and the first sticker is used as the thumbnail.
method setStickerSetTitle
setStickerSetTitle: (name: string, title: string) => Promise<true>;
method setWebhook
setWebhook: (url: string, extra?: tt.ExtraSetWebhook) => Promise<true>;
Specify a url to receive incoming updates via an outgoing webhook.
Parameter url
HTTPS url to send updates to. Use an empty string to remove webhook integration
method stopMessageLiveLocation
stopMessageLiveLocation: ( chatId: number | string | undefined, messageId: number | undefined, inlineMessageId: string | undefined, markup?: tg.InlineKeyboardMarkup) => Promise<true | (tg.Update.Edited & tg.Message.LocationMessage)>;
method stopPoll
stopPoll: ( chatId: number | string, messageId: number, extra?: tt.ExtraStopPoll) => Promise<tg.Poll>;
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter messageId
Identifier of the original message with the poll
method unbanChatMember
unbanChatMember: ( chatId: number | string, userId: number, extra?: { only_if_banned?: boolean }) => 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.
Parameter chatId
Unique identifier for the target group or username of the target supergroup or channel (in the format @username)
Parameter userId
Unique identifier of the target user
method unbanChatSenderChat
unbanChatSenderChat: ( chatId: number | string, senderChatId: number) => Promise<true>;
Unban a previously banned channel chat in a supergroup or channel. The bot must be an administrator for this to work and must have the appropriate administrator rights.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter senderChatId
Unique identifier of the target sender chat
method unhideGeneralForumTopic
unhideGeneralForumTopic: (chat_id: number | string) => Promise<true>;
Use this method to unhide the 'General' topic in a forum supergroup chat. The bot must be an administrator in the chat for this to work and must have the can_manage_topics administrator rights. Returns True on success.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
See Also
https://core.telegram.org/bots/api#unhidegeneralforumtopic
method unpinAllChatMessages
unpinAllChatMessages: (chatId: number | string) => Promise<true>;
Clear the list of pinned messages in a chat.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method unpinAllForumTopicMessages
unpinAllForumTopicMessages: ( chat_id: number | string, message_thread_id: number) => Promise<true>;
Use this method to clear the list of pinned messages in a forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup. Returns True on success.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
Parameter message_thread_id
Unique identifier for the target message thread of the forum topic
See Also
https://core.telegram.org/bots/api#unpinallforumtopicmessages
method unpinAllGeneralForumTopicMessages
unpinAllGeneralForumTopicMessages: (chat_id: number | string) => Promise<true>;
Use this method to clear the list of pinned messages in a General forum topic. The bot must be an administrator in the chat for this to work and must have the can_pin_messages administrator right in the supergroup.
Parameter chat_id
Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
method unpinChatMessage
unpinChatMessage: (chatId: number | string, messageId?: number) => 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.
Parameter chatId
Unique identifier for the target chat or username of the target channel (in the format @channelusername)
method uploadStickerFile
uploadStickerFile: ( ownerId: number, sticker: Typegram.Opts<tg.InputFile>, sticker_format: Typegram.Opts<tg.InputFile>) => Promise<tg.File>;
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
Parameter ownerId
User identifier of sticker file owner
Parameter 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.
class TelegramError
class TelegramError extends Error {}
constructor
constructor(response: ErrorPayload, on?: {});
property code
readonly code: number;
property description
readonly description: string;
property on
readonly on: {};
property parameters
readonly parameters: any;
property response
readonly response: ErrorPayload;
Interfaces
interface MiddlewareObj
interface MiddlewareObj<C extends Context<U>, U extends Update = Update> {}
property middleware
middleware: () => MiddlewareFn<C, U>;
Type Aliases
type Middleware
type Middleware<C extends Context<U>, U extends Update = Update> = | MiddlewareFn<C, U> | MiddlewareObj<C, U>;
type MiddlewareFn
type MiddlewareFn<C extends Context<U>, U extends Update = Update> = ( ctx: C, next: () => Promise<void>) => Promise<unknown> | void;
type NarrowedContext
type NarrowedContext<C extends Context, U extends tg.Update> = Context<U> & Omit<C, keyof Context>;
Narrows down
C['update']
(and derived getters) to specific update typeU
.Used by [[
Composer
]], possibly useful for splitting a bot into multiple files.
type SessionStore
type SessionStore<T> = SyncSessionStore<T> | AsyncSessionStore<T>;
Namespaces
namespace Format
module 'typings/format.d.ts' {}
variable bold
const bold: Nests< 'bold', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler'>;
variable code
const code: Nests<'code', never>;
variable fmt
const fmt: Nests<'fmt', string>;
variable italic
const italic: Nests< 'italic', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler'>;
variable join
const join: Nests<'fmt', string>;
variable quote
const quote: Nests< 'blockquote', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code'>;
variable spoiler
const spoiler: Nests< 'spoiler', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler'>;
variable strikethrough
const strikethrough: Nests< 'strikethrough', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler'>;
variable underline
const underline: Nests< 'underline', 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler'>;
function link
link: ( content: Nestable< | 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' >, url: string) => FmtString<'text_link'>;
function mention
mention: ( name: Nestable< | 'fmt' | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'spoiler' | 'code' >, user: number | User) => FmtString<'text_link'> | FmtString<'text_mention'>;
function pre
pre: (language: string) => Nests<'pre', never>;
class FmtString
class FmtString<Brand extends string = string> implements FmtString<Brand> {}
constructor
constructor(text: string, entities?: MessageEntity[]);
property text
text: string;
method normalise
static normalise: (content: Nestable<string>) => FmtString<string>;
interface FmtString
interface FmtString<Brand extends string> {}
property entities
entities?: MessageEntity[];
property parse_mode
parse_mode?: undefined;
property text
text: string;
namespace Input
module 'typings/input.d.ts' {}
The local file specified by path will be uploaded to Telegram using multipart/form-data.
10 MB max size for photos, 50 MB for other files.
function fromBuffer
fromBuffer: (buffer: Buffer, filename?: string) => InputFile;
The buffer will be uploaded as file to Telegram using multipart/form-data.
10 MB max size for photos, 50 MB for other files.
function fromFileId
fromFileId: (fileId: string) => string;
If the file is already stored somewhere on the Telegram servers, you don't need to reupload it: each file object has a file_id field, simply pass this file_id as a parameter instead of uploading.
It is not possible to change the file type when resending by file_id.
It is not possible to resend thumbnails using file_id. They have to be uploaded using one of the other Input methods.
There are no limits for files sent this way.
function fromLocalFile
fromLocalFile: (path: string, filename?: string) => InputFile;
The local file specified by path will be uploaded to Telegram using multipart/form-data.
10 MB max size for photos, 50 MB for other files.
function fromReadableStream
fromReadableStream: ( stream: NodeJS.ReadableStream, filename?: string) => InputFile;
Contents of the stream will be uploaded as file to Telegram using multipart/form-data.
10 MB max size for photos, 50 MB for other files.
function fromURL
fromURL: (url: string | URL) => string;
Provide Telegram with an HTTP URL for the file to be sent. Telegram will download and send the file.
* The target file must have the correct MIME type (e.g., audio/mpeg for
sendAudio
, etc.). *sendDocument
with URL will currently only work for GIF, PDF and ZIP files. * To usesendVoice
, the file must have the type audio/ogg and be no more than 1MB in size. 1-20MB voice notes will be sent as files.5 MB max size for photos and 20 MB max for other types of content.
function fromURLStream
fromURLStream: (url: string | URL, filename?: string) => InputFile;
Contents of the URL will be streamed to Telegram.
10 MB max size for photos, 50 MB for other files.
namespace Markup
module 'typings/markup.d.ts' {}
function forceReply
forceReply: () => Markup<ForceReply>;
function inlineKeyboard
inlineKeyboard: { (buttons: HideableIKBtn[][]): Markup<InlineKeyboardMarkup>; ( buttons: any[], options?: Partial<KeyboardBuildingOptions<any>> ): Markup<InlineKeyboardMarkup>;};
function keyboard
keyboard: { (buttons: HideableKBtn[][]): Markup<ReplyKeyboardMarkup>; ( buttons: any[], options?: Partial<KeyboardBuildingOptions<any>> ): Markup<ReplyKeyboardMarkup>;};
function removeKeyboard
removeKeyboard: () => Markup<ReplyKeyboardRemove>;
class Markup
class Markup< T extends | InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply> {}
constructor
constructor(reply_markup: {});
property reply_markup
readonly reply_markup: {};
method oneTime
oneTime: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method persistent
persistent: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method placeholder
placeholder: <T extends unknown>( this: Markup<T>, placeholder: string) => Markup<T>;
method resize
resize: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method selective
selective: <T extends unknown>(this: Markup<T>, value?: boolean) => Markup<T>;
namespace button
module 'typings/button.d.ts' {}
Must fit in a signed 32 bit int
function botRequest
botRequest: ( text: string, request_id: number, extra?: Omit<KeyboardButtonRequestUsers, 'request_id' | 'user_is_bot' | 'text'>, hide?: boolean) => Hideable<KeyboardButton.RequestUsersButton>;
function callback
callback: ( text: string, data: string, hide?: boolean) => Hideable<InlineKeyboardButton.CallbackButton>;
function channelRequest
channelRequest: ( text: string, request_id: number, extra?: KeyboardButtonRequestChannel, hide?: boolean) => Hideable<KeyboardButton.RequestChatButton>;
function contactRequest
contactRequest: ( text: string, hide?: boolean) => Hideable<KeyboardButton.RequestContactButton>;
function game
game: ( text: string, hide?: boolean) => Hideable<InlineKeyboardButton.GameButton>;
function groupRequest
groupRequest: ( text: string, request_id: number, extra?: KeyboardButtonRequestGroup, hide?: boolean) => Hideable<KeyboardButton.RequestChatButton>;
function locationRequest
locationRequest: ( text: string, hide?: boolean) => Hideable<KeyboardButton.RequestLocationButton>;
function login
login: ( text: string, url: string, opts?: { forward_text?: string; bot_username?: string; request_write_access?: boolean; }, hide?: boolean) => Hideable<InlineKeyboardButton.LoginButton>;
function pay
pay: (text: string, hide?: boolean) => Hideable<InlineKeyboardButton.PayButton>;
function pollRequest
pollRequest: ( text: string, type?: 'quiz' | 'regular', hide?: boolean) => Hideable<KeyboardButton.RequestPollButton>;
function switchToChat
switchToChat: ( text: string, value: string, hide?: boolean) => Hideable<InlineKeyboardButton.SwitchInlineButton>;
function switchToCurrentChat
switchToCurrentChat: ( text: string, value: string, hide?: boolean) => Hideable<InlineKeyboardButton.SwitchInlineCurrentChatButton>;
function text
text: (text: string, hide?: boolean) => Hideable<KeyboardButton.CommonButton>;
function url
url: ( text: string, url: string, hide?: boolean) => Hideable<InlineKeyboardButton.UrlButton>;
function userRequest
userRequest: ( text: string, request_id: number, extra?: Omit<KeyboardButtonRequestUsers, 'request_id' | 'text'>, hide?: boolean) => Hideable<KeyboardButton.RequestUsersButton>;
function webApp
webApp: ( text: string, url: string, hide?: boolean) => Hideable<InlineKeyboardButton.WebAppButton>;
namespace Scenes
module 'typings/scenes.d.ts' {}
class BaseScene
class BaseScene<C extends Context = Context> extends Composer<C> {}
constructor
constructor(id: string, options?: SceneOptions<C>);
property enterHandler
enterHandler: MiddlewareFn<C, Update>;
property id
id: string;
property leaveHandler
leaveHandler: MiddlewareFn<C, Update>;
property ttl
ttl?: number;
method enter
enter: (...fns: Array<Middleware<C>>) => this;
method enterMiddleware
enterMiddleware: () => MiddlewareFn<C>;
method leave
leave: (...fns: Array<Middleware<C>>) => this;
method leaveMiddleware
leaveMiddleware: () => MiddlewareFn<C>;
class SceneContextScene
class SceneContextScene< C extends SessionContext<SceneSession<D>>, D extends SceneSessionData = SceneSessionData> {}
constructor
constructor( ctx: SessionContext<SceneSession<D>>, scenes: Map<string, BaseScene<C>>, options: Partial<SceneContextSceneOptions<D>>);
property current
readonly current: BaseScene<C>;
property session
readonly session: SceneSessionData;
property state
state: {};
method enter
enter: ( sceneId: string, initialState?: object, silent?: boolean) => Promise<unknown>;
method leave
leave: () => Promise<void>;
method reenter
reenter: () => Promise<unknown> | undefined;
method reset
reset: () => void;
class Stage
class Stage< C extends SessionContext<SceneSession<D>> & { scene: SceneContextScene<C, D>; }, D extends SceneSessionData = SceneSessionData> extends Composer<C> {}
constructor
constructor( scenes?: readonly BaseScene<C>[], options?: Partial<SceneContextSceneOptions<D>>);
property options
options: Partial<SceneContextSceneOptions<D>>;
property scenes
scenes: Map<string, BaseScene<C>>;
method enter
static enter: <C extends Context<tg.Update> & { scene: SceneContextScene<C> }>( sceneId: string, initialState?: object, silent?: boolean) => (ctx: C) => Promise<unknown>;
method leave
static leave: < C extends Context<tg.Update> & { scene: SceneContextScene<C> }>() => (ctx: C) => Promise<void>;
method middleware
middleware: () => import('..').MiddlewareFn<C>;
method reenter
static reenter: < C extends Context<tg.Update> & { scene: SceneContextScene<C> }>() => (ctx: C) => Promise<unknown> | undefined;
method register
register: (...scenes: ReadonlyArray<BaseScene<C>>) => this;
class WizardContextWizard
class WizardContextWizard< C extends SessionContext<WizardSession> & { scene: SceneContextScene<C, WizardSessionData>; }> {}
constructor
constructor( ctx: SessionContext<WizardSession<WizardSessionData>> & { scene: SceneContextScene<C, WizardSessionData>; }, steps: readonly Middleware<C, Update>[]);
property cursor
cursor: number;
property state
readonly state: {};
property step
readonly step: Middleware<C, Update>;
method back
back: () => this;
method next
next: () => this;
method selectStep
selectStep: (index: number) => this;
class WizardScene
class WizardScene< C extends Context & { scene: SceneContextScene<C, WizardSessionData>; wizard: WizardContextWizard<C>; } > extends BaseScene<C> implements MiddlewareObj<C> {}
constructor
constructor(id: string, ...steps: Middleware<C, Update>[]);
constructor
constructor( id: string, options: SceneOptions<C>, ...steps: Middleware<C, Update>[]);
property steps
steps: Middleware<C, Update>[];
method enterMiddleware
enterMiddleware: () => import('../../middleware').MiddlewareFn<C>;
method middleware
middleware: () => import('../../middleware').MiddlewareFn<C>;
interface SceneContext
interface SceneContext<D extends SceneSessionData = SceneSessionData> extends Context {}
interface SceneSession
interface SceneSession<S extends SceneSessionData = SceneSessionData> {}
interface SceneSessionData
interface SceneSessionData {}
interface WizardContext
interface WizardContext<D extends WizardSessionData = WizardSessionData> extends Context {}
interface WizardSession
interface WizardSession<S extends WizardSessionData = WizardSessionData> extends SceneSession<S> {}
interface WizardSessionData
interface WizardSessionData extends SceneSessionData {}
property cursor
cursor: number;
namespace Telegraf
namespace Telegraf {}
interface LaunchOptions
interface LaunchOptions {}
property allowedUpdates
allowedUpdates?: tt.UpdateType[];
List the types of updates you want your bot to receive
property dropPendingUpdates
dropPendingUpdates?: boolean;
property webhook
webhook?: { /** Public domain for webhook. */ domain: string; /** * Webhook url path; will be automatically generated if not specified * @deprecated Pass `path` instead * */ hookPath?: string; /** Webhook url path; will be automatically generated if not specified */ path?: string; host?: string; port?: number; /** The fixed IP address which will be used to send webhook requests instead of the IP address resolved through DNS */ ipAddress?: string; /** * Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. * Use lower values to limit the load on your bot's server, and higher values to increase your bot's throughput. */ maxConnections?: number; /** TLS server options. Omit to use http. */ tlsOptions?: TlsOptions; /** * A secret token to be sent in a header `“X-Telegram-Bot-Api-Secret-Token”` in every webhook request. * 1-256 characters. Only characters `A-Z`, `a-z`, `0-9`, `_` and `-` are allowed. * The header is useful to ensure that the request comes from a webhook set by you. */ secretToken?: string; /** * Upload your public key certificate so that the root certificate in use can be checked. * See [self-signed guide](https://core.telegram.org/bots/self-signed) for details. */ certificate?: tg.InputFile; cb?: http.RequestListener;};
Configuration options for when the bot is run via webhooks
interface Options
interface Options<TContext extends Context> {}
property contextType
contextType: new (...args: ConstructorParameters<typeof Context>) => TContext;
property handlerTimeout
handlerTimeout: number;
property telegram
telegram?: Partial<ApiClient.Options>;
namespace Types
module 'typings/telegram-types.d.ts' {}
class Markup
class Markup< T extends | InlineKeyboardMarkup | ReplyKeyboardMarkup | ReplyKeyboardRemove | ForceReply> {}
constructor
constructor(reply_markup: {});
property reply_markup
readonly reply_markup: {};
method oneTime
oneTime: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method persistent
persistent: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method placeholder
placeholder: <T extends unknown>( this: Markup<T>, placeholder: string) => Markup<T>;
method resize
resize: ( this: Markup<ReplyKeyboardMarkup>, value?: boolean) => Markup<ReplyKeyboardMarkup>;
method selective
selective: <T extends unknown>(this: Markup<T>, value?: boolean) => Markup<T>;
interface CommandContextExtn
interface CommandContextExtn {}
property args
args: string[];
Command args parsed into an array.
Examples:
/command token1 token2 -> [ "token1", "token2" ]/command "token1 token2" -> [ "token1 token2" ]/command token1 "token2 token3" -> [ "token1" "token2 token3" ]Parser implementation might vary until considered stable
property command
command: string;
Matched command. This will always be the actual command, excluding preceeding slash and
@botname
Examples:
/command abc -> command/command@xyzbot abc -> command
property match
match: RegExpExecArray;
property payload
payload: string;
The unparsed payload part of the command
Examples:
/command abc def -> "abc def"/command "token1 token2" -> "\"token1 token2\""
type ChatAction
type ChatAction = Opts<'sendChatAction'>['action'];
type ExtraAddStickerToSet
type ExtraAddStickerToSet = MakeExtra<'addStickerToSet', 'name' | 'user_id'>;
type ExtraAnimation
type ExtraAnimation = MakeExtra<'sendAnimation', 'animation'>;
type ExtraAnswerCbQuery
type ExtraAnswerCbQuery = MakeExtra< 'answerCallbackQuery', 'text' | 'callback_query_id'>;
type ExtraAnswerInlineQuery
type ExtraAnswerInlineQuery = MakeExtra< 'answerInlineQuery', 'inline_query_id' | 'results'>;
type ExtraAudio
type ExtraAudio = MakeExtra<'sendAudio', 'audio'>;
type ExtraBanChatMember
type ExtraBanChatMember = MakeExtra<'banChatMember', 'user_id' | 'until_date'>;
type ExtraBanChatSenderChat
type ExtraBanChatSenderChat = MakeExtra<'banChatSenderChat', 'sender_chat_id'>;
type ExtraContact
type ExtraContact = MakeExtra<'sendContact', 'phone_number' | 'first_name'>;
type ExtraCopyMessage
type ExtraCopyMessage = MakeExtra<'copyMessage', 'from_chat_id' | 'message_id'>;
type ExtraCopyMessages
type ExtraCopyMessages = MakeExtra<'copyMessages', 'from_chat_id' | 'message_ids'>;
type ExtraCreateChatInviteLink
type ExtraCreateChatInviteLink = MakeExtra<'createChatInviteLink'>;
type ExtraCreateForumTopic
type ExtraCreateForumTopic = MakeExtra<'createForumTopic', 'name'>;
type ExtraCreateNewStickerSet
type ExtraCreateNewStickerSet = MakeExtra< 'createNewStickerSet', 'name' | 'title' | 'user_id'>;
type ExtraDice
type ExtraDice = MakeExtra<'sendDice'>;
type ExtraDocument
type ExtraDocument = MakeExtra<'sendDocument', 'document'>;
type ExtraEditChatInviteLink
type ExtraEditChatInviteLink = MakeExtra<'editChatInviteLink', 'invite_link'>;
type ExtraEditForumTopic
type ExtraEditForumTopic = MakeExtra<'editForumTopic', 'message_thread_id'>;
type ExtraEditMessageCaption
type ExtraEditMessageCaption = MakeExtra< 'editMessageCaption', 'message_id' | 'inline_message_id' | 'caption'>;
type ExtraEditMessageLiveLocation
type ExtraEditMessageLiveLocation = MakeExtra< 'editMessageLiveLocation', 'message_id' | 'inline_message_id' | 'latitude' | 'longitude'>;
type ExtraEditMessageMedia
type ExtraEditMessageMedia = MakeExtra< 'editMessageMedia', 'message_id' | 'inline_message_id' | 'media'>;
type ExtraEditMessageText
type ExtraEditMessageText = MakeExtra< 'editMessageText', 'message_id' | 'inline_message_id' | 'text'>;
type ExtraForwardMessage
type ExtraForwardMessage = MakeExtra< 'forwardMessage', 'from_chat_id' | 'message_id'>;
type ExtraForwardMessages
type ExtraForwardMessages = MakeExtra< 'forwardMessages', 'from_chat_id' | 'message_ids'>;
type ExtraGame
type ExtraGame = MakeExtra<'sendGame', 'game_short_name'>;
type ExtraInvoice
type ExtraInvoice = MakeExtra<'sendInvoice', keyof NewInvoiceParameters>;
type ExtraKickChatMember
type ExtraKickChatMember = ExtraBanChatMember;
type ExtraLocation
type ExtraLocation = MakeExtra<'sendLocation', 'latitude' | 'longitude'>;
type ExtraMediaGroup
type ExtraMediaGroup = MakeExtra<'sendMediaGroup', 'media'>;
type ExtraPhoto
type ExtraPhoto = MakeExtra<'sendPhoto', 'photo'>;
type ExtraPoll
type ExtraPoll = MakeExtra<'sendPoll', 'question' | 'options' | 'type'>;
type ExtraPromoteChatMember
type ExtraPromoteChatMember = MakeExtra<'promoteChatMember', 'user_id'>;
type ExtraReplyMessage
type ExtraReplyMessage = MakeExtra<'sendMessage', 'text'>;
type ExtraRestrictChatMember
type ExtraRestrictChatMember = MakeExtra<'restrictChatMember', 'user_id'>;
type ExtraSendChatAction
type ExtraSendChatAction = MakeExtra<'sendChatAction', 'action'>;
type ExtraSetChatPermissions
type ExtraSetChatPermissions = MakeExtra<'setChatPermissions', 'permissions'>;
type ExtraSetMyCommands
type ExtraSetMyCommands = MakeExtra<'setMyCommands', 'commands'>;
type ExtraSetWebhook
type ExtraSetWebhook = MakeExtra<'setWebhook', 'url'>;
type ExtraSticker
type ExtraSticker = MakeExtra<'sendSticker', 'sticker'>;
type ExtraStopPoll
type ExtraStopPoll = MakeExtra<'stopPoll', 'message_id'>;
type ExtraVenue
type ExtraVenue = MakeExtra< 'sendVenue', 'latitude' | 'longitude' | 'title' | 'address'>;
type ExtraVideo
type ExtraVideo = MakeExtra<'sendVideo', 'video'>;
type ExtraVideoNote
type ExtraVideoNote = MakeExtra<'sendVideoNote', 'video_note'>;
type ExtraVoice
type ExtraVoice = MakeExtra<'sendVoice', 'voice'>;
type MediaGroup
type MediaGroup = | readonly (InputMediaPhoto | InputMediaVideo)[] | readonly InputMediaAudio[] | readonly InputMediaDocument[];
type MessageSubType
type MessageSubType = | 'forward_date' | Exclude< UnionKeys<Message>, keyof Message.CaptionableMessage | 'entities' | 'media_group_id' >;
Possible message subtypes. Same as the properties on a message object
type MountMap
type MountMap = { [T in UpdateType]: Extract<Update, Record<T, object>>;} & { [T in MessageSubType]: { message: ExtractPartial<Update.MessageUpdate['message'], Record<T, unknown>>; update_id: number; };};
Maps [[
Composer.on
]]'supdateType
ormessageSubType
to att.Update
subtype.Deprecated
type NewInvoiceLinkParameters
type NewInvoiceLinkParameters = MakeExtra<'createInvoiceLink'>;
type NewInvoiceParameters
type NewInvoiceParameters = MakeExtra< 'sendInvoice', | 'disable_notification' | 'reply_parameters' | 'reply_markup' | 'message_thread_id'>;
type UpdateType
type UpdateType = Exclude<UnionKeys<Update>, keyof Update>;
Possible update types
type WrapCaption
type WrapCaption<T> = T extends { caption?: string;} ? Expand< Omit<T, 'caption'> & { caption?: string | FmtString; } > : T;
Package Files (22)
- typings/button.d.ts
- typings/composer.d.ts
- typings/context.d.ts
- typings/core/helpers/deunionize.d.ts
- typings/core/helpers/formatting.d.ts
- typings/core/network/error.d.ts
- typings/format.d.ts
- typings/index.d.ts
- typings/input.d.ts
- typings/markup.d.ts
- typings/middleware.d.ts
- typings/router.d.ts
- typings/scenes.d.ts
- typings/scenes/base.d.ts
- typings/scenes/context.d.ts
- typings/scenes/stage.d.ts
- typings/scenes/wizard/context.d.ts
- typings/scenes/wizard/index.d.ts
- typings/session.d.ts
- typings/telegraf.d.ts
- typings/telegram-types.d.ts
- typings/telegram.d.ts
Dependencies (8)
Dev Dependencies (19)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/telegraf
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/telegraf)
- HTML<a href="https://www.jsdocs.io/package/telegraf"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 13251 ms. - Missing or incorrect documentation? Open an issue for this package.