-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrun
91 lines (70 loc) · 3.59 KB
/
run
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/data/data/com.termux/files/usr/bin/bash
## MIT License
## Copyright (c) 2021 Emmadi Sumith Kumar
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included in all
## copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
echo -e "\033[1;32mStarting Truexaller On Termux\033[0m\n\033[1;34mDEFAULT_DIALER_APP=com.google.android.dialer\033[0m"
checkNotification() {
json_Data=$(termux-notification-list)
json_Length=$(echo $json_Data | jq length)
status_code=1
for ((j = 0; j <= json_Length - 1; j++)); do
package_Name=$(echo $json_Data | jq -r .[$j].packageName)
if [[ $package_Name == $1 ]]; then
status_code=0
j=$json_Length
fi
done
# echo $status_code
}
echo -e "\033[1;32mTruecallerjs started at\033[0m \033[4;33m$(date)\033[0m"
while true; do
jsonData=$(termux-notification-list)
jsonLength=$(echo $jsonData | jq length)
for ((i = 0; i <= jsonLength - 1; i++)); do
packageName=$(echo $jsonData | jq -r .[$i].packageName)
if [[ $packageName == "com.google.android.dialer" ]]; then
title=$(echo $jsonData | jq -r .[$i].title)
content=$(echo $jsonData | jq -r .[$i].content)
notificationId=$RANDOM
json_data=$(truecallerjs -s "$title" --json)
# echo $json_data
# echo $title
if [[ $(echo $json_data | jq -r .data) == "null" ]]; then
phoneNumber=$title
data="$content"
else
name=$(echo $json_data | jq -r '.data[0].name' )
if [[ $name == "null" ]]; then
phoneNumber=$title
data="$content"
else
phoneNumber=$title
title=$name
data=$content
fi
fi
termux-notification --id "$notificationId" -t "$title" -c "$data" --button1 call --button1-action "termux-telephony-call \"$phoneNumber\"" --button2 remove --button2-action "termux-notification-remove $notificationId"
termux-toast -b white -c black -g bottom "$phoneNumber - $title"
echo '$title-$phoneNumber'
checkNotification "com.google.android.dialer"
until [[ $status_code == 1 ]]; do
checkNotification "com.google.android.dialer"
done
i=$jsonLength
fi
done
done