import { Api } from 'telegram' ; import { Snake } from '../../client' ; import { TypeReplyMarkup , BuildReplyMarkup } from '../../Utils/ReplyMarkup' ; import { Entities , ParseEntities } from '../../Utils/Entities' ; import { _parseMessageText } from 'telegram/client/messageParse' ; import BigInt from 'big-integer' ; import * as Update from '../../Update' ; export interface forwardMessageMoreParams { withMyScore ? : boolean ; silent ? : boolean ; background ? : boolean ; scheduleDate ? : number ; } export async function ForwardMessages ( snakeClient , chatId , fromChatId , messageId , more ? ) { try { let randomId = [ ] ; for ( let i = 0 ; i < messageId . length ; i ++ ) { randomId . push ( BigInt ( Math . floor ( Math . random ( ) * 10000000000000 ) ) ) ; } let results = await snakeClient . client . invoke ( new Api . messages . ForwardMessages ( { fromPeer : fromChatId , toPeer : chatId , id : messageId , randomId : randomId , ... more , } ) ) ; return await createResults ( results , snakeClient ) ; } catch ( error ) { return snakeClient . _handleError ( error , `telegram.forwardMessages(${ chatId },${ fromChatId },${ JSON . stringify ( messageId ) },${ more ? JSON . stringify ( more , null , 2 ) : '' })` ) ; } } async function createResults ( results , snakeClient ) { if ( results instanceof Api . Updates ) { results as Api . Updates ; if ( results . updates ?. length > 0 ) { for ( let i = 0 ; i < results . updates . length ; i ++ ) { if ( results . updates [ i ] instanceof Api . UpdateNewMessage ) { let arc = results . updates [ i ] as Api . UpdateNewMessage ; let update = new Update . UpdateNewMessage ( ) ; await update . init ( arc , snakeClient ) ; return update ; } if ( results . updates [ i ] instanceof Api . UpdateNewChannelMessage ) { let arc = results . updates [ i ] as Api . UpdateNewChannelMessage ; return arc ; } } } } }