-
Notifications
You must be signed in to change notification settings - Fork 598
Utility function for getting the image URL for a Messenger-style emoji #477
Conversation
I think this should be in a separate file and added to https://github.com/Schmavery/facebook-chat-api/blob/master/index.js#L75 |
@ravkr is right, if this function is meant for general users (not just internally), then it should be exposed in that way. Let me know if you need help with that. |
@Schmavery My rationale was that if someone wanted to render the messages obtained using this API, they might want to use the same emojis that Messenger uses. I was working on a Messenger log export tool (GEOFBOT/flexr if anyone's interested) using this library and I wanted to use Messenger-style emojis in the output, so I figured out this function. |
Ok, seems reasonable. Feel free to add a link to your tool to the end of the README (in a separate PR) when it's ready 😄 |
Question: |
Can we assume for now that everyone using the api is logging in using it? I think I'd rather go with that for now. |
Sorry for the delay; I've moved the function into its own file and added docs |
const baseUrl = 'https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s'; | ||
pixelRatio = pixelRatio || '1.0'; | ||
|
||
let ending = util.format('%s/%s/%s.png', pixelRatio, size, c.codePointAt(0).toString(16)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does util not need to be 'require'd for this to work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason it worked when I tested it, but I've added the proper require
Thanks @GEOFBOT :) |
#467
Example usage:
utils.getEmojiUrl('🐍', 128)
returnshttps://static.xx.fbcdn.net/images/emoji.php/v8/ze1/1.5/128/1f40d.png
which is the emoji asset url for the snake emoji: