-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtts-sms.sh
130 lines (115 loc) · 3.5 KB
/
tts-sms.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
# Developer: SirCryptic (NullSecurityTeam)
# Info: tts-sms script v1.0 {BETA}
# Disclaimer: DO NOT USE THIS TO TROLL OR SPAM PEOPLE I WILL NOT BE RESPONSIBLE FOR YOUR USAGE!
# Details: Get a API key from here: https://www.clicksend.com
# Set the ClickSend API credentials
api_username="your_username"
api_key="your_api_key"
# Set the API endpoint and headers
url="https://rest.clicksend.com/v3/voice/send"
headers=(
"Authorization: Basic $(echo -n "$api_username:$api_key" | base64)"
"Content-Type: application/json"
)
# Set the name of the phone book file
phone_book_file="phonebook.txt"
# Define an associative array to store phone numbers and their associated names
declare -A phone_book
# Load phone numbers from the phone book file
if [[ -f "$phone_book_file" ]]; then
while IFS= read -r line; do
number=$(echo "$line" | cut -d' ' -f1)
name=$(echo "$line" | cut -d' ' -f2-)
phone_book[$number]=$name
done < "$phone_book_file"
fi
# Function to add a phone number to the phone book
function add_number {
echo "Enter the phone number:"
read number
echo "Enter a name for the recipient:"
read name
phone_book[$number]=$name
echo "Added $name ($number) to the phone book."
echo "$number $name" >> "$phone_book_file"
}
# Prompt the user to select a country
echo "Select a country code:"
select country_code in "US" "AU" "GB"
do
if [[ -n $country_code ]]; then
break
fi
done
# Prompt the user to enter a message
echo "Enter a message:"
read message
# Prompt the user to select a recipient or add a new one
echo "Select an option:"
select option in "Select a recipient" "Add a new recipient"
do
case $option in
"Select a recipient")
# Prompt the user to select a recipient from the phone book
echo "Select a recipient:"
select number in "${!phone_book[@]}"
do
if [[ -n $number ]]; then
recipient_number=$number
recipient_name=${phone_book[$number]}
break
fi
done
break
;;
"Add a new recipient")
# Call the add_number function to add a new number to the phone book
add_number
# Prompt the user to select the newly added recipient
echo "Select the newly added recipient:"
select number in "${!phone_book[@]}"
do
if [[ -n $number ]]; then
recipient_number=$(echo $number | cut -d ',' -f1)
recipient_name=${phone_book[$number]}
break
fi
done
break
;;
esac
done
# Prompt the user to select whether to schedule the message or send it immediately
echo "Do you want to schedule the message? (y/n)"
read schedule
if [[ $schedule == "y" ]]; then
# Prompt the user to enter the schedule date and time
echo "Enter the schedule date and time in the format \"YYYY-MM-DD HH:MM:SS\" (e.g. 2023-02-24 10:00:00):"
read schedule_time
schedule_time=$(date -d "$schedule_time" '+%s')
recipient="{
\"messages\": [
{
\"source\": \"bash\",
\"body\": \"$message\",
\"to\": \"${recipient_number}\"
}
]
}"
else
recipient="{
\"messages\": [
{
\"source\": \"bash\",
\"body\": \"$message\",
\"to\": \"${recipient_number}\"
}
]
}"
fi
# Send the API request
response=$(curl --silent --show-error --request POST --url $url --header "${headers[0]}" --header "${headers[1]}" --data-binary "$recipient")
# Print the selected recipient's name and the API response
echo "Message sent to $recipient_name"
echo "$response" | jq