https://github.com/adityathebe/simple-telegram-bot-api
A simple Telegram Bot API wrapper with zero dependencies
https://github.com/adityathebe/simple-telegram-bot-api
telegram telegram-bot telegram-bot-api
Last synced: about 1 month ago
JSON representation
A simple Telegram Bot API wrapper with zero dependencies
- Host: GitHub
- URL: https://github.com/adityathebe/simple-telegram-bot-api
- Owner: adityathebe
- Created: 2019-08-16T15:24:22.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-09-14T08:50:38.000Z (almost 7 years ago)
- Last Synced: 2025-12-22T22:16:04.122Z (6 months ago)
- Topics: telegram, telegram-bot, telegram-bot-api
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# Simple Telegram Bot API Wrapper
## Installation
```bash
# npm
npm install simple-telegram-bot-api --save-dev
# yarn
yarn add simple-telegram-bot-api --dev
```
## Usage
```js
const TelgramBot = require('simple-telegram-bot-api');
const token = 'bot123456789:BBHukdff2134mOYi123asdap7byDwO7dasdasP1231';
const username = 'jarvisbot';
const bot = new TelegramBot(token, username);
// With async/await
(async () => {
try {
await bot.sendMessage('123456', 'Hello World with async/await');
console.log('Message sent')
} catch (err) {
console.error(err);
}
})();
// With Promises
bot.sendMessage('123456', 'Hello World with Promise')
.then(() => console.log('Message sent'))
.catch(console.error)
```
## Try out the examples
First you need to install dotenv
```bash
# npm
npm install dotenv
# yarn
yarn add dotenv
```
Create a file named `.env` in the root directory. The file should have the following values
```
APIKEY=
BOTUSERNAME=
WEBHOOK_URL=
RECEIVER=
```
Then run the examples from the root dir
```bash
node Examples/sendMessage.js
node Examples/sendPhoto
```