zerobias / telegram-mtproto

Telegram client api (MTProto) library
MIT License
620 stars 136 forks source link

More docs required - handling incoming updates #40

Closed leonerd closed 5 years ago

leonerd commented 7 years ago

I'm currently attempting to make use of incoming "updates" messages from telegram, and finding no examples for this.

Specifically, nothing in the toplevel readme, nor any of the files under the examples/ dir, show anything about, for example, how to react to an incoming UpdateShortChatMessage which contains a newly-received message in a chat.

By sourcediving, I do see that the toplevel MTProto appears to have a pair of on+emit methods, assigned by the constructor in lib/service/main/index.js itself but this exercise in reading the source hasn't so far lead me to discover what event names might be emitted, that I could register an interest in, nor what the shape of arguments they'd provide.

For reference, this is part of a code rewrite on matrix-appservice-tg to swap from using telegram.link to telegram-mtproto; the part of code currently in question starts with the call to client.registerOnUpdates at

https://github.com/matrix-org/matrix-appservice-tg/blob/master/lib/TelegramGhost.js#L81

goodmind commented 5 years ago

@soapagent you can use tdlib for web clients