Created
December 21, 2022 15:02
-
-
Save jmlich/d66cd4c6bf46ba1bc279a3201cc76a5a to your computer and use it in GitHub Desktop.
Add testing messages into commhistory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -a messages=( | |
"Hello, would you like to hear a TCP joke?" | |
"Yes, I'd like to hear a TCP joke." | |
"OK, I'll tell you a TCP joke." \ | |
"OK, I'll hear a TCP joke." \ | |
"Are you ready to hear a TCP joke?" \ | |
"Yes, I am ready to hear a TCP joke." \ | |
"OK, I'm about to send the TCP joke. It will last 10 seconds, it has two characters, it does not have a setting, it ends with a punchline." \ | |
"OK, I'm ready to hear the TCP joke that will last 10 seconds, has two characters, does not have a setting and will end with a punchline." \ | |
) | |
declare -a messagesb=( | |
"Hey Bob, how was your weekend?" | |
"It was great, I went hiking with some friends. How about you?" | |
"I went to a concert on Saturday night. It was so much fun!" | |
"Awesome, which band did you see?" | |
"I saw The Strokes. They were amazing live." | |
"I've always wanted to see them in concert. You're lucky to have gone." | |
"Yeah, it was definitely a highlight of the summer for me. Have you done anything fun lately?" | |
"I went white water rafting last weekend. It was so exhilarating." | |
"Wow, that sounds like a blast. I've never done anything like that before." | |
"You should definitely try it sometime. It's a lot of fun." | |
) | |
offset=$(( - ${#messages[@]} * 120 )) | |
phone_number=333333 # Aaron Gates from examples.vcf | |
phone_numberb=07-3242325 | |
i=0 | |
for content in "${messages[@]}"; do | |
msg_offset=$(( offsets - i * 120 )) | |
# yyyyMMdd:hh:mm | |
ts=$(date "+%Y%m%d:%H:%M" -d "$msg_offset seconds ago") | |
i=$((i + 1)) | |
if [ "$(( i % 2))" -eq 0 ]; then | |
direction="-in" | |
else | |
direction="-out" | |
fi | |
group=$(sqlite3 /home/jmlich/.local/share/commhistory/commhistory.db "SELECT id FROM groups WHERE remoteUids='$phone_number' LIMIT 1") | |
if [ -z "$group" ]; then | |
commhistory-tool add -newgroup -startTime $ts -sms $direction -text "$content" ring/tel/ring $phone_number | |
else | |
commhistory-tool add -group $group -startTime $ts -sms $direction -text "$content" ring/tel/ring $phone_number | |
fi | |
done | |
i=0 | |
for content in "${messagesb[@]}"; do | |
msg_offset=$(( offsets - i * 120 )) | |
# yyyyMMdd:hh:mm | |
ts=$(date "+%Y%m%d:%H:%M" -d "$msg_offset seconds ago") | |
i=$((i + 1)) | |
if [ "$(( i % 2))" -eq 0 ]; then | |
direction="-in" | |
else | |
direction="-out" | |
fi | |
group=$(sqlite3 /home/jmlich/.local/share/commhistory/commhistory.db "SELECT id FROM groups WHERE remoteUids='$phone_numberb' LIMIT 1") | |
if [ -z "$group" ]; then | |
commhistory-tool add -newgroup -startTime $ts -sms $direction -text "$content" ring/tel/ring $phone_numberb | |
else | |
commhistory-tool add -group $group -startTime $ts -sms $direction -text "$content" ring/tel/ring $phone_numberb | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment