0

こんにちは、yowsup でメッセージを送信しようとしていますが、うまくいきませんでした。

yowsup.layers.interface からインポート YowInterfaceLayer、yowsup.layers.protocol_messages.protocolentities から ProtocolEntityCallback yowsup.common.tools から TextMessageProtocolEntity をインポート 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(メッセージエンティティ)

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

2 に答える 2