Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tgairbot

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tgairbot

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

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

#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")
    }
}

Keywords

FAQs

Package last updated on 17 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc