All Projects â†’ telekits â†’ teleapi

telekits / teleapi

Licence: MIT license
🚀 The useful library to simplify your work with Telegram Bot API

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to teleapi

shopee-inventory-bot
"I Make dropshiper's job easier" ~ Python Shopee Inventory Bot
Stars: ✭ 21 (-63.79%)
Mutual labels:  telegram-api
tdlight-java
Complete Bot and Userbot Telegram library based on TDLib
Stars: ✭ 128 (+120.69%)
Mutual labels:  telegram-api
addmember-telegram
Add member auto to telegram group
Stars: ✭ 170 (+193.1%)
Mutual labels:  telegram-api
telresender
A Telegram bot, which resend your message to another account
Stars: ✭ 22 (-62.07%)
Mutual labels:  telegram-api
telescan
No description or website provided.
Stars: ✭ 120 (+106.9%)
Mutual labels:  telegram-api
TGCopyBot
A python script to copy telegram messages to another chat (without forwarding)
Stars: ✭ 67 (+15.52%)
Mutual labels:  telegram-api
aiotdlib
Python asyncio Telegram client based on TDLib https://github.com/tdlib/td
Stars: ✭ 63 (+8.62%)
Mutual labels:  telegram-api
Bybit-Auto-Trading-Bot-Ordes-placed-via-TradingView-Webhook
Python based Trading Bot that uses TradingView.com webhook JSON alerts to place orders(buy/sell/close/manage positions/TP/SL/TS etc.) on Bybit.com. Hire me directly here https://www.freelancer.com/u/Beannsofts for any assistance
Stars: ✭ 235 (+305.17%)
Mutual labels:  telegram-api
nimgram
An MTProto client written in Nim 👑
Stars: ✭ 61 (+5.17%)
Mutual labels:  telegram-api
JavaTelegramBot-API
Java Telegram Bot API
Stars: ✭ 34 (-41.38%)
Mutual labels:  telegram-api
pyrubrum
An intuitive framework for creating Telegram bots.
Stars: ✭ 33 (-43.1%)
Mutual labels:  telegram-api
teleflask
A python telegram bot framework based on flask and pytgbot
Stars: ✭ 43 (-25.86%)
Mutual labels:  telegram-api
kotlogram2
An convinient wrapper for kotlogram
Stars: ✭ 17 (-70.69%)
Mutual labels:  telegram-api
telegram-log
Send a Telegram message when your scripts fire an exception or when they finish their execution.
Stars: ✭ 16 (-72.41%)
Mutual labels:  telegram-api
node-tdlib
TDLib Binding with Telegram Bot API Reimplemention for Node.js
Stars: ✭ 35 (-39.66%)
Mutual labels:  telegram-api
AbilityBots
The AbilityBots abstraction and API for building expressive Java Telegram Bots
Stars: ✭ 12 (-79.31%)
Mutual labels:  telegram-api
telegram-osint-lib
Telegram scenario-based API aimed at OSINT
Stars: ✭ 131 (+125.86%)
Mutual labels:  telegram-api
Telegram-mailer
Web-application for sending messages to list of users. Use several accounts to avoid ban.
Stars: ✭ 28 (-51.72%)
Mutual labels:  telegram-api
opentele
A Python Telegram API Library for converting between tdata and telethon sessions, with built-in official Telegram APIs.
Stars: ✭ 90 (+55.17%)
Mutual labels:  telegram-api
telegram-github-search-bot
A Github search bot for Telegram
Stars: ✭ 67 (+15.52%)
Mutual labels:  telegram-api

Header image

telekit  •  teleapi

Build Status npm npm Airbnb code style license

Now support the Telegram Bot API 3.6

What is it?

This is useful library to simplify your work with the Telegram Bot API

Before you start, please, read an introduction for developers.
Just a moment, I'll read it.

Install

npm

$ npm install teleapi --save

yarn

$ yarn add teleapi

How it use?

Elementary! Look at the next example that show you how to send request to getMe method:

/** First be we've required the teleapi */
const teleapi = require('teleapi');

/**
 * Next we need a get an instance of the teleapi.
 * Also, we should set the bot token.
 */
const api = teleapi('telegram_bot_token');

/**
 * And now we can send requests to the Telegram Bot API;
 * This method returns info about the bot to us.
 *
 * (`getMe` method is available in the Telegram Bot API).
 */
api.getMe().then((response) => {
    /** Bot ID */
    console.log('id:', response.id);
    /** and username of the our bot */
    console.log('username:', response.username);

    /**
     * And also first name and last name and lang code.
     * See about it below.
     */
}).catch((error) => {
    /** Something is wrong! */
    console.log(error);
});

If you want to see available methods and types:
Please, have a look at here first.

API

teleapi(token, [api]);

  • token:String - Token of the Bot that you can get from the BotFather
  • api:Object - (optional) An Object with Custom API(see api.json)
  • Returns: api - An instance of the teleapi.

Creates an new instance of the teleapi with your token of the bot.

teleapi.version:String

A contain of the current API version.

teleapi.methods:Array

A contain an Array of String with all available methods.

api.getFile(id);

  • id:String - File ID
  • Returns: Stream - A stream with file data

Get file from the Telegram.

api.method(name, [params]);

  • name:String - Name of the method that available in the Telegram Bot API
  • params:Object - (optional) An Object with body params for the request
  • Returns: Promise with response in then

This method send request to the Telegram Bot API;
It's private method but you can use it.

api.<method>(params);

  • params:Object - An Object with body params for the request
  • Returns: Promise with response in then

The <method> is one of the available methods from Telegram Bot API.

See all available methods here.

Examples

Send text message to chat

const teleapi = require('teleapi');

const api = teleapi('telegram_bot_token');

/** Send request with chat and text message */
api.sendMessage({
    chat_id: 0000,
    text: 'Hello!', 
});

Save file from the Telegram

const teleapi = require('teleapi');

const api = teleapi('telegram_bot_token');

/** Send request with file id */
api.getFile('file_id').pipe(fs.createWriteStream('image.png'));

Send sticker(file_id)

const teleapi = require('teleapi');

const api = teleapi('telegram_bot_token');

/** Send request where `sticker` is a file id */
api.sendSticker({
   chat_id: 0000,
   sticker: 'file_id', 
});

Send document(stream.Readable)

const teleapi = require('teleapi');
const fs = require('fs');

const api = teleapi('telegram_bot_token');

/** Send request where `document` is stream.Readable */
api.sendDocument({
   chat_id: 0000,
   document: fs.readFile('book_from_tpb.pdf'), 
});

Send photo(URL)

const teleapi = require('teleapi');

const api = teleapi('telegram_bot_token');

/** Send request where `photo` is an URL */
api.sendPhoto({
   chat_id: 0000,
   photo: 'https://upload.wikimedia.org/wikipedia/commons/d/d9/Test.png', 
});

Send voice(Buffer)

const teleapi = require('teleapi');

const api = teleapi('telegram_bot_token');

/** Send request where `voice` is a Buffer */
api.sendVoice({
   chat_id: 0000,
   voice: new Buffer([1, 2, 3]), 
});

Send document(strict)

const teleapi = require('teleapi');
const fs = require('fs');

const api = teleapi('telegram_bot_token');

/** Send request where 'document' is an Object with strict data */
api.sendDocument({
    chat_id: 000000,
    document: {
        filename: 'photo.png',
        value: fs.readFile('family_photo.dat'),
        mime: 'image/png',
    },
});

A more is coming soon.

LICENSE

MIT © Denis Maslennikov

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].