I needed to write a small script that would read the first element of an xml and send the photo, nickname and link via a telegram message to a channel at certain times.
Here’s how I did it on my Ubuntu server:
#!/bin/bash
#Download XML
curl -o list.xml "https://www.yourlist.xml";
#read nickname
nickname=$(grep -m 1 '<nickname' list.xml | head -1 | cut -f2 -d">"|cut -f1 -d"<");
#read thumbnail link
thumb=$(grep -m 1 '<thumb' list.xml | head -1 | cut -f2 -d">"|cut -f1 -d"<");
#read link
link=$(grep -m 1 '<link' list.xml | head -1 | cut -f2 -d">"|cut -f1 -d"<");
curl --get \
--data-urlencode "chat_id=-ChatID" \
--data-urlencode "photo=""$thumb" \
--data-urlencode "parse_mode=HTML" \
--data-urlencode "show_caption_above_media=true" \
--data-urlencode "caption=YourCaption" \
--data-urlencode "reply_markup={\"inline_keyboard\": [[{\"text\": \"Your Text\", \"url\": \"""$link""\"}]]}" \
https://YourApiKey/sendPhoto;
Lascia un commento