mtcute/packages/test/src/utils.ts

15 lines
421 B
TypeScript
Raw Normal View History

import { parseMarkedPeerId, tl } from '@mtcute/core'
2023-11-08 17:28:45 +03:00
export function markedIdToPeer(id: number): tl.TypePeer {
const [type, bareId] = parseMarkedPeerId(id)
2023-11-08 17:28:45 +03:00
switch (type) {
case 'user':
return { _: 'peerUser', userId: bareId }
case 'chat':
return { _: 'peerChat', chatId: bareId }
case 'channel':
return { _: 'peerChannel', channelId: bareId }
}
}