mirror of
https://github.com/keanuplayz/dotfiles.git
synced 2024-08-15 02:33:12 +00:00
[scripts/copy-crosscode-emoji-url] SHOW ONLY SFW EMOTES
This commit is contained in:
parent
264846e066
commit
c53525dc09
1 changed files with 9 additions and 7 deletions
|
@ -27,11 +27,11 @@ config = ConfigParser(interpolation=None)
|
||||||
config.read(config_path)
|
config.read(config_path)
|
||||||
|
|
||||||
|
|
||||||
data = []
|
emotes = []
|
||||||
|
|
||||||
|
|
||||||
def emote_downloader_and_iterator():
|
def emote_downloader_and_iterator():
|
||||||
global data
|
global emotes
|
||||||
|
|
||||||
registry_dump_file = config.get(
|
registry_dump_file = config.get(
|
||||||
"default", "ccbot_emote_registry_dump_file", fallback=None
|
"default", "ccbot_emote_registry_dump_file", fallback=None
|
||||||
|
@ -47,22 +47,24 @@ def emote_downloader_and_iterator():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(registry_dump_file, "r") as f:
|
with open(registry_dump_file, "r") as f:
|
||||||
data = json.load(f)
|
emote_registry_data = json.load(f)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
response = requests.get(registry_dump_url, timeout=10)
|
response = requests.get(registry_dump_url, timeout=10)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
data = response.json()
|
emote_registry_data = response.json()
|
||||||
|
|
||||||
assert data["version"] == 1
|
assert emote_registry_data["version"] == 1
|
||||||
|
|
||||||
for emote in data["list"]:
|
emotes = [emote for emote in emote_registry_data["list"] if emote["safe"]]
|
||||||
|
|
||||||
|
for emote in emotes:
|
||||||
yield "{emote[ref]} [{emote[guild_name]}]".format(emote=emote)
|
yield "{emote[ref]} [{emote[guild_name]}]".format(emote=emote)
|
||||||
|
|
||||||
|
|
||||||
chosen_index = common_script_utils.run_chooser(
|
chosen_index = common_script_utils.run_chooser(
|
||||||
emote_downloader_and_iterator(), prompt="emote", async_read=True
|
emote_downloader_and_iterator(), prompt="emote", async_read=True
|
||||||
)
|
)
|
||||||
chosen_emote = data["list"][chosen_index]
|
chosen_emote = emotes[chosen_index]
|
||||||
|
|
||||||
emote_url = chosen_emote["url"]
|
emote_url = chosen_emote["url"]
|
||||||
default_emote_image_size = config.getint(
|
default_emote_image_size = config.getint(
|
||||||
|
|
Loading…
Reference in a new issue