# tgbotars

> Telegram Bot

Latest version **0.1.1** (published 2019-09-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tgbotars
pnpm add tgbotars
yarn add tgbotars
bun add tgbotars
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2019-09-19 |
| First published | 2019-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 70.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Firas |
| Maintainers | iifiras |
| Keywords | bot, telegram bot, telegram bot api, tgbotar, telegram api, telegram, api |

## Links

- npm: https://www.npmjs.com/package/tgbotars
- Repository: https://github.com/i7Firas/tgbotar
- Issues: https://github.com/i7Firas/tgbotar/issues
- npm.io page: https://npm.io/package/tgbotars

## Recent versions

- 0.1.1 (latest) — 2019-09-19
- 0.1.0 — 2019-09-19

## README

![](https://telegra.ph/file/fd2d68a59c928de61f1fb.jpg)


**Library features:**

- 🤖 Full [Telegram Bot API 4.4](https://core.telegram.org/bots/API) support.
- 🔭 Easy to use.
- 💰 Supports [payments](https://core.telegram.org/bots/payments).
- 📡 Build-in modification and event system.

## 🔨 Installation

Download and install via [npm package manager](https://www.npmjs.com/package/tgbotar) (stable):

```
npm install tgbotar --save
```

Or clone fresh code directly from git:

```
git clone https://github.com/i7Firas/tgbotar.git
cd tgbotar
npm install
```

## 📌 Usage

Import `tgbotar` module and create a new bot object:

```js
const TGBotar = require('tgbotar');
const bot = new TGBotar('TELEGRAM_BOT_TOKEN');

bot.on('text', (msg) => msg.reply.text(msg.text));

bot.start();
```

*Don't forget to insert your [Telegram Bot API](https://core.telegram.org/bots#create-a-new-bot) token key.*


## 🔖 Examples

- Send text on `/start` or `/help` command:

```js
bot.on(['/start', '/help'], (msg) => msg.reply.text('Hello World'));
```

- Send photo:

```js
bot.on('/photo', (msg) => {
    return msg.reply.photo('https://telegra.ph/file/fd2d68a59c928de61f1fb.jpg');
});
```

- Command with arguments `/echo <message>`:

```js
bot.on(/^\/echo (.+)$/, (msg, argu) => {
    const text = argu.match[1];
    return bot.sendMessage(msg.from.id, text);
});
```

***[See more examples!](/examples)***

## ⏰ Events

Use ```bot.on(<event>, <function>)``` to handle all possible TGBotar events.
For example, to catch a command, just add a slash:

```js
bot.on('/start', (msg) => {
  return bot.sendMessage(msg.from.id, `Hello, ${ msg.from.first_name }`);
});
```

---
_Source: https://npm.io/package/tgbotars · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
