from telethon.sync import TelegramClient
api_id = 'YOUR_API_ID'
api_hash = 'YOUR_API_HASH'
phone_number = 'YOUR_PHONE_NUMBER'
with TelegramClient('session_name', api_id, api_hash) as client:
client.connect()
if not client.is_user_authorized():
client.send_code_request(phone_number)
client.sign_in(phone_number, input('Enter the code: '))
dialogs = client.get_dialogs()
for dialog in dialogs:
client.delete_dialog(dialog.id)