如何在网络图中收听电报消息/推送通知 [英] How to listen for Telegram messages / push notifications in webogram

查看:36
本文介绍了如何在网络图中收听电报消息/推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通过 Telegram API 接收最新的电报更新.似乎 webogram 是该任务唯一的最新 javascript 库.我之前使用过电报链接,它通过 TCP 可以很好地完成任务.

I need to receive latest telegram updates through the Telegram API. It seems that webogram is the only up-to-date javascript library for the task. I was using telegram link previously which did the task fine over TCP.

我想知道 webogram 是否可以做同样的事情,特别是使用什么方法来接收传入的消息/推送通知.

I want to know if webogram can do the same, and specifically what methods to use for receiving incoming messages / push notifications.

推荐答案

以下日志来自webogram.

The log below is from webogram.

我在 console.log 中添加了一些注释,以显示正在调用的函数和一些额外的响应细节.

I've added some comments with console.log to show what functions are being called and some extra response details.

这是针对 2016 年 1 月的旧版网络图(第 45 层),但总而言之,我怀疑基础知识已经发生了很大变化.

This is for an older version of webogram (Layer 45) from Jan 2016, but all in all I doubt the basics have changed much.

类似地,您可以在整个源 javascript 中添加 console.logs 并运行 webogram 的本地副本,以帮助您了解流程.

You can similarly add console.logs throughout the source javascript and run a local copy of webogram to help you understand the process flow.

这基本上就是我从网络图片中获取这些日志和详细信息的方式.

That's basically how I got these logs and details out of webogram.

希望这会有所帮助.

