feat: add hashtag removal utility and integrate it into caption formatting
This commit is contained in:
parent
58dc5f5ae3
commit
816eca4da5
@ -5,6 +5,7 @@ import { logHandle } from '../helpers/logging';
|
||||
import { TTL_URLS } from '@/config/redis';
|
||||
import { getInstagramDownloadUrl } from '@/utils/instagram';
|
||||
import { getRedisInstance } from '@/utils/redis';
|
||||
import { removeHashtags } from '@/utils/text';
|
||||
import { getTiktokDownloadUrl } from '@/utils/tiktok';
|
||||
import { validateInstagramUrl, validateTikTokUrl, validateYoutubeUrl } from '@/utils/urls';
|
||||
import { getYoutubeDownloadUrl } from '@/utils/youtube';
|
||||
@ -18,7 +19,8 @@ const redis = getRedisInstance();
|
||||
|
||||
// Форматирование подписи как expandable blockquote
|
||||
function formatCaption(caption: string) {
|
||||
return fmt`${expandableBlockquote} ${caption} ${expandableBlockquote}`;
|
||||
const cleanCaption = removeHashtags(caption);
|
||||
return fmt`${expandableBlockquote} ${cleanCaption} ${expandableBlockquote}`;
|
||||
}
|
||||
|
||||
feature.on('message:text', logHandle('download-message'), async (context) => {
|
||||
|
||||
@ -7,3 +7,5 @@ export const INSTAGRAM_URL_REGEX =
|
||||
|
||||
export const YOUTUBE_URL_REGEX =
|
||||
/(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|v\/|shorts\/))([\w-]{11})(?:[?&]\S*)?/u;
|
||||
|
||||
export const TAGS = /#[\p{L}\p{N}_]+/gu;
|
||||
|
||||
3
apps/bot/src/utils/text.ts
Normal file
3
apps/bot/src/utils/text.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export function removeHashtags(caption: string): string {
|
||||
return caption.replaceAll(/#[\p{L}\p{N}_-]+/gu, '').trim();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user