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

feat: expose conversation handle to plugins #134

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

KnorpelSenf
Copy link
Member

The plugins option allows plugins to be installed inside a conversation, and external allows the conversation to read the session data. It was pointed out in https://t.me/grammyjs/291998 that it is currently impossible to access the session data from inside a plugin.

This PQ introduces a plugins option that has access to the conversation handle. That way, the following code becomes possible.

bot.use(createConversation(convo, {
  plugins: conversation => [async (ctx, next) => {
    // can now install session data on the context:
    ctx.sess = await conversation.external(ctx => ctx.session)
  }]
}))

@KnorpelSenf KnorpelSenf requested a review from KnightNiwrem March 2, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant