Comparing version 4.9.0-canary.1 to 4.9.0-canary.2
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.newReplies = void 0; | ||
exports.useNewReplies = void 0; | ||
const util_1 = require("./util"); | ||
function newReplies() { | ||
function makeReply(ctx, extra) { | ||
var _a; | ||
const ret = extra || {}; | ||
ret.reply_to_message_id = (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id; | ||
return ret; | ||
} | ||
const replyContext = { | ||
replyWithChatAction: function () { | ||
throw new TypeError('ctx.replyWithChatAction is removed, use respondWithChatAction instead'); | ||
}, | ||
reply(text, extra) { | ||
(0, util_1.assert)(this, 'chat', 'reply'); | ||
return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra)); | ||
}, | ||
replyWithAnimation(animation, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithAnimation'); | ||
return this.telegram.sendAnimation(this.chat.id, animation, makeReply(this, extra)); | ||
}, | ||
replyWithAudio(audio, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithAudio'); | ||
return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra)); | ||
}, | ||
replyWithContact(phoneNumber, firstName, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithContact'); | ||
return this.telegram.sendContact(this.chat.id, phoneNumber, firstName, makeReply(this, extra)); | ||
}, | ||
replyWithDice(extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithDice'); | ||
return this.telegram.sendDice(this.chat.id, makeReply(this, extra)); | ||
}, | ||
replyWithDocument(document, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithDocument'); | ||
return this.telegram.sendDocument(this.chat.id, document, makeReply(this, extra)); | ||
}, | ||
replyWithGame(gameName, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithGame'); | ||
return this.telegram.sendGame(this.chat.id, gameName, makeReply(this, extra)); | ||
}, | ||
replyWithHTML(html, extra) { | ||
var _a; | ||
(0, util_1.assert)(this, 'chat', 'replyWithHTML'); | ||
return this.telegram.sendMessage(this.chat.id, html, { | ||
parse_mode: 'HTML', | ||
reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}, | ||
replyWithInvoice(invoice, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithInvoice'); | ||
return this.telegram.sendInvoice(this.chat.id, invoice, makeReply(this, extra)); | ||
}, | ||
replyWithLocation(latitude, longitude, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithLocation'); | ||
return this.telegram.sendLocation(this.chat.id, latitude, longitude, makeReply(this, extra)); | ||
}, | ||
replyWithMarkdown(markdown, extra) { | ||
var _a; | ||
(0, util_1.assert)(this, 'chat', 'replyWithMarkdown'); | ||
return this.telegram.sendMessage(this.chat.id, markdown, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}, | ||
replyWithMarkdownV2(markdown, extra) { | ||
var _a; | ||
(0, util_1.assert)(this, 'chat', 'replyWithMarkdownV2'); | ||
return this.telegram.sendMessage(this.chat.id, markdown, { | ||
parse_mode: 'MarkdownV2', | ||
reply_to_message_id: (_a = this.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}, | ||
replyWithMediaGroup(media, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithMediaGroup'); | ||
return this.telegram.sendMediaGroup(this.chat.id, media, makeReply(this, extra)); | ||
}, | ||
replyWithPhoto(photo, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithPhoto'); | ||
return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra)); | ||
}, | ||
replyWithPoll(question, options, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithPoll'); | ||
return this.telegram.sendPoll(this.chat.id, question, options, makeReply(this, extra)); | ||
}, | ||
replyWithQuiz(question, options, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithQuiz'); | ||
return this.telegram.sendQuiz(this.chat.id, question, options, makeReply(this, extra)); | ||
}, | ||
replyWithSticker(sticker, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithSticker'); | ||
return this.telegram.sendSticker(this.chat.id, sticker, makeReply(this, extra)); | ||
}, | ||
replyWithVenue(latitude, longitude, title, address, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithVenue'); | ||
return this.telegram.sendVenue(this.chat.id, latitude, longitude, title, address, makeReply(this, extra)); | ||
}, | ||
replyWithVideo(video, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithVideo'); | ||
return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra)); | ||
}, | ||
replyWithVideoNote(videoNote, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithVideoNote'); | ||
return this.telegram.sendVideoNote(this.chat.id, videoNote, makeReply(this, extra)); | ||
}, | ||
replyWithVoice(voice, extra) { | ||
(0, util_1.assert)(this, 'chat', 'replyWithVoice'); | ||
return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra)); | ||
}, | ||
}; | ||
/** | ||
* Sets up Context to use the new reply methods. | ||
* ctx.reply() and ctx.replyWith*() methods will actually reply to the message they are replying to. | ||
* Use ctx.respond() to send a message in chat without replying to it. | ||
* | ||
* If the message to reply is deleted, reply() will send a normal message. | ||
* If the update is not a message and we are unable to reply, reply() will send a normal message. | ||
*/ | ||
function useNewReplies() { | ||
return (ctx, next) => { | ||
function makeReply(extra) { | ||
var _a; | ||
const ret = extra || {}; | ||
ret.reply_to_message_id = (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id; | ||
return ret; | ||
} | ||
// Disable replyWithChatAction in favour of respondWithChatAction | ||
ctx.replyWithChatAction = function () { | ||
throw new TypeError('ctx.replyWithChatAction is removed, use respondWithChatAction instead'); | ||
}; | ||
ctx.reply = function reply(text, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'reply'); | ||
return ctx.respond(text, makeReply(extra)); | ||
}; | ||
ctx.replyWithAnimation = function replyWithAnimation(animation, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithAnimation'); | ||
return ctx.telegram.sendAnimation(ctx.chat.id, animation, makeReply(extra)); | ||
}; | ||
ctx.replyWithAudio = function replyWithAudio(audio, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithAudio'); | ||
return ctx.telegram.sendAudio(ctx.chat.id, audio, makeReply(extra)); | ||
}; | ||
ctx.replyWithContact = function replyWithContact(phoneNumber, firstName, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithContact'); | ||
return ctx.telegram.sendContact(ctx.chat.id, phoneNumber, firstName, makeReply(extra)); | ||
}; | ||
ctx.replyWithDice = function replyWithDice(extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithDice'); | ||
return ctx.telegram.sendDice(ctx.chat.id, makeReply(extra)); | ||
}; | ||
ctx.replyWithDocument = function replyWithDocument(document, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithDocument'); | ||
return ctx.telegram.sendDocument(ctx.chat.id, document, makeReply(extra)); | ||
}; | ||
ctx.replyWithGame = function replyWithGame(gameName, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithGame'); | ||
return ctx.telegram.sendGame(ctx.chat.id, gameName, makeReply(extra)); | ||
}; | ||
ctx.replyWithHTML = function replyWithHTML(html, extra) { | ||
var _a; | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithHTML'); | ||
return ctx.telegram.sendMessage(ctx.chat.id, html, { | ||
parse_mode: 'HTML', | ||
reply_to_message_id: (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}; | ||
ctx.replyWithInvoice = function replyWithInvoice(invoice, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithInvoice'); | ||
return ctx.telegram.sendInvoice(ctx.chat.id, invoice, makeReply(extra)); | ||
}; | ||
ctx.replyWithLocation = function replyWithLocation(latitude, longitude, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithLocation'); | ||
return ctx.telegram.sendLocation(ctx.chat.id, latitude, longitude, makeReply(extra)); | ||
}; | ||
ctx.replyWithMarkdown = function replyWithMarkdown(markdown, extra) { | ||
var _a; | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithMarkdown'); | ||
return ctx.telegram.sendMessage(ctx.chat.id, markdown, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}; | ||
ctx.replyWithMarkdownV2 = function replyWithMarkdownV2(markdown, extra) { | ||
var _a; | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithMarkdownV2'); | ||
return ctx.telegram.sendMessage(ctx.chat.id, markdown, { | ||
parse_mode: 'MarkdownV2', | ||
reply_to_message_id: (_a = ctx.message) === null || _a === void 0 ? void 0 : _a.message_id, | ||
...extra, | ||
}); | ||
}; | ||
ctx.replyWithPhoto = function replyWithPhoto(photo, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithPhoto'); | ||
return ctx.telegram.sendPhoto(ctx.chat.id, photo, makeReply(extra)); | ||
}; | ||
ctx.replyWithPoll = function replyWithPoll(question, options, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithPoll'); | ||
return ctx.telegram.sendPoll(ctx.chat.id, question, options, makeReply(extra)); | ||
}; | ||
ctx.replyWithQuiz = function replyWithQuiz(question, options, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithQuiz'); | ||
return ctx.telegram.sendQuiz(ctx.chat.id, question, options, makeReply(extra)); | ||
}; | ||
ctx.replyWithSticker = function replyWithSticker(sticker, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithSticker'); | ||
return ctx.telegram.sendSticker(ctx.chat.id, sticker, makeReply(extra)); | ||
}; | ||
ctx.replyWithVenue = function replyWithVenue(latitude, longitude, title, address, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithVenue'); | ||
return ctx.telegram.sendVenue(ctx.chat.id, latitude, longitude, title, address, makeReply(extra)); | ||
}; | ||
ctx.replyWithVideo = function replyWithVideo(video, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithVideo'); | ||
return ctx.telegram.sendVideo(ctx.chat.id, video, makeReply(extra)); | ||
}; | ||
ctx.replyWithVideoNote = function replyWithVideoNote(videoNote, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithVideoNote'); | ||
return ctx.telegram.sendVideoNote(ctx.chat.id, videoNote, makeReply(extra)); | ||
}; | ||
ctx.replyWithVoice = function replyWithVoice(voice, extra) { | ||
(0, util_1.assert)(ctx, 'chat', 'replyWithVoice'); | ||
return ctx.telegram.sendVoice(ctx.chat.id, voice, makeReply(extra)); | ||
}; | ||
Object.assign(ctx, replyContext); | ||
return next(); | ||
}; | ||
} | ||
exports.newReplies = newReplies; | ||
exports.useNewReplies = useNewReplies; |
{ | ||
"name": "telegraf", | ||
"version": "4.9.0-canary.1", | ||
"version": "4.9.0-canary.2", | ||
"description": "Modern Telegram Bot Framework", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,142 +5,147 @@ import { assert } from './util' | ||
export function newReplies<C extends Context>(): Middleware<C> { | ||
return (ctx, next) => { | ||
function makeReply<E extends { reply_to_message_id?: number }>(extra?: E) { | ||
const ret = extra || ({} as E) | ||
ret.reply_to_message_id = ctx.message?.message_id | ||
return ret | ||
} | ||
type ReplyContext = { [key in keyof Context & `reply${string}`]: Context[key] } | ||
// Disable replyWithChatAction in favour of respondWithChatAction | ||
ctx.replyWithChatAction = function () { | ||
throw new TypeError( | ||
'ctx.replyWithChatAction is removed, use respondWithChatAction instead' | ||
) | ||
} | ||
function makeReply< | ||
C extends Context, | ||
E extends { reply_to_message_id?: number } | ||
>(ctx: C, extra?: E) { | ||
const ret = extra || ({} as E) | ||
ret.reply_to_message_id = ctx.message?.message_id | ||
return ret | ||
} | ||
ctx.reply = function reply(text, extra) { | ||
assert(ctx, 'chat', 'reply') | ||
return ctx.respond(text, makeReply(extra)) | ||
} | ||
ctx.replyWithAnimation = function replyWithAnimation(animation, extra) { | ||
assert(ctx, 'chat', 'replyWithAnimation') | ||
return ctx.telegram.sendAnimation( | ||
ctx.chat.id, | ||
animation, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithAudio = function replyWithAudio(audio, extra) { | ||
assert(ctx, 'chat', 'replyWithAudio') | ||
return ctx.telegram.sendAudio(ctx.chat.id, audio, makeReply(extra)) | ||
} | ||
ctx.replyWithContact = function replyWithContact( | ||
const replyContext: ReplyContext = { | ||
replyWithChatAction: function () { | ||
throw new TypeError( | ||
'ctx.replyWithChatAction is removed, use respondWithChatAction instead' | ||
) | ||
}, | ||
reply(text, extra) { | ||
assert(this, 'chat', 'reply') | ||
return this.telegram.sendMessage(this.chat.id, text, makeReply(this, extra)) | ||
}, | ||
replyWithAnimation(animation, extra) { | ||
assert(this, 'chat', 'replyWithAnimation') | ||
return this.telegram.sendAnimation( | ||
this.chat.id, | ||
animation, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithAudio(audio, extra) { | ||
assert(this, 'chat', 'replyWithAudio') | ||
return this.telegram.sendAudio(this.chat.id, audio, makeReply(this, extra)) | ||
}, | ||
replyWithContact(phoneNumber, firstName, extra) { | ||
assert(this, 'chat', 'replyWithContact') | ||
return this.telegram.sendContact( | ||
this.chat.id, | ||
phoneNumber, | ||
firstName, | ||
extra | ||
) { | ||
assert(ctx, 'chat', 'replyWithContact') | ||
return ctx.telegram.sendContact( | ||
ctx.chat.id, | ||
phoneNumber, | ||
firstName, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithDice = function replyWithDice(extra) { | ||
assert(ctx, 'chat', 'replyWithDice') | ||
return ctx.telegram.sendDice(ctx.chat.id, makeReply(extra)) | ||
} | ||
ctx.replyWithDocument = function replyWithDocument(document, extra) { | ||
assert(ctx, 'chat', 'replyWithDocument') | ||
return ctx.telegram.sendDocument(ctx.chat.id, document, makeReply(extra)) | ||
} | ||
ctx.replyWithGame = function replyWithGame(gameName, extra) { | ||
assert(ctx, 'chat', 'replyWithGame') | ||
return ctx.telegram.sendGame(ctx.chat.id, gameName, makeReply(extra)) | ||
} | ||
ctx.replyWithHTML = function replyWithHTML(html, extra) { | ||
assert(ctx, 'chat', 'replyWithHTML') | ||
return ctx.telegram.sendMessage(ctx.chat.id, html, { | ||
parse_mode: 'HTML', | ||
reply_to_message_id: ctx.message?.message_id, | ||
...extra, | ||
}) | ||
} | ||
ctx.replyWithInvoice = function replyWithInvoice(invoice, extra) { | ||
assert(ctx, 'chat', 'replyWithInvoice') | ||
return ctx.telegram.sendInvoice(ctx.chat.id, invoice, makeReply(extra)) | ||
} | ||
ctx.replyWithLocation = function replyWithLocation( | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithDice(extra) { | ||
assert(this, 'chat', 'replyWithDice') | ||
return this.telegram.sendDice(this.chat.id, makeReply(this, extra)) | ||
}, | ||
replyWithDocument(document, extra) { | ||
assert(this, 'chat', 'replyWithDocument') | ||
return this.telegram.sendDocument( | ||
this.chat.id, | ||
document, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithGame(gameName, extra) { | ||
assert(this, 'chat', 'replyWithGame') | ||
return this.telegram.sendGame( | ||
this.chat.id, | ||
gameName, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithHTML(html, extra) { | ||
assert(this, 'chat', 'replyWithHTML') | ||
return this.telegram.sendMessage(this.chat.id, html, { | ||
parse_mode: 'HTML', | ||
reply_to_message_id: this.message?.message_id, | ||
...extra, | ||
}) | ||
}, | ||
replyWithInvoice(invoice, extra) { | ||
assert(this, 'chat', 'replyWithInvoice') | ||
return this.telegram.sendInvoice( | ||
this.chat.id, | ||
invoice, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithLocation(latitude, longitude, extra) { | ||
assert(this, 'chat', 'replyWithLocation') | ||
return this.telegram.sendLocation( | ||
this.chat.id, | ||
latitude, | ||
longitude, | ||
extra | ||
) { | ||
assert(ctx, 'chat', 'replyWithLocation') | ||
return ctx.telegram.sendLocation( | ||
ctx.chat.id, | ||
latitude, | ||
longitude, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithMarkdown = function replyWithMarkdown(markdown, extra) { | ||
assert(ctx, 'chat', 'replyWithMarkdown') | ||
return ctx.telegram.sendMessage(ctx.chat.id, markdown, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message?.message_id, | ||
...extra, | ||
}) | ||
} | ||
ctx.replyWithMarkdownV2 = function replyWithMarkdownV2(markdown, extra) { | ||
assert(ctx, 'chat', 'replyWithMarkdownV2') | ||
return ctx.telegram.sendMessage(ctx.chat.id, markdown, { | ||
parse_mode: 'MarkdownV2', | ||
reply_to_message_id: ctx.message?.message_id, | ||
...extra, | ||
}) | ||
} | ||
ctx.replyWithPhoto = function replyWithPhoto(photo, extra) { | ||
assert(ctx, 'chat', 'replyWithPhoto') | ||
return ctx.telegram.sendPhoto(ctx.chat.id, photo, makeReply(extra)) | ||
} | ||
ctx.replyWithPoll = function replyWithPoll(question, options, extra) { | ||
assert(ctx, 'chat', 'replyWithPoll') | ||
return ctx.telegram.sendPoll( | ||
ctx.chat.id, | ||
question, | ||
options, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithQuiz = function replyWithQuiz(question, options, extra) { | ||
assert(ctx, 'chat', 'replyWithQuiz') | ||
return ctx.telegram.sendQuiz( | ||
ctx.chat.id, | ||
question, | ||
options, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithSticker = function replyWithSticker(sticker, extra) { | ||
assert(ctx, 'chat', 'replyWithSticker') | ||
return ctx.telegram.sendSticker(ctx.chat.id, sticker, makeReply(extra)) | ||
} | ||
ctx.replyWithVenue = function replyWithVenue( | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithMarkdown(markdown, extra) { | ||
assert(this, 'chat', 'replyWithMarkdown') | ||
return this.telegram.sendMessage(this.chat.id, markdown, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: this.message?.message_id, | ||
...extra, | ||
}) | ||
}, | ||
replyWithMarkdownV2(markdown, extra) { | ||
assert(this, 'chat', 'replyWithMarkdownV2') | ||
return this.telegram.sendMessage(this.chat.id, markdown, { | ||
parse_mode: 'MarkdownV2', | ||
reply_to_message_id: this.message?.message_id, | ||
...extra, | ||
}) | ||
}, | ||
replyWithMediaGroup(media, extra) { | ||
assert(this, 'chat', 'replyWithMediaGroup') | ||
return this.telegram.sendMediaGroup( | ||
this.chat.id, | ||
media, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithPhoto(photo, extra) { | ||
assert(this, 'chat', 'replyWithPhoto') | ||
return this.telegram.sendPhoto(this.chat.id, photo, makeReply(this, extra)) | ||
}, | ||
replyWithPoll(question, options, extra) { | ||
assert(this, 'chat', 'replyWithPoll') | ||
return this.telegram.sendPoll( | ||
this.chat.id, | ||
question, | ||
options, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithQuiz(question, options, extra) { | ||
assert(this, 'chat', 'replyWithQuiz') | ||
return this.telegram.sendQuiz( | ||
this.chat.id, | ||
question, | ||
options, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithSticker(sticker, extra) { | ||
assert(this, 'chat', 'replyWithSticker') | ||
return this.telegram.sendSticker( | ||
this.chat.id, | ||
sticker, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithVenue(latitude, longitude, title, address, extra) { | ||
assert(this, 'chat', 'replyWithVenue') | ||
return this.telegram.sendVenue( | ||
this.chat.id, | ||
latitude, | ||
@@ -150,36 +155,36 @@ longitude, | ||
address, | ||
extra | ||
) { | ||
assert(ctx, 'chat', 'replyWithVenue') | ||
return ctx.telegram.sendVenue( | ||
ctx.chat.id, | ||
latitude, | ||
longitude, | ||
title, | ||
address, | ||
makeReply(extra) | ||
) | ||
} | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithVideo(video, extra) { | ||
assert(this, 'chat', 'replyWithVideo') | ||
return this.telegram.sendVideo(this.chat.id, video, makeReply(this, extra)) | ||
}, | ||
replyWithVideoNote(videoNote, extra) { | ||
assert(this, 'chat', 'replyWithVideoNote') | ||
return this.telegram.sendVideoNote( | ||
this.chat.id, | ||
videoNote, | ||
makeReply(this, extra) | ||
) | ||
}, | ||
replyWithVoice(voice, extra) { | ||
assert(this, 'chat', 'replyWithVoice') | ||
return this.telegram.sendVoice(this.chat.id, voice, makeReply(this, extra)) | ||
}, | ||
} | ||
ctx.replyWithVideo = function replyWithVideo(video, extra) { | ||
assert(ctx, 'chat', 'replyWithVideo') | ||
return ctx.telegram.sendVideo(ctx.chat.id, video, makeReply(extra)) | ||
} | ||
ctx.replyWithVideoNote = function replyWithVideoNote(videoNote, extra) { | ||
assert(ctx, 'chat', 'replyWithVideoNote') | ||
return ctx.telegram.sendVideoNote( | ||
ctx.chat.id, | ||
videoNote, | ||
makeReply(extra) | ||
) | ||
} | ||
ctx.replyWithVoice = function replyWithVoice(voice, extra) { | ||
assert(ctx, 'chat', 'replyWithVoice') | ||
return ctx.telegram.sendVoice(ctx.chat.id, voice, makeReply(extra)) | ||
} | ||
/** | ||
* Sets up Context to use the new reply methods. | ||
* ctx.reply() and ctx.replyWith*() methods will actually reply to the message they are replying to. | ||
* Use ctx.respond() to send a message in chat without replying to it. | ||
* | ||
* If the message to reply is deleted, reply() will send a normal message. | ||
* If the update is not a message and we are unable to reply, reply() will send a normal message. | ||
*/ | ||
export function useNewReplies<C extends Context>(): Middleware<C> { | ||
return (ctx, next) => { | ||
Object.assign(ctx, replyContext) | ||
return next() | ||
} | ||
} |
import Context from './context'; | ||
import { Middleware } from './middleware'; | ||
export declare function newReplies<C extends Context>(): Middleware<C>; | ||
/** | ||
* Sets up Context to use the new reply methods. | ||
* ctx.reply() and ctx.replyWith*() methods will actually reply to the message they are replying to. | ||
* Use ctx.respond() to send a message in chat without replying to it. | ||
* | ||
* If the message to reply is deleted, reply() will send a normal message. | ||
* If the update is not a message and we are unable to reply, reply() will send a normal message. | ||
*/ | ||
export declare function useNewReplies<C extends Context>(): Middleware<C>; | ||
//# sourceMappingURL=future.d.ts.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
481963
10453