Question
There is a task: to post comments by a bot to a specific post in a Telegram channel. There are difficulties with this because, to access the post, you need to know the id of the message not sent, but the id of the message that Telegram itself forwards to the linked group (whose members can comment on posts).
As a result, after sending the message, you need to wait for some time (preferably a little, as the message may get lost later), then load the latest posts (the fewer, the better), find the required one by the id of the sent message for further sending of comments to it.
If done "head-on," Telegram does not always manage to provide the update, and nothing comes through. I did it through sleep, but it slows down the addition of the line and the sending of the main message (which will be commented on).
The task looks like this: how to run the action "in the background" after 5 seconds.
Answer
For this task, you can use the following approach:
Separate this action into a separate process.
In this separate process, include a sleep for n-seconds.
In the place where the trigger that initiates this action is activated, call the nested code via exec with the parameter ssh: true
.
=: while(action: $action_1; action: $check; action: $action_3)
check: exec(code: $code; ssh: true)
```code:totum
=: while(action: $sleep; action: $action)
sleep: sleep(sec: 10)
action: "some action"
```
action_1: "some action"
action_3: "some action"
ssh: true
ā separates this call into a separate process, and now the main action will continue, while the separated process will wait 10 seconds and then execute.