import { ResultAffectedMessages } from './DeleteMessages' ; import { Api } from 'telegram' ; import { Snake } from '../../client' ; export interface readHistoryMoreParams { maxId ? : number ; } export async function ReadHistory ( snakeClient , chatId , more ? ) { try { let type = await snakeClient . telegram . getEntity ( chatId ) ; if ( type . type == 'channel' ) { let results = await snakeClient . client . invoke ( new Api . channels . ReadHistory ( { channel : chatId , ... more , } ) ) ; return new ResultAffectedMessages ( results ) ; } else { let results = await snakeClient . client . invoke ( new Api . messages . ReadHistory ( { peer : chatId , ... more , } ) ) ; return new ResultAffectedMessages ( results ) ; } } catch ( error ) { return snakeClient . _handleError ( error , `telegram.readHistory(${ chatId }${ more ? ',' + JSON . stringify ( more ) : '' })` ) ; } }