diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..2206c9a --- /dev/null +++ b/.bash_profile @@ -0,0 +1,4 @@ +export SVDIR=$PREFIX/var/service +export LOGDIR=$PREFIX/var/log + +(service-daemon start >/dev/null 2>&1 & ) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..991c4c1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ + +authkey.json + +test/authkey.json diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9fe4a54 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8662dae --- /dev/null +++ b/Makefile @@ -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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..01d0ac1 --- /dev/null +++ b/README.md @@ -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 + +
+ +
+ +## 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. + diff --git a/app.json b/app.json new file mode 100644 index 0000000..040d304 --- /dev/null +++ b/app.json @@ -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: ", + "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: ", + "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" + } +] \ No newline at end of file diff --git a/run b/run new file mode 100644 index 0000000..56ba1e1 --- /dev/null +++ b/run @@ -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 \ No newline at end of file diff --git a/start-truecallerjs.sh b/start-truecallerjs.sh new file mode 100755 index 0000000..895aecb --- /dev/null +++ b/start-truecallerjs.sh @@ -0,0 +1,3 @@ +export SVDIR=$PREFIX/var/service +export LOGDIR=$PREFIX/var/log +(service-daemon start >/dev/null 2>&1 & ) diff --git a/test/test.json b/test/test.json new file mode 100644 index 0000000..d8d2595 --- /dev/null +++ b/test/test.json @@ -0,0 +1,62 @@ +[ + { + "id": 1, + "tag": "incall", + "key": "0|com.android.incallui|1|incall|10097", + "group": "", + "packageName": "com.google.android.dialer", + "title": "+919912345678", + "content": "+919912345678 India", + "when": "2021-10-26 07:12:36" + }, + { + "id": 8, + "tag": "", + "key": "-1|android|8|null|1000", + "group": "", + "packageName": "android", + "title": "Choose input method", + "content": "Multilingual typing - Gboard", + "when": "1970-01-01 05:30:00" + }, + { + "id": 20006, + "tag": "", + "key": "0|com.miui.securitycenter|20006|null|1000", + "group": "", + "packageName": "com.miui.securitycenter", + "title": "Security is running", + "content": "Tap for more information or to stop the app.", + "when": "2021-10-25 18:39:06" + }, + { + "id": 1, + "tag": "", + "key": "0|com.miui.notification|1|null|1000", + "group": "", + "packageName": "com.miui.notification", + "title": "", + "content": "", + "when": "2021-10-26 01:48:10" + }, + { + "id": 10, + "tag": "", + "key": "0|com.miui.mishare.connectivity|10|null|10098", + "group": "", + "packageName": "com.miui.mishare.connectivity", + "title": "Mi Share is running", + "content": "Tap for more information or to stop the app.", + "when": "2021-10-25 18:39:51" + }, + { + "id": 1337, + "tag": "", + "key": "0|com.termux|1337|null|10230", + "group": "", + "packageName": "com.termux", + "title": "Termux", + "content": "2 sessions", + "when": "2021-10-26 06:46:25" + } +] \ No newline at end of file