0

我最近尝试在我的树莓派(运行 raspbian)上实现 yowsup python 客户端。我已经为 yowsup 下载了所有相关库并完成了两步注册过程。

我从yowsup github获取了示例 layer.py 和 run.py 文件来制作一个简单的 echo bot。

当我尝试运行 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
4

1 回答 1

0

我最近遇到了一个非常相似的问题,我认为问题在于教程已过时。现在,您必须在堆栈中包含三个 Axolotl 层,而不仅仅是一个(请参阅此提交)

你的堆栈看起来像这样:

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

只是为了让我的代码保持一致。

于 2016-12-06T11:55:01.450 回答