Beispiel #1
0
    def onSuccess(self, successProtocolEntity):
        vcard_data = """BEGIN:VCARD
(Your VCard Data here)
END:VCARD
"""
        phone = self.getProp(self.__class__.PROP_TO)
        outVcard = VCardMediaMessageProtocolEntity('VcardName', vcard_data, to = phone + "@s.whatsapp.net")
        self.ackQueue.append(outVcard.getId())
        self.toLower(outVcard)
Beispiel #2
0
    def onSuccess(self, successProtocolEntity):
        vcard_data = """BEGIN:VCARD
(Your VCard Data here)
END:VCARD
"""
        phone = self.getProp(self.__class__.PROP_TO)
        outVcard = VCardMediaMessageProtocolEntity('VcardName',
                                                   vcard_data,
                                                   to=phone +
                                                   "@s.whatsapp.net")
        self.ackQueue.append(outVcard.getId())
        self.toLower(outVcard)
Beispiel #3
0
    def onMediaMessage(self, messageProtocolEntity):
        if messageProtocolEntity.getMediaType() == "image":
            
            receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom())

            outImage = ImageDownloadableMediaMessageProtocolEntity(
                messageProtocolEntity.getMimeType(), messageProtocolEntity.fileHash, messageProtocolEntity.url, messageProtocolEntity.ip,
                messageProtocolEntity.size, messageProtocolEntity.fileName, messageProtocolEntity.encoding, messageProtocolEntity.width, messageProtocolEntity.height,
                messageProtocolEntity.getCaption(),
                to = messageProtocolEntity.getFrom(), preview = messageProtocolEntity.getPreview())

            print("Echoing image %s to %s" % (messageProtocolEntity.url, messageProtocolEntity.getFrom(False)))

            #send receipt otherwise we keep receiving the same message over and over
            self.toLower(receipt)
            self.toLower(outImage)

        elif messageProtocolEntity.getMediaType() == "location":

            receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom())

            outLocation = LocationMediaMessageProtocolEntity(messageProtocolEntity.getLatitude(),
                messageProtocolEntity.getLongitude(), messageProtocolEntity.getLocationName(),
                messageProtocolEntity.getLocationURL(), messageProtocolEntity.encoding,
                to = messageProtocolEntity.getFrom(), preview=messageProtocolEntity.getPreview())

            print("Echoing location (%s, %s) to %s" % (messageProtocolEntity.getLatitude(), messageProtocolEntity.getLongitude(), messageProtocolEntity.getFrom(False)))

            #send receipt otherwise we keep receiving the same message over and over
            self.toLower(outLocation)
            self.toLower(receipt)
        elif messageProtocolEntity.getMediaType() == "vcard":
            receipt = OutgoingReceiptProtocolEntity(messageProtocolEntity.getId(), messageProtocolEntity.getFrom())
            outVcard = VCardMediaMessageProtocolEntity(messageProtocolEntity.getName(),messageProtocolEntity.getCardData(),to = messageProtocolEntity.getFrom())
            print("Echoing vcard (%s, %s) to %s" % (messageProtocolEntity.getName(), messageProtocolEntity.getCardData(), messageProtocolEntity.getFrom(False)))
            #send receipt otherwise we keep receiving the same message over and over
            self.toLower(outVcard)
            self.toLower(receipt)
Beispiel #4
0
 def vcard_send(self, number, name, carddata):
     outgoingMessage = VCardMediaMessageProtocolEntity(
         name, carddata, to=self.normalizeJid(number))
     self.toLower(outgoingMessage)
Beispiel #5
0
    def onMediaMessage(self, messageProtocolEntity):
        if messageProtocolEntity.getMediaType() == "image":

            receipt = OutgoingReceiptProtocolEntity(
                messageProtocolEntity.getId(), messageProtocolEntity.getFrom())

            outImage = ImageDownloadableMediaMessageProtocolEntity(
                messageProtocolEntity.getMimeType(),
                messageProtocolEntity.fileHash,
                messageProtocolEntity.url,
                messageProtocolEntity.ip,
                messageProtocolEntity.size,
                messageProtocolEntity.fileName,
                messageProtocolEntity.encoding,
                messageProtocolEntity.width,
                messageProtocolEntity.height,
                messageProtocolEntity.getCaption(),
                to=messageProtocolEntity.getFrom(),
                preview=messageProtocolEntity.getPreview())

            print("image %s [%s]:%s" %
                  (messageProtocolEntity.getFrom(False),
                   datetime.datetime.fromtimestamp(
                       messageProtocolEntity.getTimestamp()).strftime(
                           '%d-%m-%Y %H:%M'), messageProtocolEntity.url))

        elif messageProtocolEntity.getMediaType() == "location":

            receipt = OutgoingReceiptProtocolEntity(
                messageProtocolEntity.getId(), messageProtocolEntity.getFrom())

            outLocation = LocationMediaMessageProtocolEntity(
                messageProtocolEntity.getLatitude(),
                messageProtocolEntity.getLongitude(),
                messageProtocolEntity.getLocationName(),
                messageProtocolEntity.getLocationURL(),
                messageProtocolEntity.encoding,
                to=messageProtocolEntity.getFrom(),
                preview=messageProtocolEntity.getPreview())

            print("location %s [%s]:(%s, %s)" %
                  (messageProtocolEntity.getFrom(False),
                   datetime.datetime.fromtimestamp(
                       messageProtocolEntity.getTimestamp()).strftime(
                           '%d-%m-%Y %H:%M'),
                   messageProtocolEntity.getLatitude(),
                   messageProtocolEntity.getLongitude()))

        elif messageProtocolEntity.getMediaType() == "vcard":
            receipt = OutgoingReceiptProtocolEntity(
                messageProtocolEntity.getId(), messageProtocolEntity.getFrom())
            outVcard = VCardMediaMessageProtocolEntity(
                messageProtocolEntity.getName(),
                messageProtocolEntity.getCardData(),
                to=messageProtocolEntity.getFrom())
            print("vcard %s [%s]:(%s, %s)" %
                  (messageProtocolEntity.getFrom(False),
                   datetime.datetime.fromtimestamp(
                       messageProtocolEntity.getTimestamp()).strftime(
                           '%d-%m-%Y %H:%M'), messageProtocolEntity.getName(),
                   messageProtocolEntity.getCardData()))

        outgoingMessageProtocolEntity = OutgoingReceiptProtocolEntity(
            messageProtocolEntity.getId(), messageProtocolEntity.getFrom())
        self.toLower(receipt)
        print("Sent delivered receipt Message %s" %
              messageProtocolEntity.getId())