1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-27 01:14:39 +01:00

Add support for emojis with <emoji id="1234">, <tg-emoji emoji-id="1234> HTML tags and tg://emoji?id=1234 links, in addition to the pre-existing emoji:id links

This commit is contained in:
Daniil Gentili 2023-05-27 11:49:53 +02:00
parent 2217a8160f
commit 115497e4f6
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
5 changed files with 12 additions and 19 deletions

2
docs

@ -1 +1 @@
Subproject commit 07bd633b113f1fdc690914f152395c7defe6b530
Subproject commit 470028c79ab5b01af7447f24d6a0b8905b727cfe

View File

@ -152,7 +152,7 @@ class MyEventHandler extends EventHandler
*/
public function onUpdateNewMessage(array $update): void
{
if ($update['message']['_'] === 'messageEmpty' || $update['message']['out'] ?? false) {
if ($update['message']['_'] === 'messageEmpty') {
return;
}

View File

@ -179,7 +179,7 @@ trait Constructors
if ($param['name'] === 'reply_markup') {
$hasreplymarkup = true;
}
if ($param['name'] === 'entities' && $constructor === 'inputSingleMedia') {
if ($param['name'] === 'entities') {
$hasentities = true;
$table .= '|parse\\_mode| [string](/API_docs/types/string.md) | Whether to parse HTML or Markdown markup in the message| Optional |
';

View File

@ -1823,12 +1823,6 @@ final class MTProto implements TLCallback, LoggerGetter
public function getTypeMismatchCallbacks(): array
{
return \array_merge(
\array_fill_keys(
[
'InputPeer',
],
$this->getInputPeer(...),
),
\array_fill_keys(
[
'InputUser',
@ -1854,16 +1848,13 @@ final class MTProto implements TLCallback, LoggerGetter
],
$this->getFileInfo(...),
),
\array_fill_keys(
['InputFileLocation'],
$this->getDownloadInfo(...),
),
\array_fill_keys(
['InputCheckPasswordSRP'],
function (string $password): array {
[
'InputFileLocation' => $this->getDownloadInfo(...),
'InputPeer' => $this->getInputPeer(...),
'InputCheckPasswordSRP' => function (string $password): array {
return (new PasswordCalculator($this->methodCallAsyncRead('account.getPassword', [])))->getCheckPassword($password);
}
),
},
],
);
}
/**

View File

@ -56,6 +56,8 @@ final class DOMEntities
'code' => ['_' => 'messageEntityCode'],
'spoiler', 'tg-spoiler' => ['_' => 'messageEntitySpoiler'],
'pre' => ['_' => 'messageEntityPre', 'language' => $node->getAttribute('language') ?? ''],
'tg-emoji' => ['_' => 'messageEntityCustomEmoji', 'document_id' => (int) $node->getAttribute('emoji-id')],
'emoji' => ['_' => 'messageEntityCustomEmoji', 'document_id' => (int) $node->getAttribute('id')],
'a' => $this->handleA($node),
default => null,
};
@ -90,7 +92,7 @@ final class DOMEntities
if (\preg_match('|^mention:(.+)|', $href, $matches) || \preg_match('|^tg://user\\?id=(.+)|', $href, $matches)) {
return ['_' => 'inputMessageEntityMentionName', 'user_id' => $matches[1]];
}
if (\preg_match('|^emoji:(\d+)$|', $href, $matches)) {
if (\preg_match('|^emoji:(\d+)$|', $href, $matches) || \preg_match('|^tg://emoji\\?id=(.+)|', $href, $matches)) {
return ['_' => 'messageEntityCustomEmoji', 'document_id' => (int) $matches[1]];
}
return ['_' => 'messageEntityTextUrl', 'url' => $href];