public boolean kickChatMember ( String chatId , int userId ) { HttpResponse < String > response ; JSONObject jsonResponse ; try { MultipartBody request = Unirest . post ( getBotAPIUrl ( ) + "kickChatMember" ) . field ( "chat_id" , chatId , "application/json; charset=utf8;" ) . field ( "user_id" , userId ) ; response = request . asString ( ) ; jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null ) { if ( jsonResponse . getBoolean ( "result" ) ) return true ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } return false ; }
Use this method to kick a user from a group or a supergroup . In the case of supergroups the user will not be able to return to the group on their own using invite links etc . unless unbanned first . The bot must be an administrator in the group for this to work