import { Api } from 'telegram' ; export class Entities { offset : number = 0 ; length : number = 0 ; type ! : string ; constructor ( entities ) { if ( entities . offset ) this . offset = entities . offset ; if ( entities . length ) this . length = entities . length ; this . type = entities . className . replace ( /MessageEntity/i , '' ) . trim ( ) ; this . type = this . type . replace ( this . type [ 0 ] , this . type [ 0 ] . toLowerCase ( ) ) ; } } export function ParseEntities ( entities ) { let temp = [ ] ; for ( let i = 0 ; i < entities . length ; i ++ ) { let en = entities [ i ] ; let type = `MessageEntity${ en . type . replace ( en . type [ 0 ] , en . type [ 0 ] . toUpperCase ( ) ) }` ; temp . push ( new Api [ type ] ( { length : en . length , offset : en . offset , } ) ) ; } return temp as Api . TypeMessageEntity [ ] ; }