chore: extract MASK_POS

closes MTQ-43
This commit is contained in:
alina 🌸 2023-10-05 04:41:47 +03:00
parent 74f3d53448
commit 31b41c93fc
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
3 changed files with 17 additions and 17 deletions

View file

@ -1,12 +1,11 @@
import { TelegramClient } from '../../client' import { TelegramClient } from '../../client'
import { InputStickerSet, InputStickerSetItem, normalizeInputStickerSet, StickerSet } from '../../types' import {
InputStickerSet,
const MASK_POS = { InputStickerSetItem,
forehead: 0, MASK_POSITION_POINT_TO_TL,
eyes: 1, normalizeInputStickerSet,
mouth: 2, StickerSet,
chin: 3, } from '../../types'
} as const
/** /**
* Add a sticker to a sticker set. * Add a sticker to a sticker set.
@ -44,7 +43,7 @@ export async function addStickerToSet(
maskCoords: sticker.maskPosition ? maskCoords: sticker.maskPosition ?
{ {
_: 'maskCoords', _: 'maskCoords',
n: MASK_POS[sticker.maskPosition.point], n: MASK_POSITION_POINT_TO_TL[sticker.maskPosition.point],
x: sticker.maskPosition.x, x: sticker.maskPosition.x,
y: sticker.maskPosition.y, y: sticker.maskPosition.y,
zoom: sticker.maskPosition.scale, zoom: sticker.maskPosition.scale,

View file

@ -5,19 +5,13 @@ import {
InputFileLike, InputFileLike,
InputPeerLike, InputPeerLike,
InputStickerSetItem, InputStickerSetItem,
MASK_POSITION_POINT_TO_TL,
StickerSet, StickerSet,
StickerSourceType, StickerSourceType,
StickerType, StickerType,
} from '../../types' } from '../../types'
import { normalizeToInputUser } from '../../utils/peer-utils' import { normalizeToInputUser } from '../../utils/peer-utils'
const MASK_POS = {
forehead: 0,
eyes: 1,
mouth: 2,
chin: 3,
} as const
/** /**
* Create a new sticker set. * Create a new sticker set.
* *
@ -117,7 +111,7 @@ export async function createStickerSet(
maskCoords: sticker.maskPosition ? maskCoords: sticker.maskPosition ?
{ {
_: 'maskCoords', _: 'maskCoords',
n: MASK_POS[sticker.maskPosition.point], n: MASK_POSITION_POINT_TO_TL[sticker.maskPosition.point],
x: sticker.maskPosition.x, x: sticker.maskPosition.x,
y: sticker.maskPosition.y, y: sticker.maskPosition.y,
zoom: sticker.maskPosition.scale, zoom: sticker.maskPosition.scale,

View file

@ -6,6 +6,13 @@ import { makeInspectable } from '../../utils'
import { StickerSet } from '../misc' import { StickerSet } from '../misc'
import { RawDocument } from './document' import { RawDocument } from './document'
export const MASK_POSITION_POINT_TO_TL = {
forehead: 0,
eyes: 1,
mouth: 2,
chin: 3,
} as const
export interface MaskPosition { export interface MaskPosition {
/** /**
* The part of the face relative where the mask should be placed * The part of the face relative where the mask should be placed