import { Composer } from "https://deno.land/x/grammy@v1.32.0/composer.ts";
Registers some middleware that will only be executed for some specific updates, namely those matching the provided filter query. Filter queries are a concise way to specify which updates you are interested in.
Here are some examples of valid filter queries:
// All kinds of message updates
bot.on('message', ctx => { ... })
// Only text messages
bot.on('message:text', ctx => { ... })
// Only text messages with URL
bot.on('message:entities:url', ctx => { ... })
// Text messages and text channel posts
bot.on(':text', ctx => { ... })
// Messages with URL in text or caption (i.e. entities or caption entities)
bot.on('message::url', ctx => { ... })
// Messages or channel posts with URL in text or caption
bot.on('::url', ctx => { ... })
You can use autocomplete in VS Code to see all available filter queries. Check out the documentation on the website to learn more about filter queries in grammY.
It is possible to pass multiple filter queries in an array, i.e.
// Matches all text messages and edited text messages that contain a URL
bot.on(['message:entities:url', 'edited_message:entities:url'], ctx => { ... })
Your middleware will be executed if any of the provided filter queries matches (logical OR).
If you instead want to match all of the provided filter queries
(logical AND), you can chain the .on
calls:
// Matches all messages and channel posts that both a) contain a URL and b) are forwards
bot.on('::url').on(':forward_origin', ctx => { ... })
Type Parameters
Parameters
The middleware to register behind the given filter