mirror of
https://github.com/muerwre/vk-tg-bot.git
synced 2025-04-24 22:46:41 +07:00
#4 fixed photo caption trimming
This commit is contained in:
parent
34155f39ba
commit
01211eae0f
1 changed files with 3 additions and 8 deletions
|
@ -306,14 +306,9 @@ export class PostNewHandler extends VkEventHandler<Fields, Values> {
|
||||||
* Calculates, how much should we cut off the text to match photo caption limitations
|
* Calculates, how much should we cut off the text to match photo caption limitations
|
||||||
*/
|
*/
|
||||||
private trimTextForPhoto = (text: string, user: UsersUserFull): string => {
|
private trimTextForPhoto = (text: string, user: UsersUserFull): string => {
|
||||||
// Full markup
|
const withText = this.themeText(text, user);
|
||||||
const full = this.themeText(text, user);
|
const withoutText = this.themeText("", user);
|
||||||
// Rest info except text
|
|
||||||
const others = this.themeText("", user);
|
|
||||||
|
|
||||||
// How much rest markup takes
|
return withText.slice(0, PHOTO_CAPTION_LIMIT - withoutText.length);
|
||||||
const diff = full.length - others.length;
|
|
||||||
|
|
||||||
return full.slice(0, PHOTO_CAPTION_LIMIT - diff);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue