2016-07-11 5 views
0

テレポットを使って私の最初のテレグラムロボットをビルドしようとしています。 私は会話をコマンドでルーティングしたいので、Telepot Helper Routerのドキュメントを読んだことがありますが、どのように使用できるのか分かりません。テレポトエラーヘルパールータ: 'module'オブジェクトに 'router'属性がありません

はこれまでのところ、私が持っている:

私は、このエラー与え
import telepot 
from telepot.routing import by_chat_command 

def on_site(chat_id,msg): 
    #function code 
def on_tick(chat:id,msg): 
    #function code 
def on_start(chat_id,msg): 
    #function code 
r = telepot.helper.router(by_chat_command(), {'site': on_site , 'tick':on_tick , 'start':on_start }) 
bot.routing_table['text']=r.route 
bot = telepot.Bot('TOKEN') 
bot.message_loop() 
print ('Listening....') 

#LOOP 
while 1: 
    time.sleep(10) 

r = telepot.helper.router(by_chat_command(), {'site': on_site , 'tick':on_tick , 'start':on_start }) 

私が間違って何をしました:行に

AttributeError: 'module' object has no attribute 'router'

を?

答えて

0

問題は、クラスではなく関数を呼び出そうとしていることです。 あなたがTelepot hereのソースをチェックする場合は、Routerだから代わりのクラス

であることがわかります。

r = telepot.helper.router 

使用

r = telepot.helper.Router 
関連する問題