Giter VIP home page Giter VIP logo

Comments (4)

fizruk avatar fizruk commented on August 9, 2024

Can you elaborate on the boilerplate you get? I see how it can arise, but I'd like to know more about your specific case.

I am not sure where do you expect ConversationM to arise. Note that you don't always have a ChatId (when Update is not chat-related) or Update (e.g. in bot jobs).

from telegram-bot-simple.

fizruk avatar fizruk commented on August 9, 2024

@anpryl note that I am working on a new release with a lot of new nice features on improvements branch. Perhaps I've implemented a solution to your problem already.

from telegram-bot-simple.

anpryl avatar anpryl commented on August 9, 2024

In my case, I need to store a mapping (in database) between UserID in my system and telegram's ChatID. So in most handlers I need ChatId to lookup user data and it leads to boiler plate like

mchatID <- currecntChatId
case mchatID of
  Just chatID -> do something
  Nothing -> pure NoOp

I understand that update can be without ChatId. But is it possible in conversation mode? We need ChatId to lookup conversation from HashMap. After this we definitely have ChatId inside handlers.

from telegram-bot-simple.

fizruk avatar fizruk commented on August 9, 2024

I think I see your point, but I'll have to think a little more about it.

I think we can actually make Maybe Update (or rather BotContext since v0.2) an argument to BotM:

newtype BotM context a = BotM { _runBotM :: ReaderT context ClientM a }

newtype Eff action model = Eff { _runEff :: Writer [BotM BotContext action] model }

With this we might use something similar to magnify to zoom into chatId or any other part of an update (when possible).

from telegram-bot-simple.

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.