ID  time    info    log
121 12:26:35.318    new Auth    Auth successfull! dc= 2 mtproto.js:479:15
127 12:26:35.325    CALL    =>> API call help.getNearestDc Object {  } Object { dcID: 2, createNetworker: true } mtproto.js:749:4
128 12:26:35.327    enc-START   [invokeWithLayer] 45 mtproto.js:753:7
168 12:26:35.551    SEND    POST XHR http://149.154.167.51/apiw1 [HTTP/1.1 200 OK 708ms]
189 12:26:36.522    msg-r   <<=m [msg_container] Object { _: "msg_container", messages: Array[2] } mtproto.js:1452:5
190 12:26:36.523    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200678614200321", seqno: 1, bytes: 28, body: Object } mtproto.js:1452:5
191 12:26:36.525    msg-r   <<=m [new_session_created] Object { _: "new_session_created", first_msg_id: "6242200671500883244", unique_id: "645797764649391412", server_salt: "17212767594123551779" } mtproto.js:1452:5
192 12:26:36.526    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200678630513665", seqno: 3, bytes: 28, body: Object } mtproto.js:1452:5
193 12:26:36.528    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200671500883244", result: Object } mtproto.js:1452:5
257 12:26:39.239    new Auth    Auth successfull! dc= 4 mtproto.js:479:15
270 12:26:59.606    CALL    =>> API call auth.sendCode Object { phone_number: "2348022002298", sms_type: 5, api_id: 38665, api_hash: "880c7847a517fc455d7d54731e90ad4e", lang_code: "en-US" } Object { dcID: 2, createNetworker: true } mtproto.js:749:4
321 12:27:00.048    SEND    POST XHR http://149.154.167.51/apiw1 [HTTP/1.1 200 OK 422ms]
328 12:27:00.981    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200779464550396", result: Object } mtproto.js:1452:5
331 12:27:00.986    CALL    =>> API call auth.sendCode Object { phone_number: "2348022002298", sms_type: 5, api_id: 38665, api_hash: "880c7847a517fc455d7d54731e90ad4e", lang_code: "en-US" } Object { dcID: "4", createNetworker: true, resultType: "auth.SentCode", messageID: "6242200779464550396" } mtproto.js:749:4
332 12:27:00.987    enc-START   [invokeWithLayer] 45 mtproto.js:753:7
377 12:27:01.288    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 321ms]
398 12:27:02.170    msg-r   <<=m [msg_container] Object { _: "msg_container", messages: Array[2] } mtproto.js:1452:5
399 12:27:02.171    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200787684582401", seqno: 1, bytes: 28, body: Object } mtproto.js:1452:5
400 12:27:02.172    msg-r   <<=m [new_session_created] Object { _: "new_session_created", first_msg_id: "6242200784556418516", unique_id: "13396961033572361155", server_salt: "7076519506215495914" } mtproto.js:1452:5
401 12:27:02.173    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200787775901697", seqno: 3, bytes: 48, body: Object } mtproto.js:1452:5
402 12:27:02.174    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200784556418516", result: Object } mtproto.js:1452:5
407 12:27:02.344    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 25154ms]
414 12:27:03.068    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200779464550396" } mtproto.js:1452:5
420 12:27:15.639    CALL    =>> API call auth.sendSms Object { phone_number: "2348022002298", phone_code_hash: "696b5befd8e809de81" } Object { dcID: "4", createNetworker: true, resultType: "auth.SentCode", messageID: "6242200784556418516" } mtproto.js:749:4
468 12:27:15.924    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 457ms]
475 12:27:17.154    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200848242727644", result: true } mtproto.js:1452:5
482 12:27:27.511    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200848242727644" } mtproto.js:1452:5
505 12:27:31.003    SEND    POST XHR http://149.154.167.51/apiw1 [HTTP/1.1 200 OK 25161ms]
511 12:27:40.133    CALL    =>> API call auth.signIn Object { phone_number: "2348022002298", phone_code_hash: "696b5befd8e809de81", phone_code: "26914" } Object { dcID: "4", createNetworker: true, resultType: "Bool", messageID: "6242200848242727644" } mtproto.js:749:4
560 12:27:40.454    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 756ms]
567 12:27:41.223    msg-r   <<=m [msg_container] Object { _: "msg_container", messages: Array[2] } mtproto.js:1452:5
568 12:27:41.224    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200956100910081", seqno: 7, bytes: 80, body: Object } mtproto.js:1452:5
569 12:27:41.225    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200954555850604", result: Object } mtproto.js:1452:5
570 12:27:41.226    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200956751929345", seqno: 9, bytes: 88, body: Object } mtproto.js:1452:5
571 12:27:41.227    msg-r   <<=m [updates] Object { _: "updates", updates: Array[1], users: Array[0], chats: Array[0], date: 1453375666, seq: 2 } mtproto.js:1452:5
579 12:27:41.758    CALL    =>> API call updates.getState Object {  } Object { noErrorBox: true } mtproto.js:749:4
586 12:27:41.842    CALL    =>> API call account.updateStatus Object { offline: false } Object { noErrorBox: true } mtproto.js:749:4
594 12:27:41.850    CALL    =>> API call messages.getDialogs Object { offset_date: 0, offset_id: 0, offset_peer: Object, limit: 20 } Object { timeout: 300 } mtproto.js:749:4
655 12:27:42.965    CALL    =>> API call messages.getAllStickers Object { hash: "" } Object {  } mtproto.js:749:4
696 12:27:43.920    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 908ms]
712 12:27:44.613    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 303ms]
727 12:27:46.488    msg-r   <<=m [msg_container] Object { _: "msg_container", messages: Array[3] } mtproto.js:1452:5
728 12:27:46.489    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970862778369", seqno: 11, bytes: 36, body: Object } mtproto.js:1452:5
729 12:27:46.489    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960159395644", result: Object } mtproto.js:1452:5
730 12:27:46.490    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970891641857", seqno: 13, bytes: 776, body: Object } mtproto.js:1452:5
731 12:27:46.492    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960356118244", result: Object } mtproto.js:1452:5
732 12:27:46.494    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970897958913", seqno: 15, bytes: 16, body: Object } mtproto.js:1452:5
733 12:27:46.495    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960337591900", result: true } mtproto.js:1452:5
740 12:27:46.567    msg-r   <<=m [msg_container] Object { _: "msg_container", messages: Array[4] } mtproto.js:1452:5
741 12:27:46.568    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970862778369", seqno: 11, bytes: 36, body: Object } mtproto.js:1452:5
742 12:27:46.569    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960159395644" } mtproto.js:1452:5
743 12:27:46.569    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970891641857", seqno: 13, bytes: 776, body: Object } mtproto.js:1452:5
744 12:27:46.570    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960356118244" } mtproto.js:1452:5
745 12:27:46.571    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200970897958913", seqno: 15, bytes: 16, body: Object } mtproto.js:1452:5
746 12:27:46.572    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200960337591900" } mtproto.js:1452:5
747 12:27:46.573    msg-r   <<=m [message] Object { _: "message", msg_id: "6242200973791209473", seqno: 17, bytes: 76, body: Object } mtproto.js:1452:5
748 12:27:46.574    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200964892679524", result: Object } mtproto.js:1452:5
754 12:27:46.584    CALL    =>> API call messages.getStickerSet Object { stickerset: Object } Object {  } mtproto.js:749:4
811 12:27:47.346    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 539ms]
818 12:27:48.175    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242200981275507620", result: Object } mtproto.js:1452:5
857 12:27:49.351    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 25141ms]
864 12:27:57.219    msg-r   <<=m [msgs_ack] Object { _: "msgs_ack", msg_ids: Array[0] } mtproto.js:1452:5
870 12:28:04.673    CALL    =>> API call messages.readHistory Object { peer: Object, max_id: 0 } Object {  } mtproto.js:749:4
908 12:28:04.860    CALL    =>> API call messages.getHistory Object { peer: Object, offset_id: 16, add_offset: 0, limit: 20 } Object { timeout: 300, noErrorBox: true } mtproto.js:749:4
922 12:28:05.713    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 367ms]
929 12:28:06.096    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242201058769372356", result: Object } mtproto.js:1452:5
936 12:28:15.702    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242201058769372356" } mtproto.js:1452:5
977 12:28:16.122    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 25170ms]
983 12:28:26.637    CALL    =>> API call account.updateStatus Object { offline: true } Object { noErrorBox: true } mtproto.js:749:4
1016    12:28:26.660    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 302ms]
1023    12:28:27.062    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242201153183272948", result: true } mtproto.js:1452:5
1030    12:28:41.985    msg-r   <<=m [rpc_result] Object { _: "rpc_result", req_msg_id: "6242201153183272948" } mtproto.js:1452:5
1071    12:28:42.421    SEND    POST XHR http://149.154.167.91/apiw1 [HTTP/1.1 200 OK 25165ms]

这篇关于如何在网络图中收听电报消息/推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