-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.sh
31 lines (31 loc) · 965 Bytes
/
bot.sh
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
delay=200
clear
echo Simple Autopost bot
min=$(($delay / 60))
files=(./lib/*)
a=${#files[@]}
RED='\033[0;31m'
RES=`\033[0m`
until [ "$a" -eq 1 ]
do
files=(./lib/*) #creates an array of all the files within src/ */
filecount="${#files[@]}" #determines the length of the array
echo "Files in folder:"${#files[@]}
randomid=$((RANDOM % filecount)) #uses $RANDOM to choose a random number between 0 and $filecount
filetomove="${files[$randomid]}" #the random file wich we'll move
mv "$filetomove" now/ #does
echo "Copied "$filetomove" To ./now"
telegram-send --config channel.conf --image ./now/* --caption "${filetomove:6}"
echo $filetomove" Posted"
rm -r ./now/*.png
echo $filetomove" Deleted"
echo "Sleeping for" $min "min."
sleep $delay
a=${#files[@]}
if [ "${#files[@]}" -eq 1 ]
then
echo -e "${RED}No files left, sending notification${RES}"
telegram-send --config user.conf "No files left"
fi
done
echo -e "No files or only 1 file in lib, ${RED}exiting${RES}"