1.0.40 • Published 4 years ago

tanos v1.0.40

Weekly downloads
40
License
ISC
Repository
-
Last release
4 years ago

Tanos

Telegram Bot Builder Framwork

Install

sh

npm i tanos --save

Services:

  • Http Service
  • Telegram Service

Get Started

Create config.json

{
    "telegramToken"  : "881177358:000000000000000000000000",  
    "serverAddress"  : "http://your-domain-for-telegram-passport",
    "serverPort"     : 80,
    "serverSslPort"  : 443,
    "dbType" : "drive",
    "botName" : "your_bot"
}

where

  • telegramToken - get from @BotFather (required)
  • serverAddress - only for telegram passport (optional)
  • serverPort - for HTTP API
  • serverSslPort - for HTTPS API (optional)
  • dbType - could be memory or drive.
  • botName - registered bot name in BotFather

Create layout.json (KYC bot Example)

{
   "main:bot-step":{
      "onEnter":"$global.admins = [$user.chat_id] if not $global.admins?",
      "text":"Please choose the action below",
      "buttons":{
         "Pass KYC Verification":"goto:kyc"
      }
   },
   "kyc:bot-step":{
      "text":"Please enter your email",
      "onText":{
         "goto":"passport",
         "store":"$user.email = $text"
      }
   },
   "passport:bot-step":{
      "text":"Please attach your Passport",
      "onText":{
         "goto":"utility",
         "store":"$user.passport = $text"
      }
   },
   "utility:bot-step":{
      "text":"Please attach your Utility Bill",
      "onText":{
         "goto":"address",
         "store":"$user.utility = $text"
      }
   },
   "address:bot-step":{
      "text":"Please enter your Living Address",
      "onText":{
         "goto":"firstname",
         "store":"$user.address = $text"
      }
   },
   "firstname:bot-step":{
      "text":"Please enter your First Name",
      "onText":{
         "goto":"lastname",
         "store":"$user.firstname = $text"
      }
   },
   "lastname:bot-step":{
      "text":"Please enter your Last Name",
      "onText":{
         "goto":"finish",
         "store":"$user.lastname = $text"
      }
   },
   "finish:bot-step":{
      "onEnter":"({ $user, $app }, cb)-> $app.review $user, cb",
      "text":"Your application has been sent. Please wait for review",
      "buttons":{
         "Pass KYC Verification again":"goto:kyc"
      }
   }
}

This configuration supports images, text, buttons, menu, text validators, localization. More information is available here

Create app.js

module.exports = ({ db, bot, tanos })=> {
    
    const review = ($user, cb)=> {
        // Some actions with $user data
        cb(null);
    }
    
    return { review }
}

Create server.js

const tanos  = require('tanos');
const config = require('./config.json');
const layout = require('./layout.json');
const app     = require('./app.js');

tanos({ layout, app, ...config }, (err)=> {
   console.log("Telegram Bot has been started") 
});

Start

node server.js
1.0.40

4 years ago

1.0.39

4 years ago

1.0.38

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.33

5 years ago

1.0.32

5 years ago

1.0.31

5 years ago

1.0.30

5 years ago

1.0.29

5 years ago

1.0.28

5 years ago

1.0.26

5 years ago

1.0.25

5 years ago

1.0.24

5 years ago

1.0.22

5 years ago

1.0.21

5 years ago

1.0.20

5 years ago

1.0.19

5 years ago

1.0.18

5 years ago

1.0.17

5 years ago

1.0.16

5 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago