bitlbee / bitlbee-facebook

Facebook protocol plugin for BitlBee
GNU General Public License v2.0
281 stars 49 forks source link

Stickers #127

Open IamCarbonMan opened 7 years ago

IamCarbonMan commented 7 years ago

There is currently no way to send a sticker. Perhaps a command like /sticker <URL or ID>?

dequis commented 7 years ago

dgw commented 7 years ago

@dequis AAAH IT'S EVERYWHERE

dequis commented 7 years ago

I think I won't be able to leave it up to the user to provide the ID, those aren't particularly visible from anywhere in the UI.

In the following examples, the sticker pack ID is 1844803329128898, the sticker id is 1846059612336603.

Incoming message json (only visible through bitlbee-facebook's debug)

{
  "deltas": [
    {
      "deltaNewMessage": {
        "messageMetadata": {
          "threadKey": {
            "otherUserFbId": [...]
          },
          "messageId": "mid.[...]",
          "offlineThreadingId": [...],
          "actorFbId": [...],
          "timestamp": 1487120908632,
          "tags": [
            "source:chat:orca"
          ]
        },
        "stickerId": 1846059612336603
      }
    }
  ],
  "firstDeltaSeqId": 29710,
  "lastIssuedSeqId": 29710
}

FetchStickersWithPreviewsQuery response:

{
  "1846059612336603": {
    "__type__": {
      "name": "Sticker"
    },
    "id": "1846059612336603",
    "pack": {
      "id": "1844803329128898"
    },
    "thread_image": {
      "uri": "https://scontent.xx.fbcdn.net/v/t39.1997-6/p128x128/16327863_1846059615669936_736656151906615296_n.png?_nc_ad=z-m&oh=ef4f83b1d60c410f1489a43a9414641e&oe=59416A07"
    },
    "animated_image": {
      "uri": "https://scontent.xx.fbcdn.net/v/t39.1997-6/16327453_1846059959003235_3476824984444207104_n.webp?_nc_ad=z-m&oh=aa1c44e12fe081b06b367adeb2c186b5&oe=5947B9A3"
    },
    "preview_image": {
      "uri": "https://scontent.xx.fbcdn.net/v/t39.1997-6/p200x200/16327863_1846059615669936_736656151906615296_n.png?_nc_ad=z-m&oh=7cb87f31a316f3110f1c48b47c57b6c0&oe=593D4C70"
    }
  }
}

128x128 single frame url that we show in the UI:

https://scontent.xx.fbcdn.net/v/t39.1997-6/p128x128/16327863_1846059615669936_736656151906615296_n.png?_nc_ad=z-m&oh=ef4f83b1d60c410f1489a43a9414641e&oe=59416A07

600x600 multiple frame static image used by facebook.com on firefox at least (probably because of its lack of webp support):

https://scontent-eze1-1.xx.fbcdn.net/v/t39.1997-6/p600x600/16180567_1846059625669935_593734054205980672_n.png?oh=024e7a4fef21eedbe0376e6fa3621105&oe=5934897D

Another one:

https://scontent-eze1-1.xx.fbcdn.net/v/t39.1997-6/p320x320/16344631_1846059619003269_2434487372902039552_n.png?oh=de609f20cf57d153f71b676639589213&oe=59497E93

Another one:

https://scontent-eze1-1.xx.fbcdn.net/v/t39.1997-6/s851x315/16180567_1846059625669935_593734054205980672_n.png?oh=17d0589fada678df634f2eeb9b263a7e&oe=5937846A

And so on. 1846059612336603 is mentioned nowhere public.

So I think the best solution here is to make a command that sends 1846059612336603 and nothing else.

IamCarbonMan commented 7 years ago

So the image URL and the sticker/pack ID are unrelated. Until there's a suitable way to find stickers in the UI (which is basically pointless at least in Bitlbee, although this presumably applies to the purple plugin as well), why not have a command that can send stickers given an id and/or pack id? That way people who are willing to dig can keep a list of the commands for the stickers they would usually send.

dequis commented 7 years ago

Nope I'm afraid I can only support sending 1846059612336603 and nothing else

IamCarbonMan commented 7 years ago

Well, that's actually quite a good idea.

On Feb 15, 2017 09:22, "dx" notifications@github.com wrote:

Nope I'm afraid I can only support sending 1846059612336603 and nothing else

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bitlbee/bitlbee-facebook/issues/127#issuecomment-280076822, or mute the thread https://github.com/notifications/unsubscribe-auth/APgjsIO9wzshKIfAzdjNdcU7S5H64At0ks5rczROgaJpZM4MArty .

IamCarbonMan commented 7 years ago

I've been trying to implement this, but I can't quite figure out how to actually send a sticker message. I replaced the line

fb_json_bldr_add_str(bldr, "body", msg->text);

in fb_api_message_send with:

fb_json_bldr_add_int(bldr, "stickerId", 1846059612336603);

so every message should now send .

But instead I get the following error in the debug log:

[INFO] facebook: Parsing JSON:  {
    "failedSend": {
        "offlineThreadingId": [...],
        "errorMessage": "Your message appears to be blank. Please enter your message and try again.",
        "isRetryable": 0,
        "errorCode":1545023
    }
}

If I use both lines:

fb_json_bldr_add_int(bldr, "stickerId", 1846059612336603);
fb_json_bldr_add_str(bldr, "body", "sticker");

I get the normal JSON responses from Facebook and the recipient receives only "sticker".

dequis commented 7 years ago

Yeah that's the tricky part which I haven't figured out myself. It's not a normal text message, it probably uses a different mqtt topic, and I don't know the JSON structure. The only captures I have with stickers are from the newer messenger versions which seem to use thrift for everything, and I'd rather not.

Never really cared about feature until

IamCarbonMan commented 7 years ago

Well crap.

I have a rooted Nexus device and use Messenger a lot. I also have an Arch Linux laptop and a lot of mostly useless time on my hands. So if there's any testing or reverse engineering I can help with I'd be happy to.

dequis commented 7 years ago

Reversing notes here: https://wiki.dequis.org/notes/facebook/

Slightly convoluted but it would be lovely to reduce the bus factor of this project.

I just updated them after not touching them for a year with a couple of small details like the fact that the latest versions don't have a libsslx.so to remove. Luckily you don't have to deal with those. Get a version around 30-40 (current is 104). The lower the better, as long as they have stickers. Not sure if those have more json though.

dequis commented 7 years ago

IamCarbonMan commented 7 years ago

dequis commented 7 years ago

but it would be lovely to reduce the bus factor of this project

WAIT I just realized, s/reduce/increase/

I do not actually want to get hit by a bus.

IamCarbonMan commented 7 years ago

it's too late

the bus factor is being reduced as we speak

IamCarbonMan commented 7 years ago

2017-02-16-001237_1366x768_scrot

I've placed the mqtt.lua file in ~/..wireshark/plugins and I don't have the dissector. Not a fatal flaw but it would be nice to have.

IamCarbonMan commented 7 years ago

OK, I found a fix for this and opened a PR on the dissector's repo.