Przeglądaj źródła

Username or tox ID

Bob Mottram 8 lat temu
rodzic
commit
356baaa67d
1 zmienionych plików z 9 dodań i 10 usunięć
  1. 9
    10
      src/freedombone-mesh-visit-site

+ 9
- 10
src/freedombone-mesh-visit-site Wyświetl plik

49
 trap "rm -f $data" 0 1 2 5 15
49
 trap "rm -f $data" 0 1 2 5 15
50
 dialog --title $"Visit IPFS site" \
50
 dialog --title $"Visit IPFS site" \
51
     --backtitle $"Freedombone mesh" \
51
     --backtitle $"Freedombone mesh" \
52
-    --inputbox $"Enter the username for the site you wish to visit" 8 60 2>$data
52
+    --inputbox $"Enter the username or Tox ID for the site you wish to visit" 8 70 2>$data
53
 sel=$?
53
 sel=$?
54
 case $sel in
54
 case $sel in
55
     0)
55
     0)
56
-        TOX_USERNAME=$(<$data)
57
-        if [ ${#TOX_USERNAME} -gt 0 ]; then
58
-            if ! grep -q "$TOX_USERNAME" $USERS_FILE; then
59
-                dialog --title $"Visit IPFS site" \
60
-                       --backtitle $"Freedombone mesh" \
61
-                       --msgbox $"The user '$TOX_USERNAME' was not found on the mesh" 8 60
62
-                exit 2
56
+        TOX_USERNAME_OR_ID=$(<$data)
57
+        if [ ${#TOX_USERNAME_OR_ID} -gt 0 ]; then
58
+            if ! grep -q "$TOX_USERNAME_OR_ID" $USERS_FILE; then
59
+                TOX_ID="$TOX_USERNAME_OR_ID"
60
+            else
61
+                TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME_OR_ID" | head -n 1 | sed "s|$TOX_USERNAME_OR_ID ||g" | sed -e 's/^[[:space:]]*//')
63
             fi
62
             fi
64
-            TOX_ID=$(cat "$USERS_FILE" | grep "$TOX_USERNAME" | head -n 1 | sed "s|$TOX_USERNAME ||g" | sed -e 's/^[[:space:]]*//')
63
+
65
             if [ ${#TOX_ID} -gt 5 ]; then
64
             if [ ${#TOX_ID} -gt 5 ]; then
66
                 if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
65
                 if ! grep -q "$TOX_ID" $IPFS_USERS_FILE; then
67
                     dialog --title $"Visit IPFS site" \
66
                     dialog --title $"Visit IPFS site" \
68
                            --backtitle $"Freedombone mesh" \
67
                            --backtitle $"Freedombone mesh" \
69
-                           --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME'" 8 60
68
+                           --msgbox $"An IPFS site was not found for the user '$TOX_USERNAME_OR_ID'" 8 60
70
                     exit 3
69
                     exit 3
71
                 fi
70
                 fi
72
                 IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')
71
                 IPFS_FULL_URL=${IPFS_URL}/$(cat "$IPFS_USERS_FILE" | grep $TOX_ID | head -n 1 | awk -F ':' '{print $2}')