npm.io
2.0.6 • Published 3 years ago

@busshi/telegram-api

Licence
MIT
Version
2.0.6
Deps
1
Size
36 kB
Vulns
0
Weekly
0

publish

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: string
  • text: string
  • disableNotification: boolean (optional, default: false)
editMessage
  • chatId: string
  • messageId: string
  • text: string
deleteMessage
  • chatId: string
  • messageId: string
sendPhoto
  • chatId: string
  • picUrl: string
  • disableNotification: boolean (optional, default: false)
sendDocument
  • chatId: string
  • fileUrl: string
  • disableNotification: boolean (optional, default: false)
sendVideoNote
  • chatId: string
  • videoUrl: string
  • disableNotification: boolean (optional, default: false)
sendPoll
  • chatId: string
  • question: string
  • options: string[]
  • disableNotification: boolen (optional, default: false)
  • isAnonymous: boolean (optional, default: false)
sendSticker
  • chatId: string
  • stickerId: 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);

Keywords