GithubHelp home page GithubHelp logo

vsamaru / examples Goto Github PK

View Code? Open in Web Editor NEW

This project forked from grammyjs/examples

0.0 0.0 0.0 52 KB

Example bots to help you get started with grammY

Home Page: https://grammy.dev/demo/examples

License: MIT License

TypeScript 97.95% Dockerfile 1.19% Shell 0.86%

examples's Introduction

grammY Example Bots

This repository provides a number of example bots to help you get started.

  1. Create a bot with @BotFather, and get the bot token
  2. Clone this example repository
  3. Run npm install in the root directory of this repo
  4. Paste your token into the bot source file that you want to run (e.g. ./echo.ts)
  5. Run a bot with:
npm run bot <name>

# Example:
npm run bot echo

Hello World (echo)

A simple echo bot that echoes all text messages.

Send a Single Message (send-message)

Not a real bot, only illustrates how to manually send a single message once. Maybe useful for scripts.

Nested Menus (menu)

Advanced menu example bot that lets you manage different dishes (Pasta, Pizza, Sushi, Entrecôte) via a nested menu structure. It shows how to build more complex menus where all data is generated at runtime.

Media Menus (menu-with-photo)

Similar to the nested menu example, but with menu messages that include photos.

Sessions (stats)

Full-blown example bot that counts messages in a chat and stores the statistics in session objects.

Lazy Sessions (stats-lazy)

Full-blown example bot that counts photos in a chat and stores the statistics using lazy sessions. The advantage of lazy sessions is that the storage is only queried whenever data is actually needed.

(Note that this bot stores data in-memory, it does not connect to a real database. Therefore, using lazy sessions does not make much sense. This bot uses them anyway in order to illustrate how to use them.)

Runner Example (runner)

Illustrates how to use the @grammyjs/runner package that is useful for large bots.

Scaling Example (scaling)

An advanced but minimal example bot that demonstrates a viable directory structure, for the collective orchestration of custom context flavors, transformers, sessions with initial data, composers, and routers.

Example bot that can run on Vercel.

Illustrates how to run a bot using a local Bot API server via Docker.

Illustrates how to run a bot using a local Bot API server with a reverse proxy and self-signed certificate via Docker.

Please Contribute

We could need some more examples here, e.g. about

  • command handling
  • filter queries
  • inline keyboards
  • file support

and other things.

examples's People

Contributors

deptyped avatar habemuscode avatar knightniwrem avatar knorpelsenf avatar linbuxiao avatar rojvv avatar walidvb avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.