Skip to content

Commit

Permalink
Fixed issue #3
Browse files Browse the repository at this point in the history
  • Loading branch information
sumithemmadi committed Feb 23, 2023
0 parents commit f6a0fbb
Show file tree
Hide file tree
Showing 9 changed files with 410 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .bash_profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export SVDIR=$PREFIX/var/service
export LOGDIR=$PREFIX/var/log

(service-daemon start >/dev/null 2>&1 & )
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

authkey.json

test/authkey.json
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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.
31 changes: 31 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
truecaller-on-termux:
export SVDIR := $(PREFIX)/var/service

install: truecaller-on-termux
pkg i nodejs jq termux-api termux-services -y
@ npm install -g truecallerjs
@ if [ -f "$(HOME)/.truecallerjs/authkey.json" ]; then \
echo "\033[1;34mAlready logged in to your account, please wait ...\033[0m"; \
else \
echo "\033[1;34mPlease Login to your Truecaller account \033[0m"; \
truecallerjs login ; \
fi
@ mkdir -p $(PREFIX)/var/service/truecallerjs/log/
@ ln -sf $(PREFIX)/share/termux-services/svlogger $(PREFIX)/var/service/truecallerjs/log/run
@ install -m 0777 run $(PREFIX)/var/service/truecallerjs/
@ echo "==> \033[1;32mInstallation Successful.\033[0m"
@ echo "==> 1 . You need to restart session or source this file:"
@ echo "==> \033[1;33m source start-truecallerjs.sh\033[0m"
@ echo "==> 2 . start the truecallerjs daemon service:"
@ echo "==> \033[1;33m sv-enable truecallerjs\033[0m"
@ echo "==> \033[1;33m sv up truecallerjs\033[0m"

uninstall:
@ rm -f $(PREFIX)/bin/truecallerjs
@ rm -Rf $(PREFIX)/lib/node_modules/truecallerjs
@ rm -Rf $(PREFIX)/var/service/truecallerjs
@ echo "==> \033[1;31mUninstallation Successfull.\033[0m"
@ echo "==> 1 . Enter the below command to stop service"
@ echo "==> \033[1;33m sv-disable truecallerjs && sv-down truecallerjs\033[0m"

