Closed hollysheep closed 5 years ago
I think you can in lua the last message delete with:
delete_msg(msg.id, ok_cb, false)
I want to do this with my shell script. I have this line in my actions.lua
os.execute("/home/pi/.telegram-cli-script " .. msg.text)
This sends the message Text to the shell script. In the shell script i use some if-else-commands to decide what to do. In some chases i want to delete the message and for that i need the id. I can send the message id to the script when i replace msg.text with msg. id in actions.lua. but how can i send both, the Text ans the id?
The most if-commands will ignore the id, but some of then will use it together with the Text.
What you need to decide if you want delete the message. Because in shell script I think it is bad to delete. But if you can get the the big number (msg.id) in the shell then you can delete the message with
-e 'delete_msg <big number>'
in the shell.
With .. you can add a variable.
I tried this
os.execute("/home/pi/.telegram-cli-script " .. msg.text .. msg.id)
but then i only get the id and not the message text.
OK, write in the line before "os.execute(.." print("*"..msg.text.."*")
to see in telegram-cli the text.
I have change my answer.
I think there is anything in the shell wrong.
I have test it. And it work.
os.execute("/home/pi/tg/telegram-cli-script " .. msg.text .. " " .. msg.id)
telegram-cli-script:
#!/bin/bash
echo $1 $2
you see it in telegram-cli.
os.execute: with and without .. " "
(The person who opened this issue have delete two comments from him) No, that is a hex-number. A | ist a "pipe". Look in Google or startpage.com what that in the shell mean.
If you over with this issues close it.
I use telegram-cli to send commands from my Android to my raspberry pi. Because im not familiar with lua i send the message to a shell script and use a lot of if-else to choose what to do with the message. Sometimes it would be a good idea to delete the message directly after reading the message and Sendung it to my shell script. I know i have to Start telegram-cli with Option -N and can delete the message with delete_msg.
But i cant include this command in my shell script because the msg-id isn't sent to the shell script. Only the message Text is sent. How can i do this?