我正在使用Yowsup cli使用whatsapp发送和接收消息。我可以注册并发送消息。但是当我执行此命令来监听传入的消息时:
yowsup-cli demos --login number:password --echo -E s40
我可以看到消息文本,但我看不到谁是消息发送者。如何使用yowsup-cli获取它?
这是我的结果:
yowsup-cli v2.0.15
yowsup v2.5.0
Copyright (c) 2012-2016 Tarek Galal
http://www.openwhatsapp.org
This software is provided free of charge. Copying and redistribution is
encouraged.
If you appreciate this software and you would like to support future
development please consider donating:
http://openwhatsapp.org/yowsup/donate
WARNING:yowsup.layers.axolotl.layer_receive:Received a message that we've previously decrypted, goint to send the delivery receipt myself
DUMP:
Teste 8
['\n', '\x07', 'T', 'e', 's', 't', 'e', ' ', '8']
[10, 7, 84, 101, 115, 116, 101, 32, 56]
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 1087, in MergeFromString
if self._InternalParse(serialized, 0, length) != length:
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 1109, in InternalParse
(tag_bytes, new_pos) = local_ReadTag(buffer, pos)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/google/protobuf/internal/decoder.py", line 181, in ReadTag
while six.indexbytes(buffer, pos) & 0x80:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/yowsup-cli", line 368, in <module>
if not parser.process():
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/yowsup-cli", line 270, in process
self.startEcho()
File "/Library/Frameworks/Python.framework/Versions/3.5/bin/yowsup-cli", line 308, in startEcho
stack.start()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/demos/echoclient/stack.py", line 21, in start
self.stack.loop()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/stacks/yowstack.py", line 196, in loop
asyncore.loop(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncore.py", line 203, in loop
poll_fun(timeout, map)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncore.py", line 150, in poll
read(obj)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncore.py", line 87, in read
obj.handle_error()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncore.py", line 83, in read
obj.handle_read_event()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncore.py", line 423, in handle_read_event
self.handle_read()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/network/layer.py", line 102, in handle_read
self.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/network/layer.py", line 110, in receive
self.toUpper(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/stanzaregulator/layer.py", line 29, in receive
self.processReceived()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/stanzaregulator/layer.py", line 52, in processReceived
self.processReceived()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/stanzaregulator/layer.py", line 49, in processReceived
self.toUpper(oneMessageData)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/auth/layer_crypt.py", line 65, in receive
self.toUpper(payload)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/coder/layer.py", line 35, in receive
self.toUpper(node)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/logger/layer.py", line 14, in receive
self.toUpper(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_control.py", line 44, in receive
self.toUpper(protocolTreeNode)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 76, in toUpper
self.__upper.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/__init__.py", line 189, in receive
s.receive(data)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_receive.py", line 41, in receive
self.onMessage(protocolTreeNode)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_receive.py", line 74, in onMessage
self.handleEncMessage(protocolTreeNode)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_receive.py", line 88, in handleEncMessage
self.handleWhisperMessage(node)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_receive.py", line 144, in handleWhisperMessage
self.parseAndHandleMessageProto(encMessageProtocolEntity, plaintext[:-padding])
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/yowsup/layers/axolotl/layer_receive.py", line 171, in parseAndHandleMessageProto
m.ParseFromString(serializedData)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/google/protobuf/message.py", line 185, in ParseFromString
self.MergeFromString(serialized)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/google/protobuf/internal/python_message.py", line 1093, in MergeFromString
raise message_mod.DecodeError('Truncated message.')
google.protobuf.message.DecodeError: Truncated message.
答案 0 :(得分:1)
实际上,这是使用python 3.5时出现的问题。所以,我使用了python 2.7并且它已经解决了。
答案 1 :(得分:0)
为什么不通过
转到该文件yowsup \演示\ echoclient \ layer.py
并根据需要编辑文件
print("Echoing %s to %s" % (messageProtocolEntity.getBody(), messageProtocolEntity.getFrom(False)))
编辑此行就足够了,但您可以在其下方放置另一条打印行,如此
print("Echoing %s to %s" % (messageProtocolEntity.getBody(), messageProtocolEntity.getFrom(False)))
print("Sender is : "+messageProtocolEntity.getFrom(False))