telegram-bot icon indicating copy to clipboard operation
telegram-bot copied to clipboard

Unable to delivered sorted messages

Open jmontane opened this issue 9 years ago • 4 comments

Hi,

I'm working in a own plugin. This plugin sends severals messages: 3 text messages and 1 document in following sorting.

send_large_msg(receiver, Message1) send_large_msg(receiver, Message2) send_document(receiver, FilePath1, ok_cb, false) send_large_msg(receiver, Message3)

But user receives messages in following sorting

send_large_msg(receiver, Message1) send_large_msg(receiver, Message2) send_large_msg(receiver, Message3) send_document(receiver, FilePaht1, ok_cb, false)

Sometimes text messages are received unsorted, for instance,

send_large_msg(receiver, Message2) send_large_msg(receiver, Message1) send_large_msg(receiver, Message3) send_document(receiver, FilePaht1, ok_cb, false)

Is there any way to force messages to be delivered in desired sorting? Thanks in advance.

jmontane avatar Jun 08 '15 07:06 jmontane

Use callbacks. Something like:

send_document(receiver, FilePath1, function (params) local receiver = params[1] local text = params[2] send_msg(receiver, text, ok_cb, false) end, {receiver, text})

yagop avatar Jun 08 '15 07:06 yagop

In #246 I've added a function to utils.lua to send messages in order in an easy way, when @yagop accept it (if he does, maybe my way is wrong xD) you will can send easily messages in order (including send files/images/...)

rockneurotiko avatar Jun 08 '15 20:06 rockneurotiko

Thanks for quick replies,

I'm not a programmer guy, I was unable to achieve sort messages using callback functions. I think send_order_msg function can be a good improvement.

jmontane avatar Jun 09 '15 06:06 jmontane

Your welcome! send_order_msg has been merged in a07b795, update your repo (./launch.sh update) and you will can use it :smile: To know how to use, see this: https://github.com/yagop/telegram-bot/pull/246#issue-86152981

rockneurotiko avatar Jun 09 '15 06:06 rockneurotiko