When the current phone number is not registered with the telegram network, ask for first and last name and proceed with the regular sms-code authentication scheme.
Use purple debugging functions by formatting the string beforehand and then passing the readily formatted string, instead of doing it with va_list. Log into the telegram network using the provided SMS code and hash or request a new one, in case one of those isn't provided. Store and load the state using the file config/auth, to be able to restore previous logins.
Remove the misuse of va_list and emulate behavior of purple debugging functions in our own code, since a va_list cannot be passed to purple_debug_info,