Telegraf: How can we restrict an user?

Created on 18 Jun 2019  路  3Comments  路  Source: telegraf/telegraf

Hey guys, sorry if it is not the right channel to questions, but I am working on a bot to show a captcha and I wanna restrict the new user of post messages before handle the captcha. Can you help me to know how to it?

discussion question

All 3 comments

What I have in my mind is to have the if statement at the very start of a function which compares user's id with the allowed list (or vice versa, disallowed)

bot.command('help', (ctx) => {
  if (ctx.message.from.id === <something_to_compare>) {
    // do stuff
  }
  else {
    // don't do stuff
  }
})

Actually I wanna call restrictChatMember (https://core.telegram.org/bots/api#restrictchatmember).

I found it in the base code here.
I dont know why this method is not working (I will understand soon), so I called the API directly.

ctx.telegram.callApi('restrictChatMember', payload)

After I understand the reason why to call the method directly is not working I will comment here, make a pr (if necessary) and close the issue.

Any updates on this?

Was this page helpful?
0 / 5 - 0 ratings