-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmonkeyuser
37 lines (32 loc) · 1.31 KB
/
monkeyuser
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#apt install curl xml-twig-tools gridsite-clients
while true;
do
TOKEN="$TOKEN"
WORKING_DIR="/files"
POST=0
LASTPOSTLINK=$(cat $WORKING_DIR/monkeyuserlastpost)
for LINK in $(curl -L http://www.monkeyuser.com/index.xml > file2.txt && xml_grep --text_only link file2.txt | head -6 | tac | head -5)
do
if [ "$POST" = "0" ]
then
if [ "$LASTPOSTLINK" = "$LINK" ]
then
POST=1
fi
else
curl -L "$LINK" > "$WORKING_DIR/monkeytemp"
IMGPATH="$(cat $WORKING_DIR/monkeytemp | grep -P -o "img src.+?alt=" | sed -r 's/^.{8}//' | sed -r 's/.{5}$//')"
IMGURL="https://www.monkeyuser.com/""$IMGPATH"
curl "$IMGURL" -o "$WORKING_DIR/file.png"
TITLE="$(cat $WORKING_DIR/monkeytemp | xml_grep --html --text_only title | sed -r 's/.{13}$//')"
ENCODED_TITLE="$(urlencode $TITLE)"
ENCODED_URL="$(urlencode $LINK)"
curl "https://api.telegram.org/bot$TOKEN/sendPhoto?chat_id=@monkeyusers&caption=$ENCODED_TITLE%0A$ENCODED_URL%0A@monkeyusers" -F photo=@"$WORKING_DIR/file.png"
rm "$WORKING_DIR/file.png"
echo "$LINK" > "$WORKING_DIR/monkeyuserlastpost"
fi
done
rm "$WORKING_DIR/monkeytemp"
sleep 3600
done