UpdateUsernameRequest
Only users can use this method. See code examples.
---functions--- account.updateUsername#3e0bdd7c username:string = User
Returns
| User |
This type can be an instance of either:
| User | UserEmpty |
Parameters
| username | string |
Known RPC errors
This request can cause 3 known errors:
UsernameInvalidError | Nobody is using this username, or the username is unacceptable. If the latter, it must match r"[a-zA-Z][\w\d]{3,30}[a-zA-Z\d]". |
UsernameNotModifiedError | The username is not different from the current username. |
UsernameOccupiedError | The username is already taken. |
You can import these from telethon.errors.
Example
from telethon.sync import TelegramClient
from telethon import functions, types
with TelegramClient(name, api_id, api_hash) as client:
result = client(functions.account.UpdateUsernameRequest(
username='some string here'
))
print(result.stringify())