Closed hanigamini closed 6 years ago
I don't see any requests like self-kicking in Telegram bot api. May be https://core.telegram.org/bots/api#kickchatmember may help, but your bot must be admin in chat.
I want prevent unwanted add my bot in group , I want left form that group. this is method , leaveChat , how can i use it? https://core.telegram.org/bots/api#leavechat
I can't find something in Telegram bot API docs that may help you.
Any bot may be added in any chat. You may start replying on every message in chat with some spam and humans will remove your bot very quickly ;)
leaveChat , how can i use it? https://core.telegram.org/bots/api#leavechat
Wow, my eyes. You are right, that's exactly what you need.
So, just send 'LeaveChat`:
var chatToLeave = message.Chat.Id;
await bot.SendAsync(chatToLeave, new LeaveChat(chatToLeave));
your code not work , whast is the diffrence with this ? bot.MakeRequestAsync(new LeaveChat(chatToLeave)).Wait();
Ouch, sorry.
I'm not with VS now, writing in "notepad". My code is from NetTelegramBot.Framework, it will not compile in "naked" NetTelegramBotApi.
Your code is correct one and should work.
Thank you very much, I add try cacth in c# because somtime have error with LeaveChat. and bot is in hanging. Is there any way for that ?
Hi, How can I Left from group when some one add my bot to group ?