-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient_bot.sh
More file actions
executable file
·64 lines (51 loc) · 1.12 KB
/
Copy pathclient_bot.sh
File metadata and controls
executable file
·64 lines (51 loc) · 1.12 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
NUM_MESSAGES=10
NUM_CONTACTS=10
TOTAL_CONTACTS=100
#DOMAIN_NAME="localhost"
DOMAIN_NAME="137.110.90.7"
sleep 2s
echo "$1@$DOMAIN_NAME"
sleep 1s
echo "$2"
sleep 1s
if [ -n "$3" ]; then
TOTAL_CONTACTS=$3
fi
if [ $TOTAL_CONTACTS -lt $NUM_CONTACTS ]; then
NUM_CONTACTS=$TOTAL_CONTACTS
fi
# remove all existing contacts
echo "remove-all"
sleep 10s
# add new contacts
declare -a CONTACTS
COUNTER=0
while [ $COUNTER -lt $NUM_CONTACTS ]; do
CONTACT=$(( ( RANDOM % $TOTAL_CONTACTS ) + 1 ))
if [ "$CONTACT" -ne "$1" ]; then
CONTACTS[$COUNTER]=$CONTACT
echo "add"
sleep 1s
echo "$CONTACT@$DOMAIN_NAME"
sleep 1s
let COUNTER=COUNTER+1
fi
done
# sending messages
COUNTER=0
let TOTAL_MESSAGES=$NUM_CONTACTS*$NUM_MESSAGES
while [ $COUNTER -lt $TOTAL_MESSAGES ]; do
CONTACT=${CONTACTS[$(( ( RANDOM % $NUM_CONTACTS ) ))]}
echo "message"
sleep 1s
echo "$CONTACT@$DOMAIN_NAME"
sleep 1s
echo "hey $CONTACT! this is message #${COUNTER}"
sleep 5s
let COUNTER=COUNTER+1
done
# log
echo "total message sent: $TOTAL_MESSAGES"
# exit
echo "exit"