From 5082290d155fe4d61b2cc80775157eb5ab8c0898 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 6 May 2024 01:53:48 +0000 Subject: [PATCH] add tma --- scripts/tma | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 scripts/tma diff --git a/scripts/tma b/scripts/tma new file mode 100755 index 0000000..bdcd236 --- /dev/null +++ b/scripts/tma @@ -0,0 +1,67 @@ +#!/bin/bash + +set -e + +signups="/town/var/signups/signups.db" +invites="/town/var/invites/invites.db" +users="/town/var/town.db" +bold=$(tput bold) +plain=$(tput sgr0) + +which="${1}" + +header() { + echo $bold + echo $1 + echo $plain +} + +case $which in + user) + username="${2}" + if [ "$username" == "" ]; then + echo "gimme a username" + exit + fi + + header "i looked in $users and found:" + + sqlite3 $users "select * from users where username='$username'" + + header "their emails are:" + + sqlite3 $users "select * from emails where userid in (select id from users where username='$username')" + + header "i looked in $invites and found:" + + sqlite3 $users "select address from emails where userid in (select id from users where username='$username')" | xargs printf "select * from invites where email='%s'" | sqlite3 $invites + + header "i looked in $signups and found:" + + sqlite3 $users "select address from emails where userid in (select id from users where username='$username')" | xargs printf "select * from signups where email like '%%%s%%'" | sqlite3 $signups + ;; + email) + email="${2}" + if [ "$email" == "" ]; then + echo "gimme an email" + exit + fi + + header "i looked in $signups and found:" + + sqlite3 $signups "select * from signups where email like '%$email%'"; + + header "i looked in $invites and found:" + + sqlite3 $invites "select * from invites where email='$email'" + + header "i looked in $users and found:" + + sqlite3 $users "select * from users where id in (select userid from emails where address='$email')" + ;; + *) + echo "what do you want to know about?" + echo "i can tell you about: user, email" + exit 1 + ;; +esac