public static TelegramBot login ( String authToken ) { try { HttpRequestWithBody request = Unirest . post ( API_URL + "bot" + authToken + "/getMe" ) ; HttpResponse < String > response = request . asString ( ) ; JSONObject jsonResponse = Utils . processResponse ( response ) ; if ( jsonResponse != null && Utils . checkResponseStatus ( jsonResponse ) ) { JSONObject result = jsonResponse . getJSONObject ( "result" ) ; return new TelegramBot ( authToken , result . getInt ( "id" ) , result . getString ( "first_name" ) , result . getString ( "username" ) ) ; } } catch ( UnirestException e ) { e . printStackTrace ( ) ; } return null ; }
Use this method to get a new TelegramBot instance with the selected auth token