I am using telegrafjs. I want to restrict the command

usage in a group or restrict few users.Is there a proper way to do it?

5 ответов

22 просмотра

Personally I implemented this using a JSON file called acl.json. In it, I express the user ID's of users that are allowed to execute privileged commands, as well as those who the bot should ignore. Regardless of whether you want to use JSON, the user ID's are how you should filter for this. Then compare the user ID on the incoming message to the user ID's in the ACL file on every incoming message. You may want to keep a copy of the ACL file in memory, using a data structure native to your programming language / library.

YUKON- Автор вопроса

Can you share a snippet?

YUKON
Can you share a snippet?

I've open sourced my bot, and published the source code here. It's written in bash, so some of the constructs may seem a bit arcane. But the project is currently in a state I'd consider complete. The ACL uses a syntax like this: { "admins": [ "uid1", "uid2" ], "banned": [ "uid1", "uid2" ] }

YUKON- Автор вопроса

Похожие вопросы

Карта сайта