.PHONY: install uninstall
82 changes: 82 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Truecaller-on-termux
[![Version](https://img.shields.io/badge/Version-1.0.4-blue)](https://github.com/sumithemmadi/truecaller-on-termux/releases)
[![stars](https://img.shields.io/github/stars/sumithemmadi/truecaller-on-termux)](https://github.com/sumithemmadi/truecaller-on-termux/stargazers)
[![MIT Licence](http://img.shields.io/github/license/sumithemmadi/truecaller-on-termux)](https://github.com/sumithemmadi/truecaller-on-termux/blob/main/LICENSE)
[![issues](https://img.shields.io/github/issues/sumithemmadi/truecaller-on-termux)](https://github.com/sumithemmadi/truecaller-on-termux/issues)

A simple truecaller on termux

<div class="imgs" style="center">
<img src="https://user-images.githubusercontent.com/50250422/139717425-824b5468-29d4-4514-8b4a-77b119239501.jpg">
</div>

## Before we begin
Before we begin you should do following things.
1. Make sure that you install [termux-api](https://f-droid.org/packages/com.termux.api/)
2. Now you should give notifications permission to termux-api.
```bash
termux-notification-list
```
3. After running above command in termux,click **Allow**.
3. Then run `termux-notificatin-list` and see a json is showing or not.
If it's not shown try enabling Auto Start for Termux:API and disable all battery optimizations.
https://dontkillmyapp.com/xiaomi
4. Make sure that you install `git` and `make`.

## Installation and Login

First clone this repository.

```bash
git clone https://github.com/sumithemmadi/truecaller-on-termux.git
cd truecaller-on-termux
```

```
make install
```
Then [login](https://github.com/sumithemmadi/truecaller-on-termux) to your Truecaller account.

After installation you need to restart session or source this file:

```bash
source start-truecallerjs.sh
```

Now you ready to enable and start the `truecallerjs` daemon service:
```bash
sv-enable truecallerjs
sv up truecallerjs
```
If you need to stop, run `sv down truecallerjs`

> **Note** : If you get any error just close the termux app and reopen it.Then start truecallerjs services.
### To uninstall

```
make uninstall
```

Then stop service with below command

```
sv down truecallerjs
sv-disable truecallerjs
```
## LICENSE

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.

112 changes: 112 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
[
{
"id": 1860351128,
"tag": "",
"key": "0|com.snapchat.android|1860351128|null|10351",
"group": "SNAP-351a72af-fb61-5169-a7af-7b3a6b0f3493",
"packageName": "com.snapchat.android",
"title": "Varun Sai Reddy",
"content": "sent you a Snap",
"when": "2023-02-22 10:23:27"
},
{
"id": -1866504883,
"tag": "",
"key": "0|com.snapchat.android|-1866504883|null|10351",
"group": "SNAP-376f3d5e-be82-59f0-8ab4-54b5c733e37b",
"packageName": "com.snapchat.android",
"title": "Uday kumar",
"content": "sent you a Snap",
"when": "2023-02-22 10:14:48"
},
{
"id": 1841617252,
"tag": "",
"key": "0|com.snapchat.android|1841617252|null|10351",
"group": "SNAP-1aa369d2-3dfe-5f81-a3dd-666c8ffdc0ee",
"packageName": "com.snapchat.android",
"title": "§íđđû Ýãđâv",
"content": "sent you a Snap",
"when": "2023-02-22 10:13:16"
},
{
"id": 2129984393,
"tag": "",
"key": "0|com.snapchat.android|2129984393|null|10351",
"group": "SNAP-e58213f0-d30b-5604-8ca0-4bbc059ef392",
"packageName": "com.snapchat.android",
"title": "Yogi",
"content": "sent you a Snap",
"when": "2023-02-22 08:48:27"
},
{
"id": 1520819950,
"tag": "",
"key": "0|com.snapchat.android|1520819950|null|10351",
"group": "mischief_snap~a00afa4d-89d7-4da9-93a8-2e0a6207f606",
"packageName": "com.snapchat.android",
"title": "Hasvika Reddy,Rohith Nayini,Saritha Dubbaka goud,Kadamanchiramesh Kadamanchiram,Ravi Kola95,Preethi Preethi",
"content": "New Snaps from Karthik and RaHaMaTh",
"when": "2023-02-22 08:46:33"
},
{
"id": 0,
"tag": "gig:-1553825328:^sq_ig_i_personal",
"key": "0|com.google.android.gm|0|gig:-1553825328:^sq_ig_i_personal|10289",
"group": "gig:-1553825328:^sq_ig_i_personal",
"packageName": "com.google.android.gm",
"title": "Arnab-Afk",
"content": "[sumithemmadi/truecaller-on-termux] Getting some problems (Issue #3)\nOk trying itYou are receiving this because you commented.Message ID: <sumithemmadi/truecaller-on-termux/issues/3/[email protected]>",
"when": "2023-02-22 10:24:07"
},
{
"id": -2068477715,
"tag": "gig:-1553825328:^sq_ig_i_personal",
"key": "0|com.google.android.gm|-2068477715|gig:-1553825328:^sq_ig_i_personal|10289",
"group": "gig:-1553825328:^sq_ig_i_personal",
"packageName": "com.google.android.gm",
"title": "Arnab-Afk",
"content": "[sumithemmadi/truecaller-on-termux] Getting some problems (Issue #3)\nOk trying itYou are receiving this because you commented.Message ID: <sumithemmadi/truecaller-on-termux/issues/3/[email protected]>",
"when": "2023-02-22 10:24:07"
},
{
"id": -1132074423,
"tag": "",
"key": "0|com.snapchat.android|-1132074423|null|10351",
"group": "stories~b662e995-9aef-451d-816b-bcb54abf2a59",
"packageName": "com.snapchat.android",
"title": "Snapchat",
"content": "New Story from Kishore Limgave ",
"when": "2023-02-22 00:33:12"
},
{
"id": 1337,
"tag": "",
"key": "0|com.termux|1337|null|10352",
"group": "",
"packageName": "com.termux",
"title": "Termux",
"content": "1 session",
"when": "2023-02-22 10:23:32"
},
{
"id": 0,
"tag": "-1705526044::SUMMARY::wx",
"key": "0|com.google.android.googlequicksearchbox|0|-1705526044::SUMMARY::wx|10269",
"group": "-1705526044::SUMMARY::wx",
"packageName": "com.google.android.googlequicksearchbox",
"title": "",
"content": "",
"when": "2023-02-22 10:19:35"
},
{
"id": 0,
"tag": "-1705526044::a:snotification:[0x394,wx.f,NOTIFICATION]",
"key": "0|com.google.android.googlequicksearchbox|0|-1705526044::a:snotification:[0x394,wx.f,NOTIFICATION]|10269",
"group": "-1705526044::SUMMARY::wx",
"packageName": "com.google.android.googlequicksearchbox",
"title": "27° in Kamrej",
"content": "Haze · See more",
"when": "2023-02-22 10:19:35"
}
]
91 changes: 91 additions & 0 deletions run
Original file line number Diff line number Diff line change
@@ -0,0 +1,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
3 changes: 3 additions & 0 deletions start-truecallerjs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export SVDIR=$PREFIX/var/service
export LOGDIR=$PREFIX/var/log
(service-daemon start >/dev/null 2>&1 & )
Loading

0 comments on commit f6a0fbb

Please sign in to comment.