8

Finding the most popular reaction in Slack

 3 years ago
source link: https://hannes.enjoys.it/blog/2020/12/finding-the-most-popular-reaction-in-slack/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Finding the most popular reaction in Slack

This can be run against a Slack export. It will count the reactions used and display them in an ordered list. Written for readability not speed or efficiency. No guarantees that this isn’t terribly broken. Enjoy and use responsibly!

import json
import glob
import collections

# collect messages
messages = []
for filename in glob.glob('*/*.json'):
    with open(filename) as f:
        messages += json.load(f)

# extract reactions
reactions = []
for message in messages:
    if "reactions" in message:
        reactions += message["reactions"]

# count reactions
reaction_counter = collections.Counter()
for reaction in reactions:
    reaction_counter.update({reaction["name"]: reaction["count"]})

# done, print them
print(reaction_counter.most_common())
This entry was posted in python, small things on 2020-12-09.

Post navigation

← DCP-L2530DW printer/scanner on Archlinux

Leave a Reply Cancel reply

Your email address will not be published.

Comment

Name

Email

Website

This site uses Akismet to reduce spam. Learn how your comment data is processed.


Recommend

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK