[英]Trying to send a message with Yowsup Python
Hello there im trying to send a message with yowsup but i have not been successful can you please help me im getting IndentationError: unexpected indent Thank you 您好,我正在尝试发送与yowsup的消息,但我没有成功,您能帮我获得IndentationError:意外的缩进吗?
from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback from yowsup.layers.protocol_messages.protocolentities import TextMessageProtocolEntity from yowsup.common.tools import Jid 从yowsup.layers.interface导入YowInterfaceLayer,从yowsup.layers.protocol_messages.protocolentities导入ProtocolEntityCallback从yowsup.common.tools导入TextMessageProtocolEntity
class EchoLayer(YowInterfaceLayer): 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(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)))
IndentationError: unexpected indent
IndentationError:意外缩进
This is a common kind of problem every pythoner has hit with. 这是每个pythoner都遇到的常见问题。 your code has some extra space or any tab is used.so basically you have to check every line and manually remove the excess gaps(shortcuts) and replace them with spaces insted.
您的代码有一些额外的空间或使用了任何制表符。因此基本上,您必须检查每一行并手动删除多余的空格(快捷方式),并用插入的空格替换它们。
The Unexpected indent
error message will always tell you what line the problem is detected on. Unexpected indent
错误消息将始终告诉您检测到问题所在的行。
In your case, it's obviously due to the fact that the if
and reply
lines don't match up. 在您的情况下,显然是由于
if
和reply
行不匹配的事实。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.