S
S
skweartman2021-08-19 22:29:50
Bots
skweartman, 2021-08-19 22:29:50

How to prohibit the bot some commands in groups?

Hello.

There is a bot, he is in a group, if you write a command in this group, then the bot will execute it, but I want some commands not to be available in the chat, but only if you write to the bot.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilhomidin Bakhoraliev, 2021-08-24
@skweartman

The Message object has a chat field that stores the Chat object and it already has a chat type (type): "group", "supergroup", "channel", "private". Using this data, you can write your own command filtering.
If you write using any of the popular libraries, then it should already have a filter for groups.

I
inFureal, 2021-08-19
@inFureal

Look at the type of chat, and if it's not a private chat, then cancel. As far as I know, for groups the chat id is negative, i.e.if (id < 0)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question