Giter Site home page Giter Site logo

Comments (2)

dotcypress avatar dotcypress commented on May 6, 2024

Hey Zwe!

Thank you for feedback. Much appreciated.

Approach with registration callback_query handlers "on the fly" isn't ok. For example, graceful restart is't possible with in-memory handlers.

Related to your problem: you might use db for storing 'authorization' task details.

app.action('enable', startEnableHandler)

function startEmailHandler(ctx) {
  // if (!this.session.started) return; // BTW: You can filter this on top level ;)
  // const email
  // delete this.session.started;
  // messageId = sendMessage(adminId, "Hey, ${email} wants to be enabled, is it ok?", keyboardWithYesAndNo);
  // db.save(messageId, { user, email, etc })
}

function startEnableHandler(ctx) {
  // data = db.get(ctx.message.id)  
  // const userId = data...
  // const telegramId = data...
  // user.telegramId = telegramId;
  // sendMessage(telegramId, "You are enabled");
  // sendMessage(adminId, "Done");
}

This library is inspired by koa and the main feature of Telegraf is middleware/cascading. Now you can build powerful bots from tiny blocks. Check out Telegraf middlewares for examples.

I recommend you read samples from telegraf-flow, it's experimental middleware for complex chatbots. We use 'scene' abstraction for handling user conversation flow and structure of our bots stays simple.

from telegraf.

Zweer avatar Zweer commented on May 6, 2024

Hey,

thanks, the "messageId" idea is really good, haven't thought about it!!!
In this way it a much more clean!!!

Good idea the Flow lib, I'm gonna have a look!!!

Thanks a lot!

from telegraf.

Related Issues (20)

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.