Facebook-chat-api: wrong reaction in message_reaction event

Created on 1 Apr 2017  路  7Comments  路  Source: Schmavery/facebook-chat-api

event.reaction seems to be some weird bytes (eg. 240, 0, 159, 0, 152, 0, 141, 0) instead of an emoji

test code:

var fs = require("fs");
var login = require("facebook-chat-api");

var example_reaction = "\uD83D\uDE0D" // ":heart_eyes:"
console.log(`Test reaction: ${example_reaction}`);
dump_string(example_reaction);

login({appState: JSON.parse(fs.readFileSync('../appstate.json', 'utf8'))}, (err, api) => {
    if(err) return console.error(err);

    api.setOptions({listenEvents: true, logLevel: "silly"});

    var stopListening = api.listen((err, event) => {
        if(err) return console.error(err);

        if (event.type === "message_reaction") {
            console.log(`Reaction: ${event.reaction}`);
            dump_string(event.reaction);
        }
    });
});

function dump_string(s) {
    var bytes = [];
    for (var i = 0; i < s.length; ++i) {
        var code = s.charCodeAt(i);
        bytes = bytes.concat([code & 0xff, code / 256 >>> 0]);
    }
    console.log('bytes: ' + bytes.join(', '));
}
bug

All 7 comments

What's the output of printing it normally?

in the terminal I only see first character
zrzut ekranu z 2017-04-01 19 51 41

I wonder if we need something more complicated than this to decode the response.

@GAMELASTER did you come up with this decoder or pull it from the facebook code? Did you ever see this problem?

@Schmavery It's pulled from Facebook code.
Uh, I browsed the facebook code deeply and found the solution. Reaction requires one more decoding. Sending pull request

Hey @ravkr did this fix work for you? I did a quick test on my end and it seemed to help.

@GAMELASTER @Schmavery You guys are on top of your shit! Nice :D

works perfectly
thank you :smile:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

KuoyuanY picture KuoyuanY  路  7Comments

DanH42 picture DanH42  路  3Comments

Hraph picture Hraph  路  6Comments

rivc picture rivc  路  4Comments

ianw11 picture ianw11  路  7Comments