telegram-bot-api-nodejs
Advanced tools
Comparing version 1.0.13 to 1.0.14
@@ -555,3 +555,18 @@ export type ChatType = "private" | "group" | "supergroup" | "channel"; | ||
export declare function sendAnimation(token: string, payload: SendAnimationOptions, signal: AbortSignal): Promise<Message>; | ||
export declare function sendDocument(token: string, payload: SendDocumentOptions, signal: AbortSignal): Promise<Message>; | ||
/** | ||
* @example | ||
* | ||
* const body = new FormData() | ||
* | ||
* body.append("chat_id", payload.chat_id) | ||
* body.append("caption", payload.caption) | ||
* body.append("document", payload.document, payload.documentName) | ||
* | ||
* if (payload.parse_mode) { | ||
* body.append("parse_mode", payload.parse_mode) | ||
* } | ||
* | ||
* sendDocument("token", payload) | ||
*/ | ||
export declare function sendDocument(token: string, payload: SendDocumentOptions | FormData, signal: AbortSignal): Promise<Message>; | ||
export declare function sendMediaGroup(token: string, payload: SendMediaGroupOptions, signal: AbortSignal): Promise<Message[]>; | ||
@@ -672,8 +687,8 @@ export declare function setMessageReaction(token: string, payload: { | ||
export declare const SUPPORTED_REACTION_EMOJI: string[]; | ||
export declare function isUnauthorizedError(err: unknown): err is Error; | ||
export declare function isBotBlockedByUserError(err: unknown): err is Error; | ||
export declare function isChatNotFoundError(err: unknown): err is Error; | ||
export declare function isUserDeactivatedError(err: unknown): err is Error; | ||
export declare function isBotKickedFromSupergroupError(err: unknown): err is Error; | ||
export declare function isNotEnoughRightsError(err: unknown): err is Error; | ||
export declare function isUnauthorizedError(err: unknown): boolean; | ||
export declare function isBotBlockedByUserError(err: unknown): boolean; | ||
export declare function isChatNotFoundError(err: unknown): boolean; | ||
export declare function isUserDeactivatedError(err: unknown): boolean; | ||
export declare function isBotKickedFromSupergroupError(err: unknown): boolean; | ||
export declare function isNotEnoughRightsError(err: unknown): boolean; | ||
export {}; |
28
index.js
@@ -73,7 +73,31 @@ /** | ||
} | ||
/** | ||
* @example | ||
* | ||
* const body = new FormData() | ||
* | ||
* body.append("chat_id", payload.chat_id) | ||
* body.append("caption", payload.caption) | ||
* body.append("document", payload.document, payload.documentName) | ||
* | ||
* if (payload.parse_mode) { | ||
* body.append("parse_mode", payload.parse_mode) | ||
* } | ||
* | ||
* sendDocument("token", payload) | ||
*/ | ||
export function sendDocument(token, payload, signal) { | ||
let h = headers; | ||
let b = undefined; | ||
if (payload instanceof FormData) { | ||
h = undefined; | ||
b = payload; | ||
} | ||
else { | ||
b = JSON.stringify(payload); | ||
} | ||
return fetch(`https://api.telegram.org/bot${token}/sendDocument`, { | ||
method: "POST", | ||
body: JSON.stringify(payload), | ||
headers, | ||
body: b, | ||
headers: h, | ||
signal | ||
@@ -80,0 +104,0 @@ }).then((parseResponse)); |
{ | ||
"name": "telegram-bot-api-nodejs", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "Telegram Bot API client for nodejs", | ||
@@ -5,0 +5,0 @@ "type": "module", |
38733
1237