element-hq / mautrix-telegram

A Matrix-Telegram hybrid puppeting/relaybot bridge
https://matrix.to/#/#telegram:maunium.net
GNU Affero General Public License v3.0
14 stars 6 forks source link

Support code blocks #62

Open AnonC0DER opened 10 months ago

AnonC0DER commented 10 months ago

Overview

I would like to propose the implementation of code block support within the Matrix bridge. Currently, the absence of this feature makes it challenging to effectively communicate and share code-related information in Matrix conversations.

Feature Details

Currently the raw json updates that are from mautrix bridge looks like this :

{
  "message_id": 15948,
  "from": {
    "id": 12345,
    "is_bot": false,
    "first_name": "Someone",
    "username": "Someone",
    "language_code": "en"
  },
  "chat": {
    "id": 12345,
    "first_name": "Someone",
    "username": "Someone",
    "type": "private"
  },
  "date": 1702883382,
  "forward_from": {
    "id": 12345,
    "is_bot": false,
    "first_name": "Somebody",
    "username": "Somebody",
  },
  "forward_date": 1702883336,
  "text": "```bash\necho \"hello\"\n```"
}

After update it should be similar to this :

{
  "message_id": 15951,
  "from": {
    "id": 12345,
    "is_bot": false,
    "first_name": "Someone",
    "username": "Someone",
    "language_code": "en"
  },
  "chat": {
    "id": 12345,
    "first_name": "Someone",
    "username": "Someone",
    "type": "private"
  },
  "date": 1702883388,
  "forward_from": {
    "id": 12345,
    "is_bot": false,
    "first_name": "Someone",
    "username": "Someone",
    "language_code": "en"
  },
  "forward_date": 1702883342,
  "text": "echo \"hello\"",
  "entities": [
    {
      "offset": 0,
      "length": 12,
      "type": "pre",
      "language": "bash"
    }
  ]
}