From 31b41c93fc7d20be6db6cc34bf9278a97bbb81cb Mon Sep 17 00:00:00 2001 From: Alina Sireneva Date: Thu, 5 Oct 2023 04:41:47 +0300 Subject: [PATCH] chore: extract MASK_POS closes MTQ-43 --- .../src/methods/stickers/add-sticker-to-set.ts | 17 ++++++++--------- .../src/methods/stickers/create-sticker-set.ts | 10 ++-------- packages/client/src/types/media/sticker.ts | 7 +++++++ 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/client/src/methods/stickers/add-sticker-to-set.ts b/packages/client/src/methods/stickers/add-sticker-to-set.ts index b76b9aee..1fb6945f 100644 --- a/packages/client/src/methods/stickers/add-sticker-to-set.ts +++ b/packages/client/src/methods/stickers/add-sticker-to-set.ts @@ -1,12 +1,11 @@ import { TelegramClient } from '../../client' -import { InputStickerSet, InputStickerSetItem, normalizeInputStickerSet, StickerSet } from '../../types' - -const MASK_POS = { - forehead: 0, - eyes: 1, - mouth: 2, - chin: 3, -} as const +import { + InputStickerSet, + InputStickerSetItem, + MASK_POSITION_POINT_TO_TL, + normalizeInputStickerSet, + StickerSet, +} from '../../types' /** * Add a sticker to a sticker set. @@ -44,7 +43,7 @@ export async function addStickerToSet( maskCoords: sticker.maskPosition ? { _: 'maskCoords', - n: MASK_POS[sticker.maskPosition.point], + n: MASK_POSITION_POINT_TO_TL[sticker.maskPosition.point], x: sticker.maskPosition.x, y: sticker.maskPosition.y, zoom: sticker.maskPosition.scale, diff --git a/packages/client/src/methods/stickers/create-sticker-set.ts b/packages/client/src/methods/stickers/create-sticker-set.ts index d08a0744..290fd4f7 100644 --- a/packages/client/src/methods/stickers/create-sticker-set.ts +++ b/packages/client/src/methods/stickers/create-sticker-set.ts @@ -5,19 +5,13 @@ import { InputFileLike, InputPeerLike, InputStickerSetItem, + MASK_POSITION_POINT_TO_TL, StickerSet, StickerSourceType, StickerType, } from '../../types' import { normalizeToInputUser } from '../../utils/peer-utils' -const MASK_POS = { - forehead: 0, - eyes: 1, - mouth: 2, - chin: 3, -} as const - /** * Create a new sticker set. * @@ -117,7 +111,7 @@ export async function createStickerSet( maskCoords: sticker.maskPosition ? { _: 'maskCoords', - n: MASK_POS[sticker.maskPosition.point], + n: MASK_POSITION_POINT_TO_TL[sticker.maskPosition.point], x: sticker.maskPosition.x, y: sticker.maskPosition.y, zoom: sticker.maskPosition.scale, diff --git a/packages/client/src/types/media/sticker.ts b/packages/client/src/types/media/sticker.ts index 8a8dbeae..601824ac 100644 --- a/packages/client/src/types/media/sticker.ts +++ b/packages/client/src/types/media/sticker.ts @@ -6,6 +6,13 @@ import { makeInspectable } from '../../utils' import { StickerSet } from '../misc' import { RawDocument } from './document' +export const MASK_POSITION_POINT_TO_TL = { + forehead: 0, + eyes: 1, + mouth: 2, + chin: 3, +} as const + export interface MaskPosition { /** * The part of the face relative where the mask should be placed