# vv-telegram

> JavaScript (NodeJs): api for create telegram bot, based on https://github.com/telegraf/telegraf

Latest version **0.2.1** (published 2020-11-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install vv-telegram
pnpm add vv-telegram
yarn add vv-telegram
bun add vv-telegram
```

## 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.2.1 |
| Published | 2020-11-06 |
| First published | 2020-04-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 68.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Vitalii Vasilev |
| Maintainers | vasilev.v.vitalii |

## Links

- npm: https://www.npmjs.com/package/vv-telegram
- Repository: https://github.com/VasilevVitalii/vv-telegram
- Homepage: https://github.com/VasilevVitalii/vv-telegram#readme
- Issues: https://github.com/VasilevVitalii/vv-telegram/issues
- npm.io page: https://npm.io/package/vv-telegram

## Dependencies (6)

- [vv-http](https://npm.io/package/vv-http.md) 0.1.24
- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [telegraf](https://npm.io/package/telegraf.md) ^3.38.0
- [tz-lookup](https://npm.io/package/tz-lookup.md) ^6.1.25
- [vv-shared](https://npm.io/package/vv-shared.md) ^3.0.13
- [moment-timezone](https://npm.io/package/moment-timezone.md) ^0.5.31

## Recent versions

- 0.2.1 (latest) — 2020-11-06
- 0.1.13 — 2020-11-05
- 0.1.12 — 2020-11-03
- 0.1.10 — 2020-10-30
- 0.1.9 — 2020-10-29
- 0.1.8 — 2020-10-23
- 0.1.7 — 2020-10-16
- 0.1.6 — 2020-10-16
- 0.1.4 — 2020-10-15
- 0.1.3 — 2020-10-15
- 0.1.2 — 2020-10-15
- 0.1.1 — 2020-10-15
- 0.0.11 — 2020-10-14
- 0.0.10 — 2020-05-04
- 0.0.9 — 2020-04-25
- … 7 more at https://npm.io/package/vv-telegram/versions

## README

## Install & Use
```cmd
npm i vv-telegram
```
```js
const os = require('os')
const vvt = require('vv-telegram')
let bot = vvt.create('YOUR_TOKEN_BOT', {cache: {hours_life: 3}})

let t1 = 'short_text'
let t2 = 'long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text_long_text'

bot.start(error => {
    if (error) {
        console.log(error)
        process.exit()
    }
    console.log('BOT STARTED')

    bot.on_error(error => {
        console.log('ERROR IN BOT WORK:')
        console.log(error)
    })
    bot.on_message(message => {
        console.log(''.concat('message.message_id:', os.EOL, message.message_id, os.EOL, 'message.type_text:', os.EOL, message.type_text, os.EOL, 'message.text:', os.EOL, message.text))

        //demo delete prev message when user click on button in prev message
        let prev_file_find = false
        let prev_message = bot.get_from_cache_receiving({account: message.account, chat_id: message.chat_id, message_id: message.message_id, type_text: 'callback_data'})
        prev_message.forEach(m => {
            bot.message_delete(message.chat_id, m.message_id)
            prev_file_find = true
        })


        /** @type {vvt.package_sending_button[][]}  */
        let buttons = [
            [
                {text: 'b1', callback_data: '1_'.concat(t1)}, {text: 'b2', callback_data: '2_'.concat(t1)}, {text: 'b3', callback_data: '3_'.concat(t1)},
            ], [
                {text: 'b4', callback_data: '4_'.concat(t2)}, {text: 'b5', callback_data: '5_'.concat(t2)}, {text: 'b6', callback_data: '6_'.concat(t2)},
            ]
        ]

        let message_text = message.error ? 'ERROR: '.concat(message.error) : 'replay for '.concat(message.text)

        bot.message_send(
            message.account,
            message_text,
            {buttons: buttons, reply_to_message_id: prev_file_find ? undefined : message.message_id},
            undefined,
            (error, sending) => {
                if (error) {
                    console.log(error)
                    return
                }

                //demo edit prev message
                setTimeout(() => {
                    bot.message_send(
                        message.account,
                        'edited: '.concat(message_text),
                        {reply_to_message_id: message.message_id, buttons: buttons},
                        sending.message_id,
                        (error, sending) => {
                            if (error) {
                                console.log(error)
                                return
                            }
                        }
                    )
                }, 5000)
            }
        )
    })
})
```
## Functions

<dl>
<dt><a href="#create">create(token, [options])</a> ⇒ <code>app</code></dt>
<dd></dd>
<dt><a href="#button_line_to_matrix">button_line_to_matrix(button_line, width)</a> ⇒ <code>Array.&lt;Array.&lt;package_sending_button&gt;&gt;</code></dt>
<dd></dd>
</dl>

## Typedefs

<dl>
<dt><a href="#bot">bot</a> : <code>app</code></dt>
<dd></dd>
<dt><a href="#package_sending_button">package_sending_button</a> : <code>type.package_sending_button</code></dt>
<dd></dd>
<dt><a href="#package_sending_menu">package_sending_menu</a> : <code>type.package_sending_menu</code></dt>
<dd></dd>
<dt><a href="#package_sending_options">package_sending_options</a> : <code>type.package_sending_options</code></dt>
<dd></dd>
<dt><a href="#package_sending_text_format">package_sending_text_format</a> : <code>type.package_sending_text_format</code></dt>
<dd></dd>
<dt><a href="#package_receiving">package_receiving</a> : <code>type.package_receiving</code></dt>
<dd></dd>
<dt><a href="#package_sending">package_sending</a> : <code>type.package_sending</code></dt>
<dd></dd>
<dt><a href="#package_sending_queue">package_sending_queue</a> : <code>type.package_sending_queue</code></dt>
<dd></dd>
<dt><a href="#file_info">file_info</a> : <code>type.file_info</code></dt>
<dd></dd>
</dl>

<a name="create"></a>

## create(token, [options]) ⇒ <code>app</code>
**Kind**: global function  

| Param | Type |
| --- | --- |
| token | <code>string</code> | 
| [options] | <code>type.options</code> | 

<a name="button_line_to_matrix"></a>

## button\_line\_to\_matrix(button_line, width) ⇒ <code>Array.&lt;Array.&lt;package\_sending\_button&gt;&gt;</code>
**Kind**: global function  

| Param | Type |
| --- | --- |
| button_line | [<code>Array.&lt;package\_sending\_button&gt;</code>](#package_sending_button) | 
| width | <code>number</code> | 


* [button_line_to_matrix(button_line, width)](#button_line_to_matrix) ⇒ <code>Array.&lt;Array.&lt;package\_sending\_button&gt;&gt;</code>
    * [~result](#button_line_to_matrix..result) : <code>Array.&lt;Array.&lt;package\_sending\_button&gt;&gt;</code>
    * [~line](#button_line_to_matrix..line) : [<code>Array.&lt;package\_sending\_button&gt;</code>](#package_sending_button)

<a name="button_line_to_matrix..result"></a>

### button_line_to_matrix~result : <code>Array.&lt;Array.&lt;package\_sending\_button&gt;&gt;</code>
**Kind**: inner typedef of [<code>button\_line\_to\_matrix</code>](#button_line_to_matrix)  
<a name="button_line_to_matrix..line"></a>

### button_line_to_matrix~line : [<code>Array.&lt;package\_sending\_button&gt;</code>](#package_sending_button)
**Kind**: inner typedef of [<code>button\_line\_to\_matrix</code>](#button_line_to_matrix)  
<a name="bot"></a>

## bot : <code>app</code>
**Kind**: global typedef  
<a name="package_sending_button"></a>

## package\_sending\_button : <code>type.package\_sending\_button</code>
**Kind**: global typedef  
<a name="package_sending_menu"></a>

## package\_sending\_menu : <code>type.package\_sending\_menu</code>
**Kind**: global typedef  
<a name="package_sending_options"></a>

## package\_sending\_options : <code>type.package\_sending\_options</code>
**Kind**: global typedef  
<a name="package_sending_text_format"></a>

## package\_sending\_text\_format : <code>type.package\_sending\_text\_format</code>
**Kind**: global typedef  
<a name="package_receiving"></a>

## package\_receiving : <code>type.package\_receiving</code>
**Kind**: global typedef  
<a name="package_sending"></a>

## package\_sending : <code>type.package\_sending</code>
**Kind**: global typedef  
<a name="package_sending_queue"></a>

## package\_sending\_queue : <code>type.package\_sending\_queue</code>
**Kind**: global typedef  
<a name="file_info"></a>

## file\_info : <code>type.file\_info</code>
**Kind**: global typedef

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