npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tanos-v2

v0.0.52

Published

![Tanos](https://res.cloudinary.com/nixar-work/image/upload/v1561861668/Screen_Shot_2019-06-30_at_05.27.40.png)

Downloads

9

Readme

Tanos

Telegram Bot Builder Framwork

Install

sh

npm i tanos --save

Services:

  • Http Service
  • Telegram Service

Get Started

Create config.js


const Bot = require('telegram-bot-api');
const leveup = require('levelup');
const memdown = require('memdown');
const encode = require('encoding-down')
const bot = new Bot('token');
const db = levelup(encode(memdown('./db2'), { valueEncoding: 'json' }))


module.exports = {
    "bot"  : bot,  
    "db" : db,
    "serverAddress"  : "http://your-domain-for-telegram-passport",
    "serverPort"     : 80,
    "serverSslPort"  : 443,
    "botName" : "your_bot",
    "types" : ["private", "group", "supergroup"],
    "inputCommands" : ["/start", "/trends"]
}

where

  • bot - telegram-bot-api bot instance
  • db - levelup db instance, valueEncoding: 'json'
  • serverAddress - only for telegram passport (optional)
  • serverPort - for HTTP API (optional)
  • serverSslPort - for HTTPS API (optional)
  • botName - registered bot name in BotFather
  • types - list of supported chat types
  • inputCommands - list of supported commands. (remove if you want to track all)

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.js');
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