Notable Pseudocode Mashups

    @modern-dev/tgbotjs
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.1 • Public • Published

    Telegram Bot API for Node.js and browsers.

    Build Status codecov npm NPM

    TgBotJs - is a Promise-based Telegram Bot API wrapper for Node.ks and browsers.

    $ npm install --save @modern-dev/tgbotjs

    📋 Usage

    import { Bot } from '@modern-dev/tgbotjs';
    import { User } from '@modern-dev/tgbotjs/types';
    
    const token = 'your_bot_token';
    const bot = new Bot(token);
    const me: User = await bot.getMe();
    
    console.log(me.firstName);

    A list of all the methods is available here.

    The methods with up to 3 input params have the next signature:

    setChatTitle = (chatId: ChatId, title: string): Promise<boolean>
    getChat = (chatId: ChatId): Promise<Chat>
    getChatAdministrators = (chatId: ChatId): Promise<Array<ChatMember>>

    For example:

    const ok = await bot.setChatTitle('@M3MSY', 'Best memes from all over the internet.');

    The methods with 4+ input params accept a single object with all the required params as key-value pairs:

    getUpdates = (params: GetUpdatesParams): Promise<Array<Update>>
    sendMessage = (params: SendMessageParams): Promise<Message>
    sendPhoto = (params: SendPhotoParams): Promise<Message>

    For example:

    const params = {
      chatId: '@M3MSY',
      text: 'Welcome there!',
      disableNotification: true,
      replyToMessageId: 12345678
    };
    const msg = await bot.sendMessage(params);

    Uploading media.

    TgBotJs accepts Blob, File, ReadStream or Buffer as media upload options.

    For example:

    const photo = fs.createReadStream('/photos/chat_picture.jpg');
    const ok = await bot.setChatPhoto('@M3MSY', photo);

    📗 License

    Licensed under the MIT license.

    Copyright (c) 2020 Bohdan Shtepan


    modern-dev.com  ·  GitHub @virtyaluk  ·  Twitter @virtyaluk

    Install

    npm i @modern-dev/tgbotjs

    DownloadsWeekly Downloads

    1

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    124 kB

    Total Files

    27

    Last publish

    Collaborators

    • virtyaluk