您好,我正在尝试使用 yowsup 发送消息,但我没有成功,您能帮我解决一下 IndentationError: unexpected indent 谢谢
从 yowsup.layers.interface 导入 YowInterfaceLayer,ProtocolEntityCallback 从 yowsup.layers.protocol_messages.protocolentities 导入 TextMessageProtocolEntity 从 yowsup.common.tools 导入 Jid
EchoLayer 类(YowInterfaceLayer):
@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):
if messageProtocolEntity.getType() == 'text':
self.onTextMessage(messageProtocolEntity)
reply = 1
messageEntity = TextMessageProtocolEntity(reply,to = messageProtocolEntity.getFrom())
self.toLower(messageEntity)
self.toLower(messageProtocolEntity.forward(messageProtocolEntity.getFrom()))
self.toLower(messageProtocolEntity.ack())
self.toLower(messageProtocolEntity.ack(True))
@ProtocolEntityCallback("receipt")
def onReceipt(self, entity):
self.toLower(entity.ack())
def onTextMessage(self,messageProtocolEntity):
# just print info
print("Echoing %s to %s" % (messageProtocolEntity.getBody(), messageProtocolEntity.getFrom(False)))