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

telegraf

Package Overview
Dependencies
Maintainers
3
Versions
241
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telegraf - npm Package Compare versions

Comparing version 3.39.0 to 3.40.0

108

context.js

@@ -12,3 +12,5 @@ const UpdateTypes = [

'poll',
'poll_answer'
'poll_answer',
'my_chat_member',
'chat_member'
]

@@ -47,3 +49,9 @@

'poll',
'forward_date'
'forward_date',
'message_auto_delete_timer_changed',
'video_chat_started',
'video_chat_ended',
'video_chat_participants_invited',
'video_chat_scheduled',
'web_app_data'
]

@@ -125,2 +133,10 @@

get myChatMember () {
return this.update.my_chat_member
}
get chatMember () {
return this.update.chat_member
}
get chat () {

@@ -131,3 +147,5 @@ return (this.message && this.message.chat) ||

(this.channelPost && this.channelPost.chat) ||
(this.editedChannelPost && this.editedChannelPost.chat)
(this.editedChannelPost && this.editedChannelPost.chat) ||
(this.myChatMember && this.myChatMember.chat) ||
(this.chatMember && this.chatMember.chat)
}

@@ -144,3 +162,5 @@

(this.preCheckoutQuery && this.preCheckoutQuery.from) ||
(this.chosenInlineResult && this.chosenInlineResult.from)
(this.chosenInlineResult && this.chosenInlineResult.from) ||
(this.myChatMember && this.myChatMember.from) ||
(this.chatMember && this.chatMember.from)
}

@@ -318,5 +338,8 @@

