gramjs
gramjs copied to clipboard
How to listen to new messages on a specific channel?
I looked through all the documentation and didn't find anything like that, I was confused. I just wanted to observe whenever a new message arrived on a Telegram channel so that I could activate automations based on the messages that arrived.
do somthing like this :
import { NewMessage } from 'telegram/events'
const callbackFunction= async (event:any) => {
eventHandler(event); //example function
}
Client.addEventHandler(callbackFunction, new NewMessage({ incoming: true, channels: ['@something' , '@somthing2'] }) )
//if you want to remove the event for some reason
Client.removeEventHandler(callbackFunction)