Closed lBrane closed 3 years ago
Hi,
You have to subscribe to updateMessageSendSucceeded
notifications, tdlib sends an acknowledgement for sendMessage
once (with messageSendingStatePending
type) and after that python-telegram
does not know anything about the status.
This example should work, but you have to track message ids to determine which messages were successfully sent.
def message_send_succeeded(update):
"""Hanler for all updates from tdlib with status `updateMessageSendSucceeded`"""
print(update)
tg.add_update_handler('updateMessageSendSucceeded', message_send_succeeded)
result = tg.send_message(chat_id=args.chat_id, text=args.text,)
I'm closing this issue, please reopen if you have problems.
Script example:
from telegram.client import Telegram tg = Telegram( api_id=ID, api_hash='HASH', phone='PHONE', database_encryption_key='KEY', )
tg.login() result = tg.get_chats() result.wait()
CHAT_ID =
result = tg.send_message( chat_id=CHAT_ID, text='Test Message' )
result.wait()
print(result.update)
Actual result: In the update, I received the message data, but the status of the message is "messageSendingStatePending" Expected result: Message should be sent to chat
Additional info: If after wait(), add a little sleep (2-3 seconds), then the message is sent to the chat, otherwise it is just stored in the local database.