vysheng / tg

telegram-cli
GNU General Public License v2.0
6.5k stars 1.54k forks source link

Differ between two channels // Delete messages automatically #1588

Open mooooonbaby opened 5 years ago

mooooonbaby commented 5 years ago

Hi,

telegram-cli daemon is running on my raspberry pi and i send links when i'm not at home to it and the pi starts actions depending on the link or the extra information i send. when there is 'nzb' in the message it downloads the file and sends it to the usenet downloader. because i'm not familiar with lua i send the message to a shell script and here it filter the message. this is the 'actions.lua'

function on_msg_receive (msg)
        if msg.out then
                return
        end
        if (msg.from.print_name=="ich") then
                os.execute("/home/pi/.telegram-cli-script " .. msg.text)
                send_msg (msg.from.print_name, 'works' , ok_cb, false)
        end
end

my goal is to delete the message after sending it to the shell script, but only when there is a keyword in the message. all other messages should not be deleted. i need the message-id to delete a message bit the id isn't sent to the shell. so i can filter for the keyword, but i can't create a command to delete the message because the message-id is missing.

other way: i have created a second channel with only me as member. can i use this second channel for that? i send a url to that channels and the message is sent to an other shell script and the message is deleted after reading?