2016-11-27 152 views
0

我最近嘗試在我的覆盆子pi(運行raspbian)上實現yowsup python客戶端。我已經下載了yowsup的所有相關庫並完成了2步註冊過程。Yowsup授權不起作用

我把yowsup github的樣本layer.py和run.py文件做成了一個簡單的echo機器人。

當我嘗試運行我遇到了以下錯誤run.py:

任何幫助,非常感謝!

python run.py 
Traceback (most recent call last): 
    File "run.py", line 20, in <module> 
    stack.loop() #this is the program mainloop 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/stacks/yowstack.py", line 196, in loop 
    asyncore.loop(*args, **kwargs) 
    File "/usr/lib/python2.7/asyncore.py", line 216, in loop 
    poll_fun(timeout, map) 
    File "/usr/lib/python2.7/asyncore.py", line 156, in poll 
    read(obj) 
    File "/usr/lib/python2.7/asyncore.py", line 87, in read 
    obj.handle_error() 
    File "/usr/lib/python2.7/asyncore.py", line 83, in read 
    obj.handle_read_event() 
    File "/usr/lib/python2.7/asyncore.py", line 449, in handle_read_event 
    self.handle_read() 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/network/layer.py", line 102, in handle_read 
    self.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/network/layer.py", line 110, in receive 
    self.toUpper(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 29, in receive 
    self.processReceived() 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived 
    self.toUpper(oneMessageData) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/auth/layer_crypt.py", line 65, in receive 
    self.toUpper(payload) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/coder/layer.py", line 35, in receive 
    self.toUpper(node) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/logger/layer.py", line 14, in receive 
    self.toUpper(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/axolotl/layer_control.py", line 44, in receive 
    self.toUpper(protocolTreeNode) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 189, in receive 
    s.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/axolotl/layer_receive.py", line 44, in receive 
    self.toUpper(protocolTreeNode) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 76, in toUpper 
    self.__upper.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 189, in receive 
    s.receive(data) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/__init__.py", line 125, in receive 
    recv(node) 
    File "/usr/local/lib/python2.7/dist-packages/yowsup2-2.5.0-py2.7.egg/yowsup/layers/auth/layer_authentication.py", line 81, in handleFailure 
    raise AuthError(nodeEntity.getReason()) 
yowsup.layers.auth.autherror.AuthError: not-authorized 

回答

0

我最近有一個非常類似的問題,我相信這個問題是本教程是過時的。現在有三個Axolotl圖層必須包含在您的堆棧中,而不是隻有一個(see this commit)

如果你的籌碼看起來會是這樣的:

layers = (
    EchoLayer, 
    YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, 
         YowAckProtocolLayer]), YowAxolotlLayer 
) + YOWSUP_CORE_LAYERS 

現在有這個樣子:

layers = (
    EchoLayer, 
    YowParallelLayer([YowAuthenticationProtocolLayer, YowMessagesProtocolLayer, YowReceiptProtocolLayer, 
         YowAckProtocolLayer]), AxolotlReceivelayer, AxolotlSendLayer, AxolotlControlLayer, 
) + YOWSUP_CORE_LAYERS 

你需要添加下面的進口,以及:

from yowsup.layers.axolotl import AxolotlSendLayer, AxolotlControlLayer, AxolotlReceivelayer 

請注意,AxolotlReceivelayer在'圖層'中有一個小寫'L'。我認爲這可能是Yowsup維護人員的一個疏忽,因爲它與命名方案的其餘部分不一致。我所做的是:

from yowsup.layers.axolotl import AxolotlReceivelayer as AxolotlReceiveLayer 

只是爲了讓我的代碼保持一致。