Created
March 14, 2023 15:46
-
-
Save puhitaku/8ef8fb64bcc87c51dee32e70c985d7d9 to your computer and use it in GitHub Desktop.
Slack Archive Emoji Counter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Slack Archive Emoji Counter | |
Copyright (c) 2023 Takumi Sueda ([email protected]) | |
SPDX-License-Identifier: MIT | |
Put this script by the channel directories and run it. | |
""" | |
import json | |
import sys | |
from pathlib import Path | |
emoji_counts = dict() | |
def count(fn): | |
with open(fn, 'r', encoding='utf-8') as f: | |
j = json.load(f) | |
for message in j: | |
if 'reactions' in message: | |
for reaction in message['reactions']: | |
emoji = reaction['name'] | |
count = reaction['count'] | |
emoji_counts[emoji] = emoji_counts.get(emoji, 0) + count | |
for fn in Path('.').glob('**/*.json'): | |
print(fn, file=sys.stderr) | |
count(fn) | |
for emoji, count in sorted(emoji_counts.items(), key=lambda x: x[1], reverse=True): | |
print(emoji, count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment