Сonst magicTgHTML = (text, entities) => {

let processedText = text;
let offsetShift = 0;

entities.forEach(entity => {
const { offset, length, type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + length;

switch (type) {
// case 'hashtag':
// processedText = `${processedText.slice(0, startIndex)}<b>${processedText.slice(startIndex, endIndex)}</b>${processedText.slice(endIndex)}`;
// offsetShift += 7; // Length of added HTML tags <b> and </>
// break;
case 'bold':
processedText =h, type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + length
offsetShift += 7; // Length of added HTML tags <b> and </>
break;
case 'italic':
processedText =ength, type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + le
offsetShift += 7; // Length of added HTML tags <i> and </>
break;
case 'underline':
processedText =th, type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + lengt
offsetShift += 7; // Length of added HTML tags <u> and </>
break;
case 'strikethrough':
processedText =type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + length;


offsetShift += 7; // Length of added HTML tags <s> and </>
break;
case 'text_link':
processedText =th, type, url, user } = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + length;

sw
offsetShift += 16 + url.length; // Length of added HTML tags <a href=""></a>
break;
case 'text_mention':
processedText = = entity;
const startIndex = offset + offsetShift;
const endIndex = startIndex + length;

switch (type) {
// case 'has
offsetShift += 25 + user.id.toString().length; // Length of added HTML tags <a href="tg://user?id="></a>
break;
case 'phone_number':
processedText =rtIndex = offset + offsetShift;
const endIndex = startIndex + length;

switch (type) {
// case 'hashtag':
// processedText = `${processe
offsetShift += 18 + processedText.slice(startIndex, endIndex).length; // Length of added HTML tags <a href="tel:"></a>
break;
default:
break;
}
});

return processedText;



}

1 ответов

47 просмотров
Андрей- Автор вопроса

Вот что он дают)

Похожие вопросы

Обсуждают сегодня

Короче я тут узнал полный пиздец Что кучу постов которые я создавал через posted Спустя время не могу редактировать и менять Мол телега возвращае ошибку Это реально так ...
inc.
13
Привет, сталкивался кто с такой ситуацией? У меня есть модальное окно Bootstrap, в нем кнопка закрытия: <button type="button" class="btn-close" data-bs-dismiss="modal" aria-...
Виталий
3
А если изначально бот работал так : есть сайт онлайн школы. У каждого ученика свой кабинет. Где он авторизуется по своим данным. И уже в кабинете, на самом сайте делает оплату...
Денис 💡 Фрилансер
13
что это и почему оно? executor.start_polling(bot, skip_updates=True, on_startup=on_startup, File "/usr/local/lib/python3.10/dist-packages/aiogram/utils/executor.py", line 4...
𐌍𐌄 ᕓ𐌄𐌓𐌌Ꝋ𐌓𐌄
2
Какой число последнее будет, если сказали от 1 до 10 взять все?
Misha Mikhail
5
А у тебя есть информация сколько сейчас использует твой бот?
Artem Stormageddon
4
Окрошка! На квасе или кефире или на пиве?!
Akcium Сергей
4
Забавно, но для тебя "этот" = "следующий" т.е этот год для тебя какой?
Magic
3
А что насчет FluentValidation? тоже ведь есть альтернатива у МС.
devman
13
Читаю сейчас [нет, уже больше не читаю!] курсовую о Булгакове, написанную, похоже, с помощью ChatGPT. Это удивительный психоделический опыт. Текст в основном написан в стиле б...
✨ Uni [🌊 В отпуске]
1
Карта сайта