[scripts] add script for integration with ccbot's emote registry dump

This commit is contained in:
Dmytro Meleshko 2020-05-15 20:11:45 +03:00
parent 626bd91f00
commit 6e47910a46
2 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
# shellcheck source=/dev/null
source ~/.config/copy-crosscode-emoji-url.conf.sh
data_refs=()
data_urls=()
data_titles=()
read_line() {
IFS= read -r "$@"
}
# https://stackoverflow.com/a/15692004/12005228
print_lines() {
eval "printf '%s\n' \"\${$1[@]}\""
}
while read_line ref && read_line url && read_line title; do
data_refs+=("$ref")
data_urls+=("$url")
data_titles+=("$title")
done < <(
curl --location --fail --max-time 10 "$CCBOT_EMOTE_REGISTRY_DUMP_URL" |
jq -r '.list[] | select(.safe) | .ref, .url, "\(.ref) [\(.guild_name)]"'
)
if index="$(print_lines data_titles | rofi -dmenu -i -p cc-emoji -format i)"; then
echo -n "${data_urls[$index]}" | xsel --clipboard --input
notify-send --icon=utilities-terminal --expire-time=3000 "$0" "copied URL of ${data_refs[$index]} to clipboard!"
fi

View file

@ -6,7 +6,7 @@ declare -A faces=(
["table flip"]=$'(\xe3\x83\x8e\xe0\xb2\xa0\xe7\x9b\x8a\xe0\xb2\xa0)\xe3\x83\x8e\xe5\xbd\xa1\xe2\x94\xbb\xe2\x94\x81\xe2\x94\xbb'
)
if IFS=$'\n' face_name="$(echo -e "${!faces[*]}" | rofi -dmenu)"; then
if IFS=$'\n' face_name="$(echo -E "${!faces[*]}" | rofi -dmenu -i)"; then
face="${faces[$face_name]}"
echo -n "$face" | xsel --clipboard --input
notify-send --icon=utilities-terminal --expire-time=2500 "$0" "$face_name copied to clipboard"