hfaran / slack-export-viewer

A Slack Export archive viewer that allows you to easily view and share your Slack team's export
https://pypi.python.org/pypi/slack-export-viewer
MIT License
939 stars 194 forks source link

Show emoji reactions to messages #68

Closed MiraiHattori closed 5 years ago

MiraiHattori commented 6 years ago

It's better to show emoji reactions on messages.

tscritch commented 6 years ago

@future731 Are you thinking about opening a pull request for these features?

MiraiHattori commented 6 years ago

@tscritch I've already fixed USLACKBOT issue in my local repository, so I'll send a pull request to that one and close the issue. I'm now struggling with this emoji one because it seems that emoji url is missing in archive json files. I don't think I'll create a pull request about the thread tracking one. Backquote one neither.

lsmith77 commented 5 years ago

@future731 ping? :)

MiraiHattori commented 5 years ago

@lsmith77 pong. I'm struggling with this issue because we have to login the webpage to match the emoji email address. It's pretty easy to show bare text like "\:emoji-name\: by John, Mark"just after the msg text.

MiraiHattori commented 5 years ago

Sorry that I've accidentary closed this issue, and I reopened this.

MiraiHattori commented 5 years ago

https://github.com/future731/slack-export-viewer/commit/667e74c3717cb5c4add8f521597c575f4dde9932

The link above is the easiest workaround, but there are several reasons I didn't make a pull request.

  1. a bot can react with emoji, which makes hard to convert slack user id into slack username. Furthermore, even if we ignore bot emoji reaction, using self._message.get("reactions", [])[0].get("users") will return only slack user ids. SlackFormatter class member function "find_user(self, message)" needs message object.
  2. my workaround is sometimes ugly if the emoji text is long.
  3. I'm not familier with css style format, so I didn't do anything about css.

It'll be good to have reaction property in class Message though.

lsmith77 commented 5 years ago

indeed .. the user.py would need to be refactored to be able to handle user ids from reactions properly.

I tried to improve the code a bit but likely do to being a total python n00b this code is just producing empty reaction div's

                {"usernames": [self._formatter.find_user(Message(self._formatter, {"user": user})).display_name for user in reaction.get("users")], "name": emoji.emojize(':'+reaction.get("name")+':', use_aliases=True)}
lsmith77 commented 5 years ago

ok nevermind .. got it to work

    def user_message(self, user_id):
       return {"user": user_id}

    def usernames(self, reaction):
        return [
            self._formatter.find_user(self.user_message(user_id)).display_name
            for user_id
            in reaction.get("users")
            if self._formatter.find_user(self.user_message(user_id))
        ]

    @property
    def reactions(self):
        reactions = self._message.get("reactions", [])
        return [
            {
                "usernames": self.usernames(reaction),
                "name": emoji.emojize(':'+reaction.get("name")+':', use_aliases=True)
            }
            for reaction in reactions
        ]
lsmith77 commented 5 years ago

will look into creating a PR

MiraiHattori commented 5 years ago

I think this issue is resolved thanks to @lsmith77