@busshi/telegram-api
v2.0.6
Published
Basic Telegram API to interact with your bot
Readme
npm-telegram-api
Node package for the Telegram API
Installation
yarn add @busshi/telegram-api
or
npm install @busshi/telegram-api
Functionnalities
| Method | Parameters | | :-- | :-- | | sendMessage | chatId: stringtext: stringdisableNotification: boolean (optional, default: false) | | editMessage | chatId: stringmessageId: stringtext: string | | deleteMessage | chatId: stringmessageId: string | | sendPhoto | chatId: stringpicUrl: stringdisableNotification: boolean (optional, default: false) | | sendDocument | chatId: stringfileUrl: stringdisableNotification: boolean (optional, default: false) | | sendVideoNote | chatId: stringvideoUrl: stringdisableNotification: boolean (optional, default: false) | | sendPoll | chatId: stringquestion: stringoptions: string[]disableNotification: boolen (optional, default: false)isAnonymous: boolean (optional, default: false) | | sendSticker | chatId: stringstickerId: string | | sendDice | chatId: string (get a random number from 1 to 6) |
Usage
import Telegram from '@busshi/telegram-api';
const telegram = new Telegram(BOT_TOKEN);
const req = await telegram.sendMessage(CHAT_ID, 'Hello world!');
const messageId = req.dat.result.message_id;
telegram.editMessage(CHAT_ID, messageId, 'Edited message');
telegram.deleteMessage(CHAT_ID, messageId);
telegram.sendPhoto(CHAT_ID, PICTURE_URL);
telegram.sendDocument(CHAT_ID, DOCUMENT_URL);
telegram.sendVideoNote(CHAT_ID, VIDEO_URL);
telegram.sendPoll(CHAT_ID, QUESTION, OPTIONS);
telegram.sendPoll(CHAT_ID, 'Is it working?', ['yes', 'no']);
telegram.sendSticker(CHAT_ID, STICKER_ID);
telegram.sendSticker(CHAT_ID, 'CAACAgIAAxkBAAI6GV6vP_F6BaWapEmBZ2k8e8yBi2xMAAICAwACusCVBTRFBuRNlNodGQQ');
telegram.sendDice(CHAT_ID);