2016-10-22 10 views
4

私は(管理者ではない)1つの特定のチャンネルのすべての新しいメッセージを読む必要があります。私は別のクライアントapis(.NET、PHP、nodejs)を探しましたが、どれも役に立たなかった。電報チャンネルのメッセージを読む

どうすればいいですか?

ありがとうございます!

+0

さて問題です:

は電報https://github.com/vysheng/tg

は、CLI wraper https://github.com/luckydonald/pytg

from pytg import Telegram from pytg.utils import coroutine tg = Telegram( telegram="./tg/bin/telegram-cli", pubkey_file="./tg/tg-server.pub") receiver = tg.receiver QUIT = False @coroutine def main_loop(): try: while not QUIT: msg = (yield) # it waits until it got a message, stored now in msg. if msg.text is None: continue print(msg.event) print(msg.text) except GeneratorExit: pass except KeyboardInterrupt: pass else: pass receiver.start() receiver.message(main_loop()) 

NodeJSバージョンをインストールします。チャンネルメッセージを読むことは、私がやりたい唯一のことです。私はこれに使うことができるC#、VB、PHP、Java、またはNodejsのテレグラムクライアントを期待していました。 – Digot

答えて

0

最初のステップでは、チャネルメッセージを読み取ることができない場合は、テレグラムロボットをチャネル管理者として追加します。ここで

4

は、私はそれをやった方法です:

const path = require('path'); 
const TelegramAPI = require('tg-cli-node'); 
const config = { 
    telegram_cli_path: path.join(__dirname, 'tg/bin/telegram-cli'), //path to tg-cli (see https://github.com/vysheng/tg) 
    telegram_cli_socket_path: path.join(__dirname, 'socket'), // path for socket file 
    server_publickey_path: path.join(__dirname, 'tg/tg-server.pub'), // path to server key (traditionally, in %tg_cli_path%/tg-server.pub) 
} 

const Client = new TelegramAPI(config) 

Client.connect(connection => { 
    connection.on('message', message => { 
     console.log('message : ', message) 
     console.log('message event : ', message.event) 
     console.log('message text : ', message.text)   
     console.log('message from :', message.from) 
    }) 
    connection.on('error', e => { 
     console.log('Error from Telegram API:', e) 
    }) 
    connection.on('disconnect',() => { 
     console.log('Disconnected from Telegram API') 
    }) 
}) 
+0

には、pytgを使って特定のチャンネルから投稿を受け取る方法があります。 –

+0

@ycodeメッセージを受信して​​いるチャネルはどこですか?または、直接のメッセージしか受信していませんか? –

関連する問題