0

Im trying to write a code that fetches the latest messages of a specific private telegram channel.

I want to to ignore messages replies in the channel, I couldnt find anything to help me with that.

this is my code

const { api } = require('./mtproto');

function startListener() {
    console.log('[+] starting listener');
    const newChannelMessages = [];

    api.mtproto.updates.on('updates', ({ updates }) => {
        const filteredMessages = updates
            .filter((update) => 
                update._ === 'updateNewChannelMessage' && 
                update.message.peer_id.channel_id == '12345678' && 
                update.message.message.startsWith('$') &&
                !update.message.message.split(' ').some(word => ['T1', 'T2', 'T3', 'T4', 'T5', 'T6'].includes(word))
            .map(({ message }) => message);
        
        newChannelMessages.push(...filteredMessages);

        for (const message of filteredMessages) {
            console.log(message.message);
        }
    });

    return newChannelMessages;
}

module.exports = {

    startListener,
    
  };

Appreciate your support

Ryan
  • 129
  • 1
  • 12
  • What is going wrong? Can you link us to the telegram API/library that you're using so we can look at the documentation or source code for you? – chill389cc May 28 '23 at 13:51
  • @chill389cc in the script i need to ignore fetching replies but im unable to find anything. Im using mtproto, here is the documentation https://mtproto-core.js.org/docs/call-the-telegram-methods – Ryan May 28 '23 at 14:16

0 Answers0