UpdateUsernameRequest

Only users can use this request. See code examples.

---functions---
account.updateUsername#3e0bdd7c username:string = User

Returns

User

This type can be an instance of either:

UserUserEmpty

Parameters

usernamestring

Known RPC errors

This request can cause 3 known errors:

UsernameInvalidErrorNobody 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]".
UsernameNotModifiedErrorThe username is not different from the current username.
UsernameOccupiedErrorThe 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())