Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow modules to record the id-s of messages they send #67

Open
nmlorg opened this issue Jul 22, 2019 · 0 comments
Open

Allow modules to record the id-s of messages they send #67

nmlorg opened this issue Jul 22, 2019 · 0 comments
Labels
cleanup Code changes that improve maintainability without changing behavior

Comments

@nmlorg
Copy link
Owner

nmlorg commented Jul 22, 2019

In order to implement #64, the bot needs to be able to record the ids of messages it sends, tagged with some kind of metadata related to its content/purpose.

Right now, most messages the bot sends are done so implicitly (by having module dispatchers fill data into a MessageBuilder and allowing the MultiBot dispatcher send it out through ntelebot). This means that, for example, the events module can't just capture the return value from MessageBuilder.reply and store the id somewhere internally.

One possibility would be to have MultiBot record all messages it sends, and make them available via ctx. events could then look backward through the record to find something in the given chat that looked like something it sent and perform #64's update logic on it. This could go a step further and have MultiBot actually keep track of which module ended up capturing the update and tag it by name in the record (and/or keep messages separated by module), so events would just have to look for its most-recent message in the given chat.

A slight variation would be to have modules explicitly mark messages (via MessageBuilder) that they want a record of, maybe setting msg.record = __name__ or msg.tags.add(__name__). Only so-tagged messages would then be recorded by MultiBot (or directly by MessageBuilder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleanup Code changes that improve maintainability without changing behavior
Projects
None yet
Development

No branches or pull requests

1 participant