UNPKG

tgram.js

Version:

Lightweight modern library for telegram bot. use Node.js

16 lines (15 loc) 527 B
import telegramFetch from "../utility/telegram-fetch.js"; export async function sendMessage(token, chatId, text, options = {}) { const API_URL = `https://api.telegram.org/bot${token}/sendMessage` try { // Requests To API Client SENDMESSAGE. const res = await telegramFetch.post(API_URL, { chat_id: chatId, text: text, ...options }) } catch (errorRequests) { // Catch The error and return to console. throw new Error(errorRequests) } }