summaryrefslogtreecommitdiff
path: root/data.sh
blob: 3a16c5b25615e25847452ea9e6a3fd29857ecb45 (plain)
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
export FORGEBOT_DATA_DIR="forgebotdata"
mkdir -p "$FORGEBOT_DATA_DIR" 

list_watchers() {
  # Usage: list_watchers <minecraft uuid>
  cat "$FORGEBOT_DATA_DIR/$1"
}

find_watched_accounts() {
  # Usage: find_watched_accounts <discord uuid>
  grep -lr "$1" "$FORGEBOT_DATA_DIR" | sed 's|.*/||'
}

add_watched_account() {
  # Usage: add_watched_account <discord uuid> <minecraft uuid>
  echo "$1" >> "$FORGEBOT_DATA_DIR/$2"
}

remove_watched_account() {
  # Usage: remove_watched_account <discord uuid> <minecraft uuid>
  sed -i "/$1/d" "$FORGEBOT_DATA_DIR/$2"
}

has_watched_account() {
  # Usage: has_watched_account <discord uuid> <minecraft uuid>
  grep "$1" "$FORGEBOT_DATA_DIR/$2" >/dev/null
  return $?
}