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

tbot-generator

v0.0.7

Published

A simple generator for NodeJS Telegram Bots

Downloads

1

Readme

tbot-generator

A generator for Telegram Bots in nodeJS

Installation

Install the package globally :

npm install -g tbot-generator

Usage

Go to your project folder :

cd myProjectFolder/

Make sure to have a package.json file, if you havn't use the following command :

npm init

To run it you'll need a version of node over 6.3.1, if you don't have it you can upgrade your node version using nvm doing the following :

echo 6.3.1 > .nvmrc
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.31.4/install.sh | bash
nvm install
nvm use

To generate your bot use the command :

tbot-gen

Follow the instructions.
Your package.json file has been updated, so install the new packages with :

npm install

Your bot is now ready to run !
Run it with :

node app/bot.js

Generation

During the generation you must give your Bot Key that you can get from @BotFather.

Basic Bot

No particularity for this bot, just basics.
The structure of this bot is :

app/                     --> all of the source files for the bot
  bot.js                  --> entry point, contains the router
  config.template.json    --> example versionned file for the configuration
  config.json             --> configuration file, not versionned
  controllers/             --> all the controllers
    HelloWorldController.js --> A Controller that replies "Hello World !" 
    PingController.js       --> A Controller that replies "ping" or "pong"
.gitignore               --> ignore 'app/config.json' file

This bot replies to :

  • the command /ping, replies 'pong'
  • the command /pong, replies 'ping'
  • the word hello, replies 'Hello World'
  • any other message by default with 'Default Message'

Bot with MongoDB

This bot is the same as the Basic Bot but having MongoDB set up.

If you don't have MongoDB, you can get it from here.

Make sure to have the server up and running before starting the bot.

The structure of this bot is :

app/                     --> all of the source files for the bot
  bot.js                  --> entry point, contains the router and DB connection
  config.template.json    --> example versionned file for the configuration
  config.json             --> configuration file, not versionned
  controllers/            --> all the controllers
    HelloWorldController.js --> A Controller that replies "Hello World !" 
    PingController.js       --> A Controller that replies "ping" or "pong"
    MessageController.js    --> A Controller that manage Message in the DB
  models/                 --> all the DB Models
    MessageModel.js         --> A Message MongoDB Model 
.gitignore               --> ignore 'app/config.json' file

This bot replies to :

  • the command /ping, replies 'pong'
  • the command /pong, replies 'ping'
  • the command /save myMessage, which save the Message 'myMessage' in the database
  • the command /list, which displays all the Messages stored
  • the command /clear, which remove all the Messages stored
  • the word hello, replies 'Hello World'
  • any other message by default with 'Default Message'

Programming

The structure depends on the bot you are using and are explained above for the Basic bot and the MongoDB Bot.

To program please use the following documentation :

  • For the communication with the Telegram API and understanding the bot structure, read telegram-node-bot documentation
  • To use the MongoDB database, explore the mongoose website

Credits

Loïc Touzard