npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vow-telegram-bot

v0.2.1

Published

Telegram Bot API

Downloads

51

Readme

vow-telegram-bot

npm install vow-telegram-bot

Simple examples with long polling:

var VowTelegramBot = require('vow-telegram-bot'),
    bot = new VowTelegramBot({
        token: 'TELEGRAM_BOT_TOKEN',
        polling: {
            timeout: 3,
            limit: 100
        }
    });

bot.on('message', function(message) {

    var from = message.from;

    console.log(from.first_name + ' ' + from.last_name + ': ' + message.text);

    bot.sendMessage({
        chat_id: message.chat.id,
        text: 'Test message from bot'
    }).then(function(message) {
        console.log('Message sent', message);
    });

});
var VowTelegramBot = require('vow-telegram-bot'),
    bot = new VowTelegramBot({
        token: 'TELEGRAM_BOT_TOKEN',
        polling: {
            timeout: 3,
            limit: 100
        }
    });

bot.on('message', function(message) {

    bot.sendChatAction({
        chat_id: message.chat.id,
        action: 'upload_photo'
    });

    setTimeout(function() {
        bot.sendPhoto({
            chat_id: message.chat.id,
            photo: 'example.png',
            caption: 'Photo from bot'
        }).then(function(message) {
            console.log('Photo sent', message);
        });
    }, 5000);

});

Examples with webhook (only HTTPS):

var VowTelegramBot = require('vow-telegram-bot'),
    bot = new VowTelegramBot({
        token: 'TELEGRAM_BOT_TOKEN',
        webhook: {
            url: 'https://example.com/web/hook/path',
            port: 3333 // listen http requests on port 3333 (ssl maybe configured in nginx)
        }
    });

bot.on('message', function(message) {
    console.log(message);
});
var VowTelegramBot = require('vow-telegram-bot'),
    bot = new VowTelegramBot({
        token: 'TELEGRAM_BOT_TOKEN',
        webhook: {
            url: 'https://example.com/web/hook/path',
            key: '/path/to/private/key',
            cert: '/path/to/certificate',
            port: 443
        }
    });

bot.on('message', function(message) {
    console.log(message);
});

API

See https://core.telegram.org/bots/api

getUpdates([params], [onSuccess], [onError])

Use this method to receive incoming updates using long polling. An Array of Update objects is returned.

See https://core.telegram.org/bots/api#getupdates

getMe([onSuccess], [onError])

A simple method for testing your bot's auth token. Requires no parameters.

See https://core.telegram.org/bots/api#getme

sendMessage(params, [onSuccess], [onError])

Use this method to send text messages.

See https://core.telegram.org/bots/api#sendmessage

forwardMessage(params, [onSuccess], [onError])

Use this method to forward messages of any kind.

See https://core.telegram.org/bots/api#forwardmessage

sendPhoto(params, [onSuccess], [onError])

Use this method to send photos.

See https://core.telegram.org/bots/api#sendphoto

sendAudio(params, [onSuccess], [onError])

Use this method to send audio files, if you want Telegram clients to display the file as a playable voice message. For this to work, your audio must be in an .ogg file encoded with OPUS (other formats may be sent as Document). Bots can currently send audio files of up to 50 MB in size, this limit may be changed in the future.

See https://core.telegram.org/bots/api#sendaudio

sendDocument(params, [onSuccess], [onError])

Use this method to send general files. Bots can currently send files of any type of up to 50 MB in size, this limit may be changed in the future.

See https://core.telegram.org/bots/api#senddocument

sendSticker(params, [onSuccess], [onError])

Use this method to send .webp stickers.

See https://core.telegram.org/bots/api#sendsticker

sendVideo(params, [onSuccess], [onError])

Use this method to send video files, Telegram clients support mp4 videos (other formats may be sent as Document). Bots can currently send video files of up to 50 MB in size, this limit may be changed in the future.

See https://core.telegram.org/bots/api#sendvideo

sendLocation(params, [onSuccess], [onError])

Use this method to send point on the map.

See https://core.telegram.org/bots/api#sendlocation

sendChatAction(params, [onSuccess], [onError])

Use this method when you need to tell the user that something is happening on the bot's side. The status is set for 5 seconds or less (when a message arrives from your bot, Telegram clients clear its typing status).

See https://core.telegram.org/bots/api#sendchataction

getUserProfilePhotos(params, [onSuccess], [onError])

Use this method to get a list of profile pictures for a user.

See https://core.telegram.org/bots/api#getuserprofilephotos