Chat API to add and remove members automatically [closed]

你离开我真会死。 提交于 2019-12-06 05:12:06

First of all, for inviting new members to the group, your friend can make an invite link for his group and use it because bots cannot automatically add people to groups.

But for removing people there is a method in telegram bot api which is called Kick Chat Member:

await Bot.KickChatMemberAsync(chatId, userId, untilDate);

Of course this method is used in Telegram.Bot API which is made for C#, but you can find its alternative for PHP.

Not that UntilDate is optional and if you do not set it, it means the user will be kicked for ever.

chatId refers to your group's Chat ID and userId refers to the user whom you want to delete.

As with the bot API, it is NOT possible to add members directly to the group, you can still kick them out.

However what you are asking is still possible by using a user bot (MTPROTO client). If you are going to use PHP, I suggest you look at MadelineProto. I will list the methods you can use:

  1. channels.inviteToChannel (Works with supergroups)
  2. channels.editBanned (Works with supergroups)

Using the two methods you can easily achive your aim.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!