Open bdelwood opened 3 years ago
Should be doable, involves some browser devtools on twitter.com/messages to find out how twitter sends mentions in messages (it's probably a separate field in the send request body) and then parsing the Matrix HTML similar to https://github.com/mautrix/facebook/blob/master/mautrix_facebook/formatter/from_matrix.py to generate that field
Other direction already happens in https://github.com/mautrix/twitter/blob/master/mautrix_twitter/formatter.py
Mostly notes for myself as I debug this, but it appears what happens when a user is mentioned is
The "text" key has a value that is the plaintext message, including the raw handle of the user, ie @{USER}.
The "entities" object is included in "message" (this also happens for URLs, which are handled correctly), with a "user_mentions" key containing and array of objects with info on the mentioned user. It appears there is already a class, Message Entities, particularly MessageEntityUserMention, that already has the json object that twitter expects is included in the entity.
I'll check out what the formatter is doing to the value of "text" and "user_mentions." Currently it appears the formatter is only sending the full Matrix username in the "text" field, and not including the expected "entities" key.
There's currently no formatter in the Matrix -> Twitter direction, the bridge just sends the plain body.
If a user mentions a Twitter user on Matrix, it appears on the Twitter end in plain text as the Matrix user's display name.
Is this a fundamental limitation of the bridge? If not, I would be interested in contributing a fix.