2017-03-06 30 views
0

你好我嘗試發送帶有yowsup但我一直沒成功,你可以幫我即時得到IndentationError:意外縮進謝謝試圖發送一個消息Yowsup的Python

從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))) 

回答

0

IndentationError: unexpected indent

這是一種常見的問題每pythoner已經擊中。你的代碼有一些額外的空間或任何標籤是used.so基本上你必須檢查每一行並手動刪除多餘的間隙(快捷方式),並取代它們用空格insted的。

0

Unexpected indent錯誤消息總是會告訴你什麼線檢測的問題。

就你而言,這顯然是由於ifreply行不匹配的事實。