i am trying to get updates and print it:
client = TelegramClient('session_name', api_id, api_hash, update_workers=1, spawn_read_thread=False)
client.connect()
from telethon.tl.types import UpdateShortMessage, PeerUser
def replier(update):
print(update.message[::-1])
if isinstance(update, UpdateShortMessage) and not update.out:
#client.send_message(PeerUser(update.user_id), update.message[::-1])
print(update.message[::-1])
client.add_update_handler(replier)
i send myself message from another account but nothing prints except -Press enter to stop this!
spawn_read_thread=False
If that's false you need to call another method I can't see there.
@Lonami
i tryed this :
client.connect()
client = TelegramClient('session_name', api_id, api_hash, update_workers=1,spawn_read_thread=False)
from telethon.tl.types import UpdateShortMessage, PeerUser
def callback(update):
print('I received', update)
client = TelegramClient('session', api_id, api_hash,
update_workers=1, spawn_read_thread=False)
client.add_update_handler(callback)
nothing happens either
import telethon
TelegramClient = TelegramAPI('example',
api_id=12345,
api_hash='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
update_workers=4,
spawn_read_thread=False)
def callback(update):
print('I received', update)
TelegramClient.add_update_handler(callback)
TelegramClient._client.idle()
nothing happens either
The script probably terminates. @SyrianProgrammer's comment should work (thanks!), and you should have read the wiki @justxor.
Most helpful comment