Closed Pie133 closed 7 years ago
It's not possible to get all ChatMembers of channel.
You can get only the Administrators (see offical Bot API docs getChatAdministrators)
But what you could do is to check if a specific user is in your channel by using getChatMember
(see offical Bot API docs here)
Also I recommend you to look through the offical Bot API docs. Anything what is offical described there is also implemented/possible with this library.
Sorry but how can use getChatMember in your API ?
All methods of the offical Bot API are basically also just methods in @rubenlagus's lib.
And you should also know an example for that. sendMessage
sendMessage is a method in the API, here also
sendMessage
-> sendMessage(message);
The same with sendAudio
sendAudio
-> sendAudio(audio);
And the list goes on, and on, and on...^^
So for getChatMember
GetChatMember getChatMember = new GetChatMember():
//id of the chat (in your case the channel id)
getChatMember.setChatId(chatId);
//id of the user
getChatMember.setUserId(userId);
//run the actual method getChatMember
ChatMember member = getChatMember(getChatMember);
what happens if a user isn't a member of a channel, does it return an exception? I tried this method and it seems it's not working :-(
Don't have tested it yet, but it should return null if the user isn't a member of the targeted chat.
Returns a ChatMember object on success.
getChatMember
Please, can you make an example with getChatMembersCount ... Dont inderstand how it works
@Fotomultman try to do the same scheme like in this example https://github.com/rubenlagus/TelegramBots/issues/236#issuecomment-302244907
GetChatMemberCount getChatMemberCount = new GetChatMemberCount();
getChatMemberCount.setChatId(ChatID);
String members_count = getChatMemberCount (getChatMemberCount).toString(); // gets members count
Thank you. Nice.
then I tried to get List of ChatMember to getChatAdministrators
GetChatAdministrators getChatAdministrators = new GetChatAdministrators();
getChatAdministrators.setChatId(ChatID);
List<ChatMember> lst = getChatAdministrators (getChatAdministrators);
int admin_count = lst.size(); //gets admins count if they are exists
Nice!
Hi i want to force users to join a channel before they can use my bot is there any way that i can get channel members chat_id in a array?