import { Composer } from "https://deno.land/x/grammy@v1.31.0/mod.ts";
Registers some middleware for certain chat types only. For example, you
can use this method to only receive updates from private chats. The four
chat types are "channel"
, "supergroup"
, "group"
, and "private"
.
This is especially useful when combined with other filtering logic. For
example, this is how can you respond to /start
commands only from
private chats:
bot.chatType("private").command("start", ctx => { ... })
Naturally, you can also use this method on its own.
// Private chats only
bot.chatType("private", ctx => { ... });
// Channels only
bot.chatType("channel", ctx => { ... });
You can pass an array of chat types if you want your middleware to run for any of several provided chat types.
// Groups and supergroups only
bot.chatType(["group", "supergroup"], ctx => { ... });
Remember also that you
can access the chat type via ctx.chat.type
.
Parameters
chatType: MaybeArray<T>
The chat type
...middleware: Array<Middleware<ChatTypeContext<C, T>>>
The middleware to register