首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >尝试使用Yowsup Python发送消息

尝试使用Yowsup Python发送消息
EN

Stack Overflow用户
提问于 2017-03-06 17:24:41
回答 2查看 563关注 0票数 0

你好,我想用yowsup发送一条消息,但没有成功,你能帮我弄到IndentationError吗?

从yowsup.layers.interface导入YowInterfaceLayer,从yowsup.layers.protocol_messages.protocolentities导入ProtocolEntityCallback从yowsup.common.tools导入TextMessageProtocolEntity

EchoLayer类(YowInterfaceLayer):

代码语言:javascript
复制
@ProtocolEntityCallback("message")
def onMessage(self, messageProtocolEntity):

    if messageProtocolEntity.getType() == 'text':
        self.onTextMessage(messageProtocolEntity)

     reply = 1
     messageEntity = TextMessageProtocolEntity(reply,to = messageProtocolEntity.getFrom())

self.toLower(messageEntity)

代码语言:javascript
复制
    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)))
EN

回答 2

Stack Overflow用户

发布于 2017-05-10 02:30:39

IndentationError:意外缩进

这是每个巨人都遇到过的常见问题。你的代码有一些额外的空格,或者任何制表符都是used.so的,基本上你必须检查每一行,手动删除多余的空格(快捷方式),并将它们替换为空格实例。

票数 0
EN

Stack Overflow用户

发布于 2017-05-10 03:04:50

Unexpected indent错误消息将始终告诉您在哪条线路上检测到问题。

在您的例子中,这显然是由于ifreply行不匹配所致。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42621833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档