forked from grakshith/fterm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinbox.sh
executable file
·73 lines (64 loc) · 1.75 KB
/
inbox.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
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
65
66
67
68
69
70
71
72
73
#! /bin/bash
source config.cfg
figlet -f script "Your Inbox"
curl -s -X GET \
"https://graph.facebook.com/v2.3/me?fields=inbox%7Bcomments%2Cfrom%2Csubject%2Cto%7D&access_token=$access_token" > inbox.txt &
pid=$!
./wait.sh $pid
unset pid
usage() {
cat<<EOF
List of commands available
No specific commands to display
Navigation:
back To go back to the previous level
EOF
}
countgroups=$(jq -r ".inbox.data | length" inbox.txt)
status=""
while(true)
do
#displays the names of all your friends
for((i=0;i<countgroups;i++))
do
countmembers=$(jq -r ".inbox.data[$i].to.data | length" inbox.txt)
if [ $countmembers -eq 2 ]
then
jq -r ".inbox.data[$i].to.data[0].name" inbox.txt
fi
done
echo "Enter the name of the person whose conversation you want to read or back to return to the previous menu"
echo -n "facebook/inbox $ "
#enter the name of any person in the list
read name
if [ "$name" = "back" ]; then
exit 0
fi
if [ "$name" = "help" ]; then
usage
fi
for((i=0;i<countgroups;i++))
do
#list contains the list of names
list=$(jq -r ".inbox.data[$i].to.data[0].name" inbox.txt)
#checks whether the name exists in the list and displays that persons conversation
#with you
if [ "$name" == "$list" ]
then
countcomments=$(jq -r ".inbox.data[$i].comments.data | length" inbox.txt)
for((j=0;j<countcomments;j++))
do
comment=$(jq -r ".inbox.data[$i].comments.data[$j].message" inbox.txt)
if [ "$comment" != "null" ]
then
user=$(jq -r ".inbox.data[$i].comments.data[$j].from.name" inbox.txt)
echo "$user: $comment"
fi
done
echo ""
echo ""
fi
done
#press e to exit and any other key to continue
read prompt
done