# tgairbot

> This is a library for creating progressive bots for Telegram. Based on the principle of MVS (Model, View, Service).

Latest version **1.0.2** (published 2020-07-17) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-07-17 |
| First published | 2020-07-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 15.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | vladimir_lisenko |
| Maintainers | vladimir_lisenko |
| Keywords | telegram-bot, tgairbot, node-telegram-bot-api |

## Links

- npm: https://www.npmjs.com/package/tgairbot
- Repository: https://github.com/morgota199/TgAirbot
- Homepage: https://github.com/morgota199/TgAirbot#readme
- Issues: https://github.com/morgota199/TgAirbot/issues
- npm.io page: https://npm.io/package/tgairbot

## Dependencies (5)

- [colors](https://npm.io/package/colors.md) ^1.4.0
- [dotenv](https://npm.io/package/dotenv.md) ^8.2.0
- [@types/color](https://npm.io/package/@types/color.md) ^3.0.1
- [node-telegram-bot-api](https://npm.io/package/node-telegram-bot-api.md) ^0.50.0
- [@types/node-telegram-bot-api](https://npm.io/package/@types/node-telegram-bot-api.md) ^0.50.2

## Recent versions

- 1.0.2 (latest) — 2020-07-17
- 1.0.1 — 2020-07-17
- 1.0.0 — 2020-07-17

## README

#TgAirBot

This is a library for creating progressive bots for Telegram. Based on the principle of MVS (Model, View, Service).

Uses TypeScript and in particular the extensive system of decorators.

####Work has just begun!!!
##Install
````
npm install tgairbot
````

##Install dependencies
````
npm i node-telegram-bot-api @types/node-telegram-bot-api
npm i @types/color colors
npm i dotenv 
````
##Using

````
    you project dir
    |
    +--dist (generated folder by typescript)
    | 
    +--node_modules
    | 
    +--src (folder for your bot)
    |  |
    |  |
    |  +--...folders module
    |  |
    |  +--you module folder
    |  |  |
    |  |  +-- *.module.ts (module file)
    |  |  |
    |  |  +-- *.view.ts (view file)
    |  |  |
    |  |  +-- *.service.ts (service file)
    |  |
    |  +--main.ts (input file)
    |
    +--.env
    |
    +--package.json
    |
    +--tsconfig.json
````

* ###tsconfig.ts
````
{
    "compilerOptions": {
        "target": "es6",  
        "module": "commonjs",
        "outDir": "./dist",   
        "rootDir": "./src",   
        "strict": true,                          
        "esModuleInterop": true,
        "experimentalDecorators": true,
        "emitDecoratorMetadata": true, 
        "skipLibCheck": true,           
        "forceConsistentCasingInFileNames": true
    }
}
````

* ###package.json
````
{
  ..., 

  "scripts": {
    "start": "node ./dist/main.js",
    "start:dev": "tsc && npm run start"
  },

  ...,

  "dependencies": {
    "@types/color": "^3.0.1",
    "@types/node-telegram-bot-api": "^0.50.2",
    "colors": "^1.4.0",
    "dotenv": "^8.2.0",
    "node-telegram-bot-api": "^0.50.0"
  }
}

````

At the root of the project you need an .env file with the submitted fields

````
TELEGRAM_TOKEN=you telegram bot token
````

* ###main.ts
````
import { Airbot } from 'tgairbot/airbot'
import { HelloModule } from "./hello/hello.module"

const bot = new Airbot({polling: true})

bot.Create(HelloModule)
````

* ###hello.module.ts
````
import { Module } from "tgairbot/module/module"
import { HelloView } from "./hello.view"

@Module({
    name: "HelloModule",
    imports: [],
    views: [HelloView],
    services: []
})
export class HelloModule {
    constructor(...args: any[]) {}
}
````

* ###hello.view.ts
````
import { View } from 'tgairbot/view/view'
import { HelloService } from './hello.service'

@View({
    name: "HelloView",
    service: [HelloService]
})
export class HelloView {
    constructor(private helloService: HelloService) {}
    
    first_message() {
        return this.helloService.first_message()
    }
}
````

* ###hello.service.ts
````
import { Service } from "tgairbot/service/service"

@Service({
    name: "HelloService"
})
export class HelloService {

    first_message() {
        return console.log("Hello")
    }
}
````

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