reply (...args) {
reply (text, args) {
this.assert(this.chat, 'reply')
return this.telegram.sendMessage(this.chat.id, ...args)
const extra = this.options.parseMode
? { parse_mode: this.options.parseMode }
: { ...args }
return this.telegram.sendMessage(this.chat.id, text, extra)
}

@@ -334,2 +357,7 @@

banChatMember (...args) {
this.assert(this.chat, 'banChatMember')
return this.telegram.banChatMember(this.chat.id, ...args)
}
kickChatMember (...args) {

@@ -360,2 +388,12 @@ this.assert(this.chat, 'kickChatMember')

banChatSenderChat (...args) {
this.assert(this.chat, 'banChatSenderChat')
return this.telegram.banChatSenderChat(this.chat.id, ...args)
}
unbanChatSenderChat (...args) {
this.assert(this.chat, 'unbanChatSenderChat')
return this.telegram.unbanChatSenderChat(this.chat.id, ...args)
}
setChatPhoto (...args) {

@@ -418,5 +456,10 @@ this.assert(this.chat, 'setChatPhoto')

this.assert(this.chat, 'getChatMembersCount')
return this.telegram.getChatMembersCount(this.chat.id, ...args)
return this.telegram.getChatMemberCount(this.chat.id, ...args)
}
getChatMemberCount (...args) {
this.assert(this.chat, 'getChatMemberCount')
return this.telegram.getChatMemberCount(this.chat.id, ...args)
}
setPassportDataErrors (errors) {

@@ -563,4 +606,4 @@ this.assert(this.chat, 'setPassportDataErrors')

getMyCommands () {
return this.telegram.getMyCommands()
getMyCommands (...args) {
return this.telegram.getMyCommands(...args)
}

@@ -572,2 +615,6 @@

deleteMyCommands (...args) {
return this.telegram.deleteMyCommands(...args)
}
replyWithMarkdown (markdown, extra) {

@@ -619,4 +666,47 @@ return this.reply(markdown, { parse_mode: 'Markdown', ...extra })

}
createChatInviteLink (...args) {
this.assert(this.chat, 'createChatInviteLink')
return this.telegram.createChatInviteLink(this.chat.id, ...args)
}
editChatInviteLink (...args) {
this.assert(this.chat, 'editChatInviteLink')
return this.telegram.editChatInviteLink(this.chat.id, ...args)
}
revokeChatInviteLink (...args) {
this.assert(this.chat, 'revokeChatInviteLink')
return this.telegram.revokeChatInviteLink(this.chat.id, ...args)
}
approveChatJoinRequest (...args) {
this.assert(this.chat, 'approveChatJoinRequest')
return this.telegram.approveChatJoinRequest(this.chat.id, ...args)
}
declineChatJoinRequest (...args) {
this.assert(this.chat, 'declineChatJoinRequest')
return this.telegram.declineChatJoinRequest(this.chat.id, ...args)
}
setChatMenuButton (...args) {
this.assert(this.chat, 'setChatMenuButton')
return this.telegram.setChatMenuButton(this.chat.id, ...args)
}
getChatMenuButton () {
this.assert(this.chat, 'getChatMenuButton')
return this.telegram.getChatMenuButton(this.chat.id)
}
setMyDefaultAdministratorRights (rights, forChannels) {
return this.telegram.setMyDefaultAdministratorRights(rights, forChannels)
}
getMyDefaultAdministratorRights (forChannels) {
return this.telegram.getMyDefaultAdministratorRights(forChannels)
}
}
module.exports = TelegrafContext

20

core/network/client.js

@@ -11,14 +11,8 @@ const debug = require('debug')('telegraf:client')

const WEBHOOK_BLACKLIST = [
'getChat',
'getChatAdministrators',
'getChatMember',
'getChatMembersCount',
'getFile',
'getFileLink',
'getGameHighScores',
'getMe',
'getUserProfilePhotos',
'getWebhookInfo',
'exportChatInviteLink'
const WEBHOOK_ALLOWLIST = [
'answerCallbackQuery',
'answerInlineQuery',
'deleteMessage',
'leaveChat',
'sendChatAction'
]

@@ -251,3 +245,3 @@

if (options.webhookReply && response && !responseEnd && !WEBHOOK_BLACKLIST.includes(method)) {
if (options.webhookReply && response && !responseEnd && WEBHOOK_ALLOWLIST.includes(method)) {
debug('Call via webhook', method, payload)

@@ -254,0 +248,0 @@ this.responseEnd = true

@@ -12,2 +12,7 @@ class Markup {

inputFieldPlaceholder (placeholder) {
this.input_field_placeholder = placeholder
return this
}
selective (value = true) {

@@ -115,2 +120,6 @@ this.selective = value

static inputFieldPlaceholder (placeholder) {
return new Markup().inputFieldPlaceholder(placeholder)
}
static selective (value = true) {

@@ -173,7 +182,6 @@ return new Markup().selective(value)

static formatHTML (text = '', entities = []) {
const chars = [...text]
const available = [...entities]
const opened = []
const result = []
for (let offset = 0; offset < chars.length; offset++) {
for (let offset = 0; offset < text.length; offset++) {
while (true) {

@@ -219,3 +227,3 @@ const index = available.findIndex((entity) => entity.offset === offset)

result.push(chars[offset])
result.push(escapeHTML(text[offset]))

@@ -263,2 +271,14 @@ while (true) {

const escapedChars = {
'"': '&quot;',
'&': '&amp;',
'<': '&lt;',
'>': '&gt;'
}
function escapeHTML (string) {
const chars = [...string]
return chars.map(char => escapedChars[char] || char).join('')
}
function buildKeyboard (buttons, options) {

@@ -265,0 +285,0 @@ const result = []

{
"name": "telegraf",
"version": "3.39.0",
"version": "3.40.0",
"description": "Modern Telegram Bot Framework",

@@ -34,3 +34,3 @@ "license": "MIT",

"engines": {
"node": ">=8"
"node": ">=10"
},

@@ -44,3 +44,3 @@ "types": "./typings/index.d.ts",

"sandwich-stream": "^2.0.1",
"typegram": "^3.1.5"
"typegram": "^3.10.0"
},

@@ -47,0 +47,0 @@ "devDependencies": {

![Telegraf](docs/media/header.png)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v5.0-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![Bot API Version](https://img.shields.io/badge/Bot%20API-v6.0-f36caf.svg?style=flat-square)](https://core.telegram.org/bots/api)
[![NPM Version](https://img.shields.io/npm/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)

@@ -15,3 +15,3 @@ [![node](https://img.shields.io/node/v/telegraf.svg?style=flat-square)](https://www.npmjs.com/package/telegraf)

- Full [Telegram Bot API 4.8](https://core.telegram.org/bots/api) support
- Full [Telegram Bot API 6.0](https://core.telegram.org/bots/api) support
- [Telegram Payment Platform](https://telegram.org/blog/payments)

@@ -21,3 +21,3 @@ - [HTML5 Games](https://core.telegram.org/bots/api#games)

- Incredibly fast
- [now](https://now.sh)/[Firebase](https://firebase.google.com/products/functions/)/[Glitch](https://dashing-light.glitch.me)/[Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction)/[AWS **Ī»**](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html)/Whatever ready
- [Vercel](https://vercel.com)/[Firebase](https://firebase.google.com/products/functions/)/[Glitch](https://dashing-light.glitch.me)/[Heroku](https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction)/[AWS **Ī»**](https://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html)/Whatever ready
- `http/https/fastify/Connect.js/express.js` compatible webhooks

@@ -24,0 +24,0 @@ - Easy to extend

@@ -178,5 +178,9 @@ const replicators = require('./core/replicators')

getChatMembersCount (chatId) {
return this.callApi('getChatMembersCount', { chat_id: chatId })
return this.callApi('getChatMemberCount', { chat_id: chatId })
}
getChatMemberCount (chatId) {
return this.callApi('getChatMemberCount', { chat_id: chatId })
}
answerInlineQuery (inlineQueryId, results, extra) {

@@ -190,4 +194,8 @@ return this.callApi('answerInlineQuery', { inline_query_id: inlineQueryId, results, ...extra })

banChatMember (chatId, userId, extra) {
return this.callApi('banChatMember', { chat_id: chatId, user_id: userId, ...extra })
}
kickChatMember (chatId, userId, untilDate) {
return this.callApi('kickChatMember', { chat_id: chatId, user_id: userId, until_date: untilDate })
return this.callApi('banChatMember', { chat_id: chatId, user_id: userId, until_date: untilDate })
}

@@ -207,2 +215,10 @@

banChatSenderChat (chatId, senderChatId) {
return this.callApi('banChatSenderChat', { chat_id: chatId, sender_chat_id: senderChatId })
}
unbanChatSenderChat (chatId, senderChatId) {
return this.callApi('unbanChatSenderChat', { chat_id: chatId, sender_chat_id: senderChatId })
}
exportChatInviteLink (chatId) {

@@ -409,10 +425,14 @@ return this.callApi('exportChatInviteLink', { chat_id: chatId })

getMyCommands () {
return this.callApi('getMyCommands')
getMyCommands (extra) {
return this.callApi('getMyCommands', extra)
}
setMyCommands (commands) {
return this.callApi('setMyCommands', { commands })
setMyCommands (commands, extra) {
return this.callApi('setMyCommands', { commands, ...extra })
}
deleteMyCommands (extra) {
return this.callApi('deleteMyCommands', extra)
}
setPassportDataErrors (userId, errors) {

@@ -452,4 +472,67 @@ return this.callApi('setPassportDataErrors', {

}
createChatInviteLink (chatId, name, extra) {
return this.callApi('createChatInviteLink', {
chat_id: chatId,
name: name,
...extra
})
}
editChatInviteLink (chatId, inviteLink, extra) {
return this.callApi('editChatInviteLink', {
chat_id: chatId,
invite_link: inviteLink,
...extra
})
}
revokeChatInviteLink (chatId, inviteLink) {
return this.callApi('revokeChatInviteLink', {
chat_id: chatId,
invite_link: inviteLink
})
}
approveChatJoinRequest (chatId, userId) {
return this.callApi('approveChatJoinRequest', {
chat_id: chatId,
user_id: userId
})
}
declineChatJoinRequest (chatId, userId) {
return this.callApi('declineChatJoinRequest', {
chat_id: chatId,
user_id: userId
})
}
setChatMenuButton (chatId, menuButton) {
return this.callApi('setChatMenuButton', {
chat_id: chatId,
menu_button: menuButton
})
}
getChatMenuButton (chatId) {
return this.callApi('getChatMenuButton', {
chat_id: chatId
})
}
setMyDefaultAdministratorRights (rights, forChannels) {
return this.callApi('setMyDefaultAdministratorRights', {
rights: rights,
for_channels: forChannels
})
}
getMyDefaultAdministratorRights (forChannels) {
return this.callApi('getMyDefaultAdministratorRights', {
for_channels: forChannels
})
}
}
module.exports = Telegram

@@ -106,3 +106,3 @@ /** @format */

/**
* Use this method to get the number of members in a chat
* @deprecated in favor of `getChatMemberCount`
* @returns Number on success

@@ -113,2 +113,8 @@ */

/**
* Use this method to get the number of members in a chat
* @returns Number on success
*/
getChatMemberCount(): Promise<number>
/**
* Use this method to restrict a user in a supergroup. The bot must be an administrator in the supergroup for this to work and must have the appropriate admin rights. Pass True for all boolean parameters to lift restrictions from a user. Returns True on success.

@@ -576,4 +582,15 @@ * @param userId Unique identifier of the target user

/**
* Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* Use this method to ban a user in a group, a supergroup or a channel.
* @param userId Unique identifier of the target user
* @param extra Extra params
* @returns True on success
*/
banChatMember(
userId: number,
extra?: tt.ExtraBan
): Promise<boolean>
/**
* @deprecated in favor of `banChatMember`
* @param userId Unique identifier of the target user
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever

@@ -615,2 +632,20 @@ * @returns True on success

/**
* Use this method to ban a channel chat in a supergroup or a channel
* @param senderChatId Unique identifier of the target sender chat
* @returns True on success
*/
banChatSenderChat(
senderChatId: number,
): Promise<boolean>
/**
* Use this method to unban a previously banned channel chat in a supergroup or channel
* @param senderChatId Unique identifier of the target sender chat
* @returns True on success
*/
unbanChatSenderChat(
senderChatId: number,
): Promise<boolean>
/**
* Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights

@@ -713,6 +748,9 @@ * @param photo New chat photo

/**
* Use this method to get the current list of the bot's commands. Requires no parameters.
* Use this method to get the current list of the bot's commands for the given scope and user language.
* @param extra Extra parameters for getMyCommands
* @returns Array of BotCommand on success.
*/
getMyCommands(): Promise<tt.BotCommand[]>
getMyCommands(
extra?: tt.ExtraGetMyCommands
): Promise<tt.BotCommand[]>

@@ -722,5 +760,102 @@ /**

* @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
* @param extra Extra parameters for setMyCommands
* @returns True on success
*/
setMyCommands(commands: tt.BotCommand[]): Promise<boolean>
setMyCommands(
commands: tt.BotCommand[],
extra?: tt.ExtraSetMyCommands
): Promise<boolean>
/**
* Use this method to delete the list of the bot's commands for the given scope and user language.
* After deletion, higher level commands will be shown to affected users.
* @param extra Extra parameters for deleteMyCommands
* @returns True on success
*/
deleteMyCommands(
extra?: tt.ExtraDeleteMyCommands
): Promise<boolean>
/**
* Use this method to create an additional invite link for a chat.
* @param extra Extra parameters for createChatInviteLink
* @returns the new invite link as ChatInviteLink object
*/
createChatInviteLink(
extra?: tt.ExtraCreateChatIviteLink
): Promise<tt.ChatInviteLink>
/**
* Use this method to edit a non-primary invite link created by the bot.
* @param inviteLink The invite link to edit
* @param extra Extra parameters for editChatInviteLink
* @returns the edited invite link as a ChatInviteLink object
*/
editChatInviteLink(
inviteLink: string,
extra?: tt.ExtraEditChatIviteLink
): Promise<tt.ChatInviteLink>
/**
* Use this method to revoke an invite link created by the bot.
* @param inviteLink The invite link to revoke
* @returns the revoked invite link as a ChatInviteLink object
*/
revokeChatInviteLink(
inviteLink: string
): Promise<tt.ChatInviteLink>
/**
* Use this method to 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. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*/
approveChatJoinRequest(
chatId: number | string,
userId: number,
): Promise<boolean>
/**
* Use this method to 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. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*/
declineChatJoinRequest(
chatId: number | string,
userId: number,
): Promise<boolean>
/**
* Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
* @param menuButton A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault
*/
setChatMenuButton(
menuButton?: tt.MenuButton
): Promise<boolean>
/**
* 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.
*/
getChatMenuButton(): Promise<tt.MenuButton>
/**
* 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. Returns True on success.
* @param rights A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
* @param forChannels Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
*/
setMyDefaultAdministratorRights(
rights?: tt.ChatAdministratorRights,
forChannels?: boolean
): Promise<boolean>
/**
* Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
* @param forChannels Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
*/
getMyDefaultAdministratorRights(
forChannels?: boolean
): Promise<tt.ChatAdministratorRights>
}

@@ -90,2 +90,4 @@ /** @format */

inputFieldPlaceholder<T extends tt.ReplyKeyboardMarkup | tt.ForceReply>(this: Markup<T> & T, placeholder: string): this
selective<T extends tt.ReplyMarkupBundle>(this: Markup<T> & T, value?: boolean): this

@@ -144,3 +146,3 @@

static forceReply(value?: string): Markup<tt.ForceReply> & tt.ForceReply
static forceReply(value?: boolean): Markup<tt.ForceReply> & tt.ForceReply

@@ -159,2 +161,4 @@ static keyboard(

static inputFieldPlaceholder(placeholder: string): Markup<tt.ReplyKeyboardMarkup | tt.ForceReply>
static selective(value?: boolean): Markup<tt.ReplyMarkupBundle>

@@ -161,0 +165,0 @@

@@ -6,4 +6,2 @@ /** @format */

import { IncomingMessage, ServerResponse } from 'http'
import * as https from 'https'
import * as http from 'http'
import { TlsOptions } from 'tls'

@@ -19,2 +17,7 @@

/**
* Parse mode
*/
parseMode?: tt.ParseMode
/**
* Telegram options

@@ -21,0 +24,0 @@ */

@@ -1,2 +0,1 @@

import { type } from 'os'
import * as TT from 'typegram'

@@ -10,7 +9,8 @@

'typing' |
'choose_sticker' |
'upload_photo' |
'record_video' |
'upload_video' |
'record_audio' |
'upload_audio' |
'record_voice' |
'upload_voice' |
'upload_document' |

@@ -38,3 +38,5 @@ 'find_location' |

'poll' |
'poll_answer'
'poll_answer' |
'my_chat_member' |
'chat_member'

@@ -72,3 +74,8 @@ export type MessageSubTypes =

'poll' |
'forward'
'forward' |
'message_auto_delete_timer_changed' |
'voice_chat_started' |
'voice_chat_ended' |
'voice_chat_participants_invited' |
'voice_chat_scheduled'

@@ -89,2 +96,3 @@ export type InputMediaTypes =

| 'kicked'
export type MessageEntityType =

@@ -106,2 +114,3 @@ 'mention'

| 'pre'
| 'spoiler'

@@ -182,2 +191,3 @@ export type InlineQueryResult =

mask_position: TT.MaskPosition
webm_sticker?: TT.InputFile
}

@@ -285,2 +295,5 @@

/** Pass True, if the administrator can manage voice chats */
can_manage_video_chats?: boolean,
/** Pass True, if the administrator can invite new users to the chat */

@@ -376,4 +389,11 @@ can_invite_users?: boolean

export interface ExtraSendMessage extends ExtraFormatting, ExtraDisableWebPagePreview, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {}
export interface ExtraProtectContent {
/**
* Protects the contents of the sent message from forwarding and saving
*/
protect_content?: boolean
}
export interface ExtraSendMessage extends ExtraFormatting, ExtraDisableWebPagePreview, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {}
export interface ExtraEditMessage extends ExtraFormatting, ExtraDisableWebPagePreview, ExtraReplyMarkupInlineKeyboard {}

@@ -390,3 +410,3 @@

export interface ExtraAudio extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraAudio extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {

@@ -417,3 +437,3 @@ /**

export interface ExtraDocument extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraDocument extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -433,7 +453,7 @@ * Thumbnail of the file sent; can be ignored if thumbnail generation for the file is supported server-side.

export interface ExtraGame extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkupInlineKeyboard {}
export interface ExtraGame extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkupInlineKeyboard, ExtraProtectContent {}
export interface ExtraInvoice extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkupInlineKeyboard {}
export interface ExtraInvoice extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkupInlineKeyboard, ExtraProtectContent {}
export interface ExtraLocation extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraLocation extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -484,3 +504,3 @@ * The radius of uncertainty for the location, measured in meters; 0-1500

export interface ExtraVenue extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraVenue extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -507,3 +527,3 @@ * Foursquare identifier of the venue

export interface ExtraContact extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraContact extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -520,11 +540,11 @@ * Contact's last name

export interface ExtraPhoto extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {}
export interface ExtraPhoto extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {}
export interface ExtraMediaGroup extends ExtraDisableNotifications, ExtraReplyMessage {}
export interface ExtraMediaGroup extends ExtraDisableNotifications, ExtraReplyMessage, ExtraProtectContent {}
export interface ExtraAnimation extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {}
export interface ExtraAnimation extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {}
export interface ExtraSticker extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {}
export interface ExtraSticker extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {}
export interface ExtraVideo extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraVideo extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -559,3 +579,3 @@ * Duration of sent video in seconds

export interface ExtraVideoNote extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraVideoNote extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -580,3 +600,3 @@ * Duration of sent video in seconds

export interface ExtraVoice extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraVoice extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -588,3 +608,3 @@ * Duration of the voice message in seconds

export interface ExtraDice extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraDice extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/**

@@ -599,3 +619,3 @@ * Emoji on which the dice throw animation is based.

export interface ExtraPoll extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {
export interface ExtraPoll extends ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {
/** True, if the poll needs to be anonymous, defaults to True */

@@ -651,3 +671,3 @@ is_anonymous?: boolean

export interface ExtraCopyMessage extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup {}
export interface ExtraCopyMessage extends ExtraCaption, ExtraDisableNotifications, ExtraReplyMessage, ExtraReplyMarkup, ExtraProtectContent {}

@@ -683,6 +703,51 @@ export type Extra = ExtraSendMessage

export interface ExtraUnban {
/** Do nothing if the user is not banned */
/**
* Do nothing if the user is not banned
*/
only_if_banned?: Boolean
}
export interface ExtraBan {
/**
* 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.
* Applied for supergroups and channels only.
*/
until_date?: number,
/**
* Pass True to delete all messages from the chat for the user that is being removed.
* If False, the user will be able to see messages in the group that were sent before the user was removed.
* Always True for supergroups and channels.
*/
revoke_messages: boolean
}
interface ExtraChatIviteLink {
/**
* Invite link name; 0-32 characters
*/
name?: string
/**
* Point in time (Unix timestamp) when the link will expire
*/
expire_date?: number,
/**
* Maximum number of users that can be members of the chat simultaneously after joining the chat via this invite link; 1-99999
*/
member_limit?: number
/**
* True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
*/
creates_join_request?: boolean
}
export interface ExtraCreateChatIviteLink extends ExtraChatIviteLink {}
export interface ExtraEditChatIviteLink extends ExtraChatIviteLink {}
export type MessageAudio = TT.Message.AudioMessage

@@ -720,2 +785,9 @@ export type MessageContact = TT.Message.ContactMessage

& TT.Message.SupergroupChatCreated
& TT.Message.MessageAutoDeleteTimerChangedMessage
& TT.Message.VideoChatStartedMessage
& TT.Message.VideoChatEndedMessage
& TT.Message.VideoChatEndedMessage
& TT.Message.VideoChatScheduledMessage
& TT.Message.VideoChatParticipantsInvitedMessage
& TT.Message.WebAppDataMessage

@@ -751,6 +823,6 @@ type CommonMessageBundle = TT.Message.AnimationMessage

& TT.Update.ShippingQueryUpdate
& TT.Update.MyChatMemberUpdate
& TT.Update.ChatMemberUpdate
export interface CallbackQuery extends TT.CallbackQuery.DataCallbackQuery, TT.CallbackQuery.GameShortGameCallbackQuery {
message: Message
}
export type CallbackQuery = TT.CallbackQuery

@@ -779,5 +851,7 @@ export interface NewInvoiceParameters {

/**
* Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
* Unique deep-linking parameter.
* If left empty, forwarded copies of the sent message will have a Pay button, allowing multiple users to pay directly from the forwarded message, using the same invoice.
* If non-empty, forwarded copies of the sent message will have a URL button with a deep link to the bot (instead of a Pay button), with the value used as the start parameter
*/
start_parameter: string
start_parameter?: string

@@ -795,2 +869,16 @@ /**

/**
* The maximum accepted amount for tips in the smallest units of the currency (integer, not float/double).
* For example, for a maximum tip of US$ 1.45 pass max_tip_amount = 145.
* Defaults to 0
*/
max_tip_amount: number
/**
* A JSON-serialized array of suggested amounts of tips in the smallest units of the currency (integer, not float/double).
* At most 4 suggested tip amounts can be specified.
* The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
*/
suggested_tip_amounts: number[]
/**
* URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.

@@ -869,2 +957,136 @@ */

/**
* Represents the default scope of bot commands.
* Default commands are used if no commands with a narrower scope are specified for the user.
*/
export interface BotCommandScopeDefault {
/**
* Scope type
*/
type: 'default'
}
/**
* Represents the scope of bot commands, covering all private chats.
*/
export interface BotCommandScopeAllPrivateChats {
/**
* Scope type
*/
type: 'all_private_chats'
}
/**
* Represents the scope of bot commands, covering all group and supergroup chats.
*/
export interface BotCommandScopeAllGroupChats {
/**
* Scope type
*/
type: 'all_groups_chats'
}
/**
* Represents the scope of bot commands, covering all group and supergroup chat administrators.
*/
export interface BotCommandScopeAllChatAdministrators {
/**
* Scope type
*/
type: 'all_chat_administrators'
}
/**
* Represents the scope of bot commands, covering a specific chat.
*/
export interface BotCommandScopeChat {
/**
* Scope type
*/
type: 'chat'
/**
* Unique identifier for the target chat or username of the target supergroup
*/
chat_id: number | string
}
/**
* Represents the scope of bot commands, covering all administrators of a specific group or supergroup chat.
*/
export interface BotCommandScopeChatAdministrators {
/**
* Scope type
*/
type: 'chat_administrators'
/**
* Unique identifier for the target chat or username of the target supergroup
*/
chat_id: number | string
}
/**
* Represents the scope of bot commands, covering a specific member of a group or supergroup chat.
*/
export interface BotCommandScopeChatMember {
/**
* Scope type
*/
type: 'chat_member'
/**
* Unique identifier for the target chat or username of the target supergroup
*/
chat_id: number | string
/**
* Unique identifier of the target user
*/
user_id: number
}
/**
* This object represents the scope to which bot commands are applied.
*/
export type BotCommandScope =
BotCommandScopeDefault
| BotCommandScopeAllPrivateChats
| BotCommandScopeAllGroupChats
| BotCommandScopeAllChatAdministrators
| BotCommandScopeChat
| BotCommandScopeChatAdministrators
| BotCommandScopeChatMember
export interface ExtraScope {
/**
* A JSON-serialized object, describing scope of users for which the commands are relevant.
* Defaults to BotCommandScopeDefault.
*/
scope?: BotCommandScope
}
export interface ExtraSetMyCommands extends ExtraScope {
/**
* A two-letter ISO 639-1 language code.
* If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
*/
language_code?: string
}
export interface ExtraDeleteMyCommands extends ExtraScope {
/**
* A two-letter ISO 639-1 language code.
* If empty, commands will be applied to all users from the given scope, for whose language there are no dedicated commands
*/
language_code?: string
}
export interface ExtraGetMyCommands extends ExtraScope {
/**
* A two-letter ISO 639-1 language code or an empty string
*/
language_code?: string
}
/**
* This object represents a bot command

@@ -883,1 +1105,9 @@ */

}
export type ChatInviteLink = TT.ChatInviteLink
export type MenuButton = TT.MenuButton
export type ChatAdministratorRights = TT.ChatAdministratorRights
export type SentWebAppMessage = TT.SentWebAppMessage

@@ -470,3 +470,3 @@ /** @format */

/**
* Use this method to get the number of members in a chat
* @deprecated in favor of `getChatMemberCount`
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)

@@ -478,2 +478,9 @@ * @returns Number on success

/**
* Use this method to get the number of members in a chat
* @param chatId Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
* @returns Number on success
*/
getChatMemberCount(chatId: string | number): Promise<number>
/**
* Use this method to send answers to an inline query. On success, True is returned.

@@ -504,5 +511,18 @@ * No more than 50 results per query are allowed.

/**
* Use this method to kick a user from a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the group on their own using invite links, etc., unless unbanned first. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights
* Use this method to ban a user in a group, a supergroup or a channel.
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @param extra Extra params
* @returns True on success
*/
banChatMember(
chatId: number | string,
userId: number,
extra?: tt.ExtraBan
): Promise<boolean>
/**
* @deprecated in favor of `banChatMember`
* @param chatId Unique identifier for the target group or username of the target supergroup or channel (in the format `@channelusername`)
* @param userId Unique identifier of the target user
* @param untilDate Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever

@@ -557,2 +577,24 @@ * @returns True on success

/**
* Use this method to ban a channel chat in a supergroup or a channel. Until the chat is unbanned (@function unbanChatSenderChat), the owner of the banned chat won't be able to send messages on behalf of any of their channels. The bot must be an administrator in the supergroup or channel for this to work and must have the appropriate administrator rights
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param senderChatId Unique identifier of the target sender chat
* @returns True on success
*/
banChatSenderChat(
chatId: string | number,
senderChatId: number,
): Promise<boolean>
/**
* Use this method to 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
* @param chatId Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
* @param senderChatId Unique identifier of the target sender chat
* @returns True on success
*/
unbanChatSenderChat(
chatId: string | number,
senderChatId: number,
): Promise<boolean>
/**
* Use this method to export an invite link to a supergroup or a channel. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.

@@ -914,6 +956,9 @@ * @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)

/**
* Use this method to get the current list of the bot's commands. Requires no parameters.
* Use this method to get the current list of the bot's commands for the given scope and user language.
* @param extra Extra parameters for getMyCommands
* @returns Array of BotCommand on success.
*/
getMyCommands(): Promise<tt.BotCommand[]>
getMyCommands(
extra?: tt.ExtraGetMyCommands
): Promise<tt.BotCommand[]>

@@ -923,7 +968,21 @@ /**

* @param commands A list of bot commands to be set as the list of the bot's commands. At most 100 commands can be specified.
* @param extra Extra parameters for setMyCommands
* @returns True on success
*/
setMyCommands(commands: tt.BotCommand[]): Promise<boolean>
setMyCommands(
commands: tt.BotCommand[],
extra?: tt.ExtraSetMyCommands
): Promise<boolean>
/**
* Use this method to delete the list of the bot's commands for the given scope and user language.
* After deletion, higher level commands will be shown to affected users.
* @param extra Extra parameters for deleteMyCommands
* @returns True on success
*/
deleteMyCommands(
extra?: tt.ExtraDeleteMyCommands
): Promise<boolean>
/**
* Informs a user that some of the Telegram Passport elements they provided contains errors.

@@ -971,2 +1030,97 @@ * The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change).

): Promise<tt.MessageId>
/**
* Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. The link can be revoked using the method revokeChatInviteLink. Returns the new invite link as ChatInviteLink object.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param name Invite link name; 0-32 characters
* @param extra Extra parameters for createChatInviteLink
* @returns the new invite link as ChatInviteLink object
*/
createChatInviteLink(
chatId: number | string,
name: string,
extra?: tt.ExtraCreateChatIviteLink
): Promise<tt.ChatInviteLink>
/**
* Use this method to edit a non-primary invite link created by the bot.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param inviteLink The invite link to edit
* @param extra Extra parameters for editChatInviteLink
* @returns the edited invite link as a ChatInviteLink object
*/
editChatInviteLink(
chatId: number | string,
inviteLink: string,
extra?: tt.ExtraEditChatIviteLink
): Promise<tt.ChatInviteLink>
/**
* Use this method to revoke an invite link created by the bot.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param inviteLink The invite link to revoke
* @returns the revoked invite link as a ChatInviteLink object
*/
revokeChatInviteLink(
chatId: number | string,
inviteLink: string
): Promise<tt.ChatInviteLink>
/**
* Use this method to 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. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*/
approveChatJoinRequest(
chatId: number | string,
userId: number
): Promise<boolean>
/**
* Use this method to 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. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param userId Unique identifier of the target user
*/
declineChatJoinRequest(
chatId: number | string,
userId: number
): Promise<boolean>
/**
* Use this method to change the bot's menu button in a private chat, or the default menu button. Returns True on success.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
* @param menuButton A JSON-serialized object for the bot's new menu button. Defaults to MenuButtonDefault
*/
setChatMenuButton(
chatId?: number | string,
menuButton?: tt.MenuButton
): Promise<boolean>
/**
* 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.
* @param chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername)
*/
getChatMenuButton(
chatId?: number | string,
): Promise<tt.MenuButton>
/**
* 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. Returns True on success.
* @param rights A JSON-serialized object describing new default administrator rights. If not specified, the default administrator rights will be cleared.
* @param forChannels Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
*/
setMyDefaultAdministratorRights(
rights?: tt.ChatAdministratorRights,
forChannels?: boolean
): Promise<boolean>
/**
* Use this method to get the current default administrator rights of the bot. Returns ChatAdministratorRights on success.
* @param forChannels Pass True to change the default administrator rights of the bot in channels. Otherwise, the default administrator rights of the bot for groups and supergroups will be changed.
*/
getMyDefaultAdministratorRights(
forChannels?: boolean
): Promise<tt.ChatAdministratorRights>
}
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with āš”ļø by Socket Inc