Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/web3space/tanos
Telegram Bot Builder Framework
https://github.com/web3space/tanos
telegram telegram-bot
Last synced: 4 days ago
JSON representation
Telegram Bot Builder Framework
- Host: GitHub
- URL: https://github.com/web3space/tanos
- Owner: web3space
- Created: 2019-05-15T23:12:21.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-19T13:59:29.000Z (about 5 years ago)
- Last Synced: 2024-11-25T19:29:58.165Z (2 months ago)
- Topics: telegram, telegram-bot
- Language: LiveScript
- Homepage:
- Size: 1.5 MB
- Stars: 5
- Watchers: 6
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![Tanos](https://res.cloudinary.com/nixar-work/image/upload/v1561861668/Screen_Shot_2019-06-30_at_05.27.40.png)
### Telegram Bot Builder Framwork
## Install
sh
```
npm i tanos --save
```Services:
* Http Service
* Telegram Service## Get Started
### Create config.json
```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)
```JSON
{
"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](LAYOUT.md)
### Create app.js
```Javascript
module.exports = ({ db, bot, tanos })=> {
const review = ($user, cb)=> {
// Some actions with $user data
cb(null);
}
return { review }
}```
### Create server.js
```Javascript
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
```