gramjs icon indicating copy to clipboard operation
gramjs copied to clipboard

Export events like you export another things

Open vanodevium opened this issue 1 year ago • 4 comments

#698 #601

Even I try to make import as you wrote in you documentation

import { TelegramClient } from "telegram";
import { StringSession } from "telegram/sessions";
import { NewMessageEvent } from "telegram/events";

I have problem with exports and ERR_UNSUPPORTED_DIR_IMPORT

So please inject events into main exported object.

It will fix many problems with Events as minimum.

Thanx!

vanodevium avatar Dec 25 '24 15:12 vanodevium

as a workaround you can do.

  client.addEventHandler((message) => {
        console.log(message);
    }, new TelegramClient.events.NewMessage());

You don't need to import events like this.

painor avatar Dec 25 '24 16:12 painor

@painor

Thanx. It works but as workaround.

In general I wanna completely without errors use string

import { NewMessageEvent } from "telegram/events";

Is is possible?

vanodevium avatar Dec 25 '24 17:12 vanodevium

Last time I tried that i ended up with some recursive errors so I have to restructure the imports a bit to make it work for now. So it'll take some time to update that

painor avatar Dec 25 '24 17:12 painor

@painor Please mention me for testing when it would be done.

Thanx!

vanodevium avatar Dec 25 '24 17:12 vanodevium