├── .gitignore ├── README.md ├── app ├── layer.py ├── mac │ ├── __init__.py │ ├── layer.py │ ├── mac.py │ ├── run.py │ └── signals.py ├── models │ ├── __init__.py │ ├── message.py │ └── receipt.py ├── receiver │ ├── __init__.py │ └── receiver.py ├── requirements.txt └── utils │ ├── __init__.py │ ├── downloader.py │ ├── helper.py │ └── media_decrypter.py ├── clean.sh ├── config_example.py ├── libs ├── python-axolotl │ ├── .gitignore │ ├── .travis.yml │ ├── LICENSE │ ├── README.md │ ├── axolotl │ │ ├── __init__.py │ │ ├── axolotladdress.py │ │ ├── duplicatemessagexception.py │ │ ├── ecc │ │ │ ├── __init__.py │ │ │ ├── curve.py │ │ │ ├── djbec.py │ │ │ ├── ec.py │ │ │ └── eckeypair.py │ │ ├── groups │ │ │ ├── __init__.py │ │ │ ├── groupcipher.py │ │ │ ├── groupsessionbuilder.py │ │ │ ├── ratchet │ │ │ │ ├── __init__.py │ │ │ │ ├── senderchainkey.py │ │ │ │ └── sendermessagekey.py │ │ │ ├── senderkeyname.py │ │ │ └── state │ │ │ │ ├── __init__.py │ │ │ │ ├── senderkeyrecord.py │ │ │ │ ├── senderkeystate.py │ │ │ │ └── senderkeystore.py │ │ ├── identitykey.py │ │ ├── identitykeypair.py │ │ ├── invalidkeyexception.py │ │ ├── invalidkeyidexception.py │ │ ├── invalidmessageexception.py │ │ ├── invalidversionexception.py │ │ ├── kdf │ │ │ ├── __init__.py │ │ │ ├── derivedmessagesecrets.py │ │ │ ├── derivedrootsecrets.py │ │ │ ├── hkdf.py │ │ │ ├── hkdfv2.py │ │ │ ├── hkdfv3.py │ │ │ └── messagekeys.py │ │ ├── legacymessageexception.py │ │ ├── nosessionexception.py │ │ ├── protobuf │ │ │ ├── LocalStorageProtocol.proto │ │ │ └── WhisperTextProtocol.proto │ │ ├── protocol │ │ │ ├── __init__.py │ │ │ ├── ciphertextmessage.py │ │ │ ├── keyexchangemessage.py │ │ │ ├── prekeywhispermessage.py │ │ │ ├── senderkeydistributionmessage.py │ │ │ ├── senderkeymessage.py │ │ │ ├── whispermessage.py │ │ │ └── whisperprotos_pb2.py │ │ ├── ratchet │ │ │ ├── __init__.py │ │ │ ├── aliceaxolotlparameters.py │ │ │ ├── bobaxolotlparamaters.py │ │ │ ├── chainkey.py │ │ │ ├── ratchetingsession.py │ │ │ ├── rootkey.py │ │ │ └── symmetricaxolotlparameters.py │ │ ├── sessionbuilder.py │ │ ├── sessioncipher.py │ │ ├── state │ │ │ ├── __init__.py │ │ │ ├── axolotlstore.py │ │ │ ├── identitykeystore.py │ │ │ ├── prekeybundle.py │ │ │ ├── prekeyrecord.py │ │ │ ├── prekeystore.py │ │ │ ├── sessionrecord.py │ │ │ ├── sessionstate.py │ │ │ ├── sessionstore.py │ │ │ ├── signedprekeyrecord.py │ │ │ ├── signedprekeystore.py │ │ │ └── storageprotos_pb2.py │ │ ├── statekeyexchangeexception.py │ │ ├── tests │ │ │ ├── __init__.py │ │ │ ├── groups │ │ │ │ ├── __init__.py │ │ │ │ ├── inmemorysenderkeystore.py │ │ │ │ └── test_groupcipher.py │ │ │ ├── inmemoryaxolotlstore.py │ │ │ ├── inmemoryidentitykeystore.py │ │ │ ├── inmemoryprekeystore.py │ │ │ ├── inmemorysessionstore.py │ │ │ ├── inmemorysignedprekeystore.py │ │ │ ├── kdf │ │ │ │ ├── __init__.py │ │ │ │ └── test_hkdf.py │ │ │ ├── ratchet │ │ │ │ ├── __init__.py │ │ │ │ ├── test_chainkey.py │ │ │ │ ├── test_ratchetingsession.py │ │ │ │ └── test_rootkey.py │ │ │ ├── test_sessionbuilder.py │ │ │ ├── test_sessioncipher.py │ │ │ ├── test_sigs.py │ │ │ └── util │ │ │ │ ├── __init__.py │ │ │ │ └── test_byteutil.py │ │ ├── untrustedidentityexception.py │ │ └── util │ │ │ ├── __init__.py │ │ │ ├── byteutil.py │ │ │ ├── hexutil.py │ │ │ ├── keyhelper.py │ │ │ └── medium.py │ ├── setup.py │ └── tox.ini ├── yowsup.egg-info │ ├── PKG-INFO │ ├── SOURCES.txt │ ├── dependency_links.txt │ ├── requires.txt │ └── top_level.txt └── yowsup │ ├── .github │ └── ISSUE_TEMPLATE │ │ └── bug_report.md │ ├── .gitignore │ ├── .travis.yml │ ├── CHANGELOG.md │ ├── LICENSE │ ├── MANIFEST.in │ ├── README.md │ ├── setup.py │ ├── tox.ini │ ├── yowsup-cli │ └── yowsup │ ├── __init__.py │ ├── axolotl │ ├── __init__.py │ ├── exceptions.py │ ├── factory.py │ ├── manager.py │ └── store │ │ ├── __init__.py │ │ └── sqlite │ │ ├── __init__.py │ │ ├── liteaxolotlstore.py │ │ ├── liteidentitykeystore.py │ │ ├── liteprekeystore.py │ │ ├── litesenderkeystore.py │ │ ├── litesessionstore.py │ │ └── litesignedprekeystore.py │ ├── common │ ├── __init__.py │ ├── constants.py │ ├── http │ │ ├── __init__.py │ │ ├── httpproxy.py │ │ ├── test_warequest.py │ │ ├── warequest.py │ │ └── waresponseparser.py │ ├── mime.types │ ├── optionalmodules.py │ └── tools.py │ ├── config │ ├── __init__.py │ ├── base │ │ ├── __init__.py │ │ ├── serialize.py │ │ └── transform.py │ ├── manager.py │ ├── transforms │ │ ├── __init__.py │ │ ├── config_dict.py │ │ ├── dict_json.py │ │ ├── dict_keyval.py │ │ ├── filter.py │ │ ├── map.py │ │ ├── meta.py │ │ ├── props.py │ │ └── serialize.py │ └── v1 │ │ ├── __init__.py │ │ └── serialize.py │ ├── demos │ ├── __init__.py │ ├── cli │ │ ├── __init__.py │ │ ├── cli.py │ │ ├── layer.py │ │ └── stack.py │ ├── common │ │ ├── __init__.py │ │ └── sink_worker.py │ ├── contacts │ │ ├── __init__.py │ │ ├── layer.py │ │ └── stack.py │ ├── echoclient │ │ ├── __init__.py │ │ ├── layer.py │ │ └── stack.py │ ├── mediasink │ │ ├── __init__.py │ │ ├── layer.py │ │ └── stack.py │ └── sendclient │ │ ├── __init__.py │ │ ├── layer.py │ │ └── stack.py │ ├── env │ ├── __init__.py │ ├── env.py │ └── env_android.py │ ├── layers │ ├── __init__.py │ ├── auth │ │ ├── __init__.py │ │ ├── layer_authentication.py │ │ ├── layer_interface_authentication.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── auth.py │ │ │ ├── challenge.py │ │ │ ├── failure.py │ │ │ ├── response.py │ │ │ ├── stream_error.py │ │ │ ├── stream_features.py │ │ │ ├── success.py │ │ │ ├── test_failure.py │ │ │ └── test_success.py │ ├── axolotl │ │ ├── __init__.py │ │ ├── layer_base.py │ │ ├── layer_control.py │ │ ├── layer_receive.py │ │ ├── layer_send.py │ │ ├── props.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── enc.py │ │ │ ├── iq_key_get.py │ │ │ ├── iq_keys_get_result.py │ │ │ ├── iq_keys_set.py │ │ │ ├── message_encrypted.py │ │ │ ├── notification_encrypt_identitychange.py │ │ │ ├── notification_encrypt_requestkeys.py │ │ │ ├── receipt_incoming_retry.py │ │ │ ├── receipt_outgoing_retry.py │ │ │ ├── test_iq_keys_get_result.py │ │ │ ├── test_iq_keys_set.py │ │ │ └── test_notification_encrypt_requestkeys.py │ ├── coder │ │ ├── __init__.py │ │ ├── decoder.py │ │ ├── encoder.py │ │ ├── layer.py │ │ ├── test_decoder.py │ │ ├── test_encoder.py │ │ ├── test_tokendictionary.py │ │ └── tokendictionary.py │ ├── interface │ │ ├── __init__.py │ │ └── interface.py │ ├── logger │ │ ├── __init__.py │ │ └── layer.py │ ├── network │ │ ├── __init__.py │ │ ├── dispatcher │ │ │ ├── __init__.py │ │ │ ├── dispatcher.py │ │ │ ├── dispatcher_asyncore.py │ │ │ └── dispatcher_socket.py │ │ ├── layer.py │ │ └── layer_interface.py │ ├── noise │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── layer_noise_segments.py │ │ └── workers │ │ │ ├── __init__.py │ │ │ └── handshake.py │ ├── protocol_acks │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── protocolentities │ │ │ ├── __init__.py │ │ │ ├── ack.py │ │ │ ├── ack_incoming.py │ │ │ ├── ack_outgoing.py │ │ │ ├── test_ack_incoming.py │ │ │ └── test_ack_outgoing.py │ │ └── test_layer.py │ ├── protocol_calls │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── call.py │ │ │ └── test_call.py │ ├── protocol_chatstate │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── protocolentities │ │ │ ├── __init__.py │ │ │ ├── chatstate.py │ │ │ ├── chatstate_incoming.py │ │ │ ├── chatstate_outgoing.py │ │ │ ├── test_chatstate_incoming.py │ │ │ └── test_chatstate_outgoing.py │ │ └── test_layer.py │ ├── protocol_contacts │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq_sync.py │ │ │ ├── iq_sync_get.py │ │ │ ├── iq_sync_result.py │ │ │ ├── notification_contact.py │ │ │ ├── notification_contact_add.py │ │ │ ├── notification_contact_remove.py │ │ │ ├── notification_contact_update.py │ │ │ ├── notificiation_contacts_sync.py │ │ │ ├── test_iq_sync_get.py │ │ │ ├── test_iq_sync_result.py │ │ │ ├── test_notification_contact_add.py │ │ │ ├── test_notification_contact_remove.py │ │ │ └── test_notification_contact_update.py │ │ └── test_layer.py │ ├── protocol_groups │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq_groups.py │ │ │ ├── iq_groups_create.py │ │ │ ├── iq_groups_create_success.py │ │ │ ├── iq_groups_info.py │ │ │ ├── iq_groups_leave.py │ │ │ ├── iq_groups_leave_success.py │ │ │ ├── iq_groups_list.py │ │ │ ├── iq_groups_participants.py │ │ │ ├── iq_groups_participants_add.py │ │ │ ├── iq_groups_participants_add_failure.py │ │ │ ├── iq_groups_participants_add_success.py │ │ │ ├── iq_groups_participants_demote.py │ │ │ ├── iq_groups_participants_promote.py │ │ │ ├── iq_groups_participants_remove.py │ │ │ ├── iq_groups_participants_remove_success.py │ │ │ ├── iq_groups_subject.py │ │ │ ├── iq_result_groups_info.py │ │ │ ├── iq_result_groups_list.py │ │ │ ├── iq_result_participants_list.py │ │ │ ├── notification_groups.py │ │ │ ├── notification_groups_add.py │ │ │ ├── notification_groups_create.py │ │ │ ├── notification_groups_remove.py │ │ │ ├── notification_groups_subject.py │ │ │ ├── test_iq_groups.py │ │ │ ├── test_iq_groups_create.py │ │ │ ├── test_iq_groups_create_success.py │ │ │ ├── test_iq_groups_list.py │ │ │ ├── test_iq_result_groups.py │ │ │ └── test_iq_result_groups_list.py │ │ └── structs │ │ │ ├── __init__.py │ │ │ └── group.py │ ├── protocol_ib │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── account_ib.py │ │ │ ├── clean_iq.py │ │ │ ├── dirty_ib.py │ │ │ ├── ib.py │ │ │ ├── offline_ib.py │ │ │ ├── test_clean_iq.py │ │ │ ├── test_dirty_ib.py │ │ │ ├── test_ib.py │ │ │ └── test_offline_iq.py │ ├── protocol_iq │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq.py │ │ │ ├── iq_crypto.py │ │ │ ├── iq_error.py │ │ │ ├── iq_ping.py │ │ │ ├── iq_props.py │ │ │ ├── iq_push.py │ │ │ ├── iq_result.py │ │ │ ├── iq_result_pong.py │ │ │ ├── test_iq.py │ │ │ ├── test_iq_error.py │ │ │ └── test_iq_result.py │ ├── protocol_media │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── mediacipher.py │ │ ├── mediauploader.py │ │ ├── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq_requestupload.py │ │ │ ├── iq_requestupload_result.py │ │ │ ├── message_media.py │ │ │ ├── message_media_contact.py │ │ │ ├── message_media_downloadable.py │ │ │ ├── message_media_downloadable_audio.py │ │ │ ├── message_media_downloadable_document.py │ │ │ ├── message_media_downloadable_image.py │ │ │ ├── message_media_downloadable_sticker.py │ │ │ ├── message_media_downloadable_video.py │ │ │ ├── message_media_extendedtext.py │ │ │ ├── message_media_location.py │ │ │ ├── test_iq_requestupload.py │ │ │ ├── test_iq_requestupload_result.py │ │ │ ├── test_message_media.py │ │ │ ├── test_message_media_contact.py │ │ │ ├── test_message_media_downloadable_audio.py │ │ │ ├── test_message_media_downloadable_image.py │ │ │ ├── test_message_media_downloadable_video.py │ │ │ ├── test_message_media_extendedtext.py │ │ │ └── test_message_media_location.py │ │ └── test_mediacipher.py │ ├── protocol_messages │ │ ├── __init__.py │ │ ├── layer.py │ │ ├── proto │ │ │ ├── __init__.py │ │ │ ├── e2e_pb2.py │ │ │ └── protocol_pb2.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── attributes │ │ │ ├── __init__.py │ │ │ ├── attributes_audio.py │ │ │ ├── attributes_contact.py │ │ │ ├── attributes_context_info.py │ │ │ ├── attributes_document.py │ │ │ ├── attributes_downloadablemedia.py │ │ │ ├── attributes_extendedtext.py │ │ │ ├── attributes_image.py │ │ │ ├── attributes_location.py │ │ │ ├── attributes_media.py │ │ │ ├── attributes_message.py │ │ │ ├── attributes_message_key.py │ │ │ ├── attributes_message_meta.py │ │ │ ├── attributes_protocol.py │ │ │ ├── attributes_sender_key_distribution_message.py │ │ │ ├── attributes_sticker.py │ │ │ ├── attributes_video.py │ │ │ └── converter.py │ │ │ ├── message.py │ │ │ ├── message_extendedtext.py │ │ │ ├── message_text.py │ │ │ ├── message_text_broadcast.py │ │ │ ├── proto.py │ │ │ ├── protomessage.py │ │ │ ├── test_message.py │ │ │ ├── test_message_text.py │ │ │ └── test_message_text_broadcast.py │ ├── protocol_notifications │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── notification.py │ │ │ ├── notification_picture.py │ │ │ ├── notification_picture_delete.py │ │ │ ├── notification_picture_set.py │ │ │ ├── notification_status.py │ │ │ ├── test_notification.py │ │ │ ├── test_notification_picture.py │ │ │ ├── test_notification_picture_delete.py │ │ │ ├── test_notification_picture_set.py │ │ │ └── test_notification_status.py │ ├── protocol_presence │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq_lastseen.py │ │ │ ├── iq_lastseen_result.py │ │ │ ├── presence.py │ │ │ ├── presence_available.py │ │ │ ├── presence_subscribe.py │ │ │ ├── presence_unavailable.py │ │ │ ├── presence_unsubscribe.py │ │ │ ├── test_presence.py │ │ │ ├── test_presence_available.py │ │ │ ├── test_presence_subscribe.py │ │ │ ├── test_presence_unavailable.py │ │ │ └── test_presence_unsubscribe.py │ ├── protocol_privacy │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ └── privacylist_iq.py │ ├── protocol_profiles │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ │ ├── __init__.py │ │ │ ├── iq_picture.py │ │ │ ├── iq_picture_get.py │ │ │ ├── iq_picture_get_result.py │ │ │ ├── iq_picture_set.py │ │ │ ├── iq_pictures_list.py │ │ │ ├── iq_privacy_get.py │ │ │ ├── iq_privacy_result.py │ │ │ ├── iq_privacy_set.py │ │ │ ├── iq_status_set.py │ │ │ ├── iq_statuses_get.py │ │ │ ├── iq_statuses_result.py │ │ │ ├── iq_unregister.py │ │ │ ├── test_iq_privacy_get.py │ │ │ ├── test_iq_privacy_result.py │ │ │ ├── test_iq_privacy_set.py │ │ │ ├── test_iq_status_set.py │ │ │ └── test_iq_unregister.py │ └── protocol_receipts │ │ ├── __init__.py │ │ ├── layer.py │ │ └── protocolentities │ │ ├── __init__.py │ │ ├── receipt.py │ │ ├── receipt_incoming.py │ │ ├── receipt_outgoing.py │ │ ├── test_receipt_incoming.py │ │ └── test_receipt_outgoing.py │ ├── profile │ ├── __init__.py │ └── profile.py │ ├── registration │ ├── __init__.py │ ├── coderequest.py │ ├── existsrequest.py │ └── regrequest.py │ ├── stacks │ ├── __init__.py │ └── yowstack.py │ └── structs │ ├── __init__.py │ ├── protocolentity.py │ └── protocoltreenode.py ├── modules ├── __init__.py ├── hiExample │ └── __init__.py ├── hihelp │ └── __init__.py └── misdatos │ └── __init__.py ├── run.py ├── start.sh ├── yowsapp_installer.sh ├── yowsapp_installer_osx.sh └── yowsup.egg-info ├── PKG-INFO ├── SOURCES.txt ├── dependency_links.txt ├── requires.txt └── top_level.txt /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .9 3 | __pycache__ 4 | 5 | build 6 | config.py 7 | libs/yowsup/ 8 | libs/yowsup.egg-info/ 9 | libs/build/ 10 | 11 | # modules 12 | modules/misdatos 13 | 14 | 15 | 16 | venv -------------------------------------------------------------------------------- /app/mac/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/app/mac/__init__.py -------------------------------------------------------------------------------- /app/mac/run.py: -------------------------------------------------------------------------------- 1 | import sys, logging, config 2 | 3 | from yowsup.layers.axolotl.props import PROP_IDENTITY_AUTOTRUST 4 | from yowsup.stacks import YowStackBuilder 5 | from yowsup.layers import YowLayerEvent 6 | from yowsup.layers.network import YowNetworkLayer 7 | 8 | from app.mac.layer import MacLayer 9 | 10 | # Uncomment to log 11 | logging.basicConfig(level=logging.DEBUG) 12 | 13 | # Config 14 | credentials = (config.credentials['phone'], config.credentials['password']) 15 | encryption = True 16 | 17 | 18 | class MacStack(object): 19 | def __init__(self): 20 | builder = YowStackBuilder() 21 | 22 | self.stack = builder\ 23 | .pushDefaultLayers()\ 24 | .push(MacLayer)\ 25 | .build() 26 | 27 | self.stack.setCredentials(credentials) 28 | self.stack.setProp(MacLayer.PROP_CONTACTS, list(config.contacts.keys())) 29 | self.stack.setProp(PROP_IDENTITY_AUTOTRUST, True) 30 | 31 | def start(self): 32 | print("[Whatsapp] Mac started\n") 33 | 34 | self.stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) 35 | 36 | try: 37 | self.stack.loop(timeout=0.5, discrete=0.5) 38 | except KeyboardInterrupt: 39 | print("\nYowsdown") 40 | sys.exit(0) 41 | 42 | def instance(): 43 | return MacStack() 44 | 45 | if __name__ == "__main__": 46 | c = MacStack() 47 | c.start() -------------------------------------------------------------------------------- /app/mac/signals.py: -------------------------------------------------------------------------------- 1 | from blinker import signal 2 | 3 | ''' 4 | Life cycle 5 | ''' 6 | 7 | initialized = signal('mac_initialized') 8 | 9 | 10 | ''' 11 | Messages 12 | ''' 13 | 14 | message_received = signal('message_received') # Plain message 15 | command_received = signal('command_received') # ! 16 | 17 | 18 | ''' 19 | Notifications 20 | ''' 21 | receipt = signal('message_receipted') 22 | ack = signal('message_ack') -------------------------------------------------------------------------------- /app/models/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/app/models/__init__.py -------------------------------------------------------------------------------- /app/models/receipt.py: -------------------------------------------------------------------------------- 1 | from app.utils import helper 2 | 3 | class Receipt(object): 4 | def __init__(self, message_entity): 5 | self.who = message_entity.getParticipant() 6 | self.conversation = message_entity.getFrom() 7 | self.timestamp = message_entity.timestamp 8 | self.message_entity = message_entity 9 | self.blue = message_entity.type == "read" 10 | 11 | """ 12 | Logs message node 13 | """ 14 | def log(self, deep=False): 15 | helper.log(self) 16 | if deep: 17 | helper.log(self.message_entity) -------------------------------------------------------------------------------- /app/receiver/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/app/receiver/__init__.py -------------------------------------------------------------------------------- /app/requirements.txt: -------------------------------------------------------------------------------- 1 | blinker -------------------------------------------------------------------------------- /app/utils/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/app/utils/__init__.py -------------------------------------------------------------------------------- /app/utils/downloader.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | # from yowsup.layers.protocol_media.mediadownloader import MediaDownloader 4 | from app.utils import helper 5 | from app.utils import media_decrypter 6 | 7 | """ 8 | Downloads & Decrypts 9 | Returns file path of the message attached in the message 10 | """ 11 | def get_file(message_entity): 12 | enc_path = download_enc(message_entity) 13 | out_file = decrypt_file(message_entity, enc_path) 14 | 15 | # Remove enc file 16 | try: 17 | os.remove(enc_path) 18 | except OSError: 19 | pass 20 | 21 | return out_file 22 | 23 | 24 | """ 25 | Downloads enc from url from message_entity and returns its path 26 | """ 27 | def download_enc(message_entity): 28 | url = message_entity.getMediaUrl() 29 | #return MediaDownloader().download(url.decode('ASCII')) 30 | 31 | 32 | """ 33 | Decrypts enc file and returns its path 34 | """ 35 | def decrypt_file(message_entity, enc_path): 36 | key = message_entity.getMediaKey() 37 | out = "" 38 | 39 | if helper.is_image_media(message_entity): 40 | out = os.path.splitext(enc_path)[0] + '.jpg' 41 | 42 | return media_decrypter.decrypt_file(enc_path, key, out) -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | find / -name 'axolotl.db' -exec rm -rf {} \; -------------------------------------------------------------------------------- /config_example.py: -------------------------------------------------------------------------------- 1 | credentials = dict( 2 | phone = 'YOUR_PHONE', 3 | password = 'YOUR_PASWWORD', 4 | ) 5 | 6 | contacts = { 7 | "CONTACT_PHONE": "CONTACT_NAME", 8 | "ANOTHER_CONTACT_PHONE": "ANOTHER_CONTACT_NAME", 9 | } -------------------------------------------------------------------------------- /libs/python-axolotl/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: '3.5' 3 | # command to install dependencies 4 | 5 | env: 6 | global: 7 | - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so 8 | - SEGFAULT_SIGNALS=all 9 | matrix: 10 | - TOXENV=py26 11 | - TOXENV=py27 12 | - TOXENV=py33 13 | - TOXENV=py34 14 | - TOXENV=py35 15 | before_install: 16 | - python --version 17 | - uname -a 18 | - lsb_release -a 19 | install: 20 | - pip install tox 21 | - virtualenv --version 22 | - easy_install --version 23 | - pip --version 24 | - tox --version 25 | # command to run tests 26 | script: 27 | - tox -v 28 | after_failure: 29 | - more .tox/log/* | cat 30 | - more .tox/*/log/* | cat 31 | before_cache: 32 | - rm -rf $HOME/.cache/pip/log 33 | cache: 34 | directories: 35 | - $HOME/.cache/pip 36 | branches: 37 | only: 38 | - master 39 | - develop 40 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __version__ = '0.1.39' 4 | __author__ = 'Tarek Galal' 5 | __email__ = 'tare2.galal@gmail.com' 6 | __license__ = 'GPLv3' 7 | __status__ = 'Production' 8 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/axolotladdress.py: -------------------------------------------------------------------------------- 1 | class AxolotlAddress(object): 2 | def __init__(self, name, deviceId): 3 | self.name = name 4 | self.deviceId = deviceId 5 | 6 | def getName(self): 7 | return self.name 8 | 9 | def getDeviceId(self): 10 | return self.deviceId 11 | 12 | def __str__(self): 13 | return "%s;%s" % (self.name, self.deviceId) 14 | 15 | def __eq__(self, other): 16 | if other is None: 17 | return False 18 | 19 | if other.__class__ != AxolotlAddress: 20 | return False 21 | 22 | return self.name == other.getName() and self.deviceId == other.getDeviceId() 23 | 24 | def __hash__(self): 25 | return hash(self.name) ^ self.deviceId 26 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/duplicatemessagexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class DuplicateMessageException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/ecc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/python-axolotl/axolotl/ecc/__init__.py -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/ecc/ec.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class ECPublicKey(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | KEY_SIZE = 33 10 | 11 | @abc.abstractmethod 12 | def serialize(self): 13 | pass 14 | 15 | @abc.abstractmethod 16 | def getType(self): 17 | pass 18 | 19 | 20 | class ECPrivateKey(object): 21 | __metaclass__ = abc.ABCMeta 22 | 23 | @abc.abstractmethod 24 | def serialize(self): 25 | pass 26 | 27 | @abc.abstractmethod 28 | def getType(self): 29 | pass 30 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/ecc/eckeypair.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class ECKeyPair(): 5 | def __init__(self, publicKey, privateKey): 6 | """ 7 | :type publicKey: ECPublicKey 8 | :type privateKey: ECPrivateKey 9 | """ 10 | self.publicKey = publicKey 11 | self.privateKey = privateKey 12 | 13 | def getPrivateKey(self): 14 | return self.privateKey 15 | 16 | def getPublicKey(self): 17 | return self.publicKey 18 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/ratchet/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/ratchet/senderchainkey.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import hashlib 4 | import hmac 5 | 6 | from .sendermessagekey import SenderMessageKey 7 | 8 | 9 | class SenderChainKey: 10 | MESSAGE_KEY_SEED = bytearray([0x01]) 11 | CHAIN_KEY_SEED = bytearray([0x02]) 12 | 13 | def __init__(self, iteration, chainKey): 14 | """ 15 | :type iteration: int 16 | :type chainKey: bytearray 17 | """ 18 | self.iteration = iteration 19 | self.chainKey = chainKey 20 | 21 | def getIteration(self): 22 | return self.iteration 23 | 24 | def getSenderMessageKey(self): 25 | return SenderMessageKey(self.iteration, self.getDerivative(self.__class__.MESSAGE_KEY_SEED, self.chainKey)) 26 | 27 | def getNext(self): 28 | return SenderChainKey(self.iteration + 1, self.getDerivative(self.__class__.CHAIN_KEY_SEED, self.chainKey)) 29 | 30 | def getSeed(self): 31 | return self.chainKey 32 | 33 | def getDerivative(self, seed, key): 34 | mac = hmac.new(bytes(key), bytes(seed), digestmod=hashlib.sha256) 35 | return mac.digest() 36 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/ratchet/sendermessagekey.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ...kdf.hkdfv3 import HKDFv3 4 | from ...util.byteutil import ByteUtil 5 | 6 | 7 | class SenderMessageKey: 8 | def __init__(self, iteration, seed): 9 | """ 10 | :type iteration: int 11 | :type seed: bytearray 12 | """ 13 | derivative = HKDFv3().deriveSecrets(seed, "WhisperGroup".encode(), 48) 14 | parts = ByteUtil.split(derivative, 16, 32) 15 | 16 | self.iteration = iteration 17 | self.seed = seed 18 | self.iv = parts[0] 19 | self.cipherKey = parts[1] 20 | 21 | def getIteration(self): 22 | return self.iteration 23 | 24 | def getIv(self): 25 | return self.iv 26 | 27 | def getCipherKey(self): 28 | return self.cipherKey 29 | 30 | def getSeed(self): 31 | return self.seed 32 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/senderkeyname.py: -------------------------------------------------------------------------------- 1 | class SenderKeyName(object): 2 | def __init__(self, groupId, senderAxolotlAddress): 3 | self.groupId = groupId 4 | self.sender = senderAxolotlAddress 5 | 6 | def getGroupId(self): 7 | return self.groupId 8 | 9 | def getSender(self): 10 | return self.sender 11 | 12 | def serialize(self): 13 | return "%s::%s::%s" % (self.groupId, self.sender.getName(), self.sender.getDeviceId()) 14 | 15 | def __eq__(self, other): 16 | if other is None: return False 17 | if other.__class__ != SenderKeyName: return False 18 | 19 | return self.groupId == other.getGroupId() and self.sender == other.getSender() 20 | 21 | def __hash__(self): 22 | return hash(self.groupId) ^ hash(self.sender) 23 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/state/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/groups/state/senderkeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class SenderKeyStore(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | @abc.abstractmethod 10 | def storeSenderKey(self, senderKeyId, senderKeyRecord): 11 | """ 12 | :type senderKeyId: str 13 | :type senderKeyRecord: SenderKeyRecord 14 | """ 15 | 16 | @abc.abstractmethod 17 | def loadSenderKey(self, senderKeyId): 18 | """ 19 | :type senderKeyId: str 20 | """ 21 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/identitykey.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .ecc.curve import Curve 4 | 5 | 6 | class IdentityKey: 7 | def __init__(self, ecPubKeyOrBytes, offset=None): 8 | if offset is None: 9 | self.publicKey = ecPubKeyOrBytes 10 | else: 11 | self.publicKey = Curve.decodePoint(bytearray(ecPubKeyOrBytes), offset) 12 | 13 | def getPublicKey(self): 14 | return self.publicKey 15 | 16 | def serialize(self): 17 | return self.publicKey.serialize() 18 | 19 | def get_fingerprint(self): 20 | raise Exception("IMPL ME") 21 | 22 | def __eq__(self, other): 23 | return self.publicKey == other.getPublicKey() 24 | 25 | def hashCode(self): 26 | raise Exception("IMPL ME") 27 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/identitykeypair.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .state.storageprotos_pb2 import IdentityKeyPairStructure 4 | from .identitykey import IdentityKey 5 | from .ecc.curve import Curve 6 | 7 | 8 | class IdentityKeyPair: 9 | def __init__(self, identityKeyPublicKey=None, ecPrivateKey=None, serialized=None): 10 | if serialized: 11 | structure = IdentityKeyPairStructure() 12 | structure.ParseFromString(serialized) 13 | self.publicKey = IdentityKey(bytearray(structure.publicKey), offset=0) 14 | self.privateKey = Curve.decodePrivatePoint(bytearray(structure.privateKey)) 15 | else: 16 | self.publicKey = identityKeyPublicKey 17 | self.privateKey = ecPrivateKey 18 | 19 | def getPublicKey(self): 20 | return self.publicKey 21 | 22 | def getPrivateKey(self): 23 | return self.privateKey 24 | 25 | def serialize(self): 26 | structure = IdentityKeyPairStructure() 27 | structure.publicKey = self.publicKey.serialize() 28 | structure.privateKey = self.privateKey.serialize() 29 | return structure.SerializeToString() 30 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/invalidkeyexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class InvalidKeyException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/invalidkeyidexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class InvalidKeyIdException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/invalidmessageexception.py: -------------------------------------------------------------------------------- 1 | # -*- cofing: utf-8 -*- 2 | 3 | 4 | class InvalidMessageException(Exception): 5 | def __init__(self, message, exceptions=None): 6 | if exceptions: 7 | message += str(exceptions[0]) 8 | super(InvalidMessageException, self).__init__(message) 9 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/invalidversionexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class InvalidVersionException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __author__ = 'tarek' 4 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/derivedmessagesecrets.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..util.byteutil import ByteUtil 4 | 5 | 6 | class DerivedMessageSecrets: 7 | SIZE = 80 8 | CIPHER_KEY_LENGTH = 32 9 | MAC_KEY_LENGTH = 32 10 | IV_LENGTH = 16 11 | 12 | def __init__(self, okm): 13 | keys = ByteUtil.split(okm, 14 | self.__class__.CIPHER_KEY_LENGTH, 15 | self.__class__.MAC_KEY_LENGTH, 16 | self.__class__.IV_LENGTH) 17 | self.cipherKey = keys[0] # AES 18 | self.macKey = keys[1] # sha256 19 | self.iv = keys[2] 20 | 21 | def getCipherKey(self): 22 | return self.cipherKey 23 | 24 | def getMacKey(self): 25 | return self.macKey 26 | 27 | def getIv(self): 28 | return self.iv 29 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/derivedrootsecrets.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..util.byteutil import ByteUtil 4 | 5 | 6 | class DerivedRootSecrets: 7 | SIZE = 64 8 | 9 | def __init__(self, okm): 10 | keys = ByteUtil.split(okm, 32, 32) 11 | self.rootKey = keys[0] 12 | self.chainKey = keys[1] 13 | 14 | def getRootKey(self): 15 | return self.rootKey 16 | 17 | def getChainKey(self): 18 | return self.chainKey 19 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/hkdfv2.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .hkdf import HKDF 4 | 5 | 6 | class HKDFv2(HKDF): 7 | def getIterationStartOffset(self): 8 | return 0 9 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/hkdfv3.py: -------------------------------------------------------------------------------- 1 | # -*- codsing: utf-8 -*- 2 | 3 | from .hkdf import HKDF 4 | 5 | 6 | class HKDFv3(HKDF): 7 | def getIterationStartOffset(self): 8 | return 1 9 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/kdf/messagekeys.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class MessageKeys: 5 | def __init__(self, cipherKey, macKey, iv, counter): 6 | self.cipherKey = cipherKey 7 | self.macKey = macKey 8 | self.iv = iv 9 | self.counter = counter 10 | 11 | def getCipherKey(self): 12 | return self.cipherKey 13 | 14 | def getMacKey(self): 15 | return self.macKey 16 | 17 | def getIv(self): 18 | return self.iv 19 | 20 | def getCounter(self): 21 | return self.counter 22 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/legacymessageexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class LegacyMessageException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/nosessionexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class NoSessionException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/protobuf/WhisperTextProtocol.proto: -------------------------------------------------------------------------------- 1 | package textsecure; 2 | 3 | option java_package = "org.whispersystems.libaxolotl.protocol"; 4 | option java_outer_classname = "WhisperProtos"; 5 | 6 | message WhisperMessage { 7 | optional bytes ratchetKey = 1; 8 | optional uint32 counter = 2; 9 | optional uint32 previousCounter = 3; 10 | optional bytes ciphertext = 4; 11 | } 12 | 13 | message PreKeyWhisperMessage { 14 | optional uint32 registrationId = 5; 15 | optional uint32 preKeyId = 1; 16 | optional uint32 signedPreKeyId = 6; 17 | optional bytes baseKey = 2; 18 | optional bytes identityKey = 3; 19 | optional bytes message = 4; // WhisperMessage 20 | } 21 | 22 | message KeyExchangeMessage { 23 | optional uint32 id = 1; 24 | optional bytes baseKey = 2; 25 | optional bytes ratchetKey = 3; 26 | optional bytes identityKey = 4; 27 | optional bytes baseKeySignature = 5; 28 | } 29 | 30 | message SenderKeyMessage { 31 | optional uint32 id = 1; 32 | optional uint32 iteration = 2; 33 | optional bytes ciphertext = 3; 34 | } 35 | 36 | message SenderKeyDistributionMessage { 37 | optional uint32 id = 1; 38 | optional uint32 iteration = 2; 39 | optional bytes chainKey = 3; 40 | optional bytes signingKey = 4; 41 | } -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/protocol/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __author__ = 'tarek' 4 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/protocol/ciphertextmessage.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class CiphertextMessage(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | UNSUPPORTED_VERSION = 1 10 | CURRENT_VERSION = 3 11 | 12 | WHISPER_TYPE = 2 13 | PREKEY_TYPE = 3 14 | SENDERKEY_TYPE = 4 15 | SENDERKEY_DISTRIBUTION_TYPE = 5 16 | 17 | # This should be the worst case (worse than V2). So not always accurate, but good enough for padding. 18 | ENCRYPTED_MESSAGE_OVERHEAD = 53 19 | 20 | @abc.abstractmethod 21 | def serialize(self): 22 | return 23 | 24 | @abc.abstractmethod 25 | def getType(self): 26 | return 27 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/ratchet/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/ratchet/rootkey.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..ecc.curve import Curve 4 | from ..kdf.derivedrootsecrets import DerivedRootSecrets 5 | from .chainkey import ChainKey 6 | 7 | 8 | class RootKey: 9 | def __init__(self, kdf, key): 10 | self.kdf = kdf 11 | self.key = key 12 | 13 | def getKeyBytes(self): 14 | return self.key 15 | 16 | def createChain(self, ECPublicKey_theirRatchetKey, ECKeyPair_ourRatchetKey): 17 | sharedSecret = Curve.calculateAgreement(ECPublicKey_theirRatchetKey, ECKeyPair_ourRatchetKey.getPrivateKey()) 18 | derivedSecretBytes = self.kdf.deriveSecrets(sharedSecret, 19 | bytearray("WhisperRatchet".encode()), 20 | DerivedRootSecrets.SIZE, 21 | salt=self.key) 22 | derivedSecrets = DerivedRootSecrets(derivedSecretBytes) 23 | newRootKey = RootKey(self.kdf, derivedSecrets.getRootKey()) 24 | newChainKey = ChainKey(self.kdf, derivedSecrets.getChainKey(), 0) 25 | return (newRootKey, newChainKey) 26 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/axolotlstore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | from .identitykeystore import IdentityKeyStore 6 | from .prekeystore import PreKeyStore 7 | from .sessionstore import SessionStore 8 | from .signedprekeystore import SignedPreKeyStore 9 | 10 | 11 | class AxolotlStore(IdentityKeyStore, PreKeyStore, SignedPreKeyStore, SessionStore): 12 | __metaclass__ = abc.ABCMeta 13 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/identitykeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class IdentityKeyStore(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | @abc.abstractmethod 10 | def getIdentityKeyPair(self): 11 | pass 12 | 13 | @abc.abstractmethod 14 | def getLocalRegistrationId(self): 15 | pass 16 | 17 | @abc.abstractmethod 18 | def saveIdentity(self, recepientId, identityKey): 19 | pass 20 | 21 | @abc.abstractmethod 22 | def isTrustedIdentity(self, recepientId, identityKey): 23 | pass 24 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/prekeybundle.py: -------------------------------------------------------------------------------- 1 | # -*- cosing: utf-8 -*- 2 | 3 | 4 | class PreKeyBundle: 5 | def __init__(self, registrationId, deviceId, preKeyId, ECPublicKey_preKeyPublic, 6 | signedPreKeyId, ECPublicKey_signedPreKeyPublic, signedPreKeySignature, 7 | identityKey): 8 | self.registrationId = registrationId 9 | self.deviceId = deviceId 10 | self.preKeyId = preKeyId 11 | self.preKeyPublic = ECPublicKey_preKeyPublic 12 | self.signedPreKeyId = signedPreKeyId 13 | self.signedPreKeyPublic = ECPublicKey_signedPreKeyPublic 14 | self.signedPreKeySignature = signedPreKeySignature 15 | self.identityKey = identityKey 16 | 17 | def getDeviceId(self): 18 | return self.deviceId 19 | 20 | def getPreKeyId(self): 21 | return self.preKeyId 22 | 23 | def getPreKey(self): 24 | return self.preKeyPublic 25 | 26 | def getSignedPreKeyId(self): 27 | return self.signedPreKeyId 28 | 29 | def getSignedPreKey(self): 30 | return self.signedPreKeyPublic 31 | 32 | def getSignedPreKeySignature(self): 33 | return self.signedPreKeySignature 34 | 35 | def getIdentityKey(self): 36 | return self.identityKey 37 | 38 | def getRegistrationId(self): 39 | return self.registrationId 40 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/prekeyrecord.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .storageprotos_pb2 import PreKeyRecordStructure 4 | from ..ecc.curve import Curve 5 | from ..ecc.eckeypair import ECKeyPair 6 | 7 | 8 | class PreKeyRecord: 9 | def __init__(self, _id=None, ecKeyPair=None, serialized=None): 10 | self.structure = PreKeyRecordStructure() 11 | if serialized: 12 | self.structure.ParseFromString(serialized) 13 | else: 14 | self.structure.id = _id 15 | self.structure.publicKey = ecKeyPair.getPublicKey().serialize() 16 | self.structure.privateKey = ecKeyPair.getPrivateKey().serialize() 17 | 18 | def getId(self): 19 | return self.structure.id 20 | 21 | def getKeyPair(self): 22 | publicKey = Curve.decodePoint(bytearray(self.structure.publicKey), 0) 23 | privateKey = Curve.decodePrivatePoint(bytearray(self.structure.privateKey)) 24 | return ECKeyPair(publicKey, privateKey) 25 | 26 | def serialize(self): 27 | return self.structure.SerializeToString() 28 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/prekeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class PreKeyStore(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | @abc.abstractmethod 10 | def loadPreKey(self, preKeyId): 11 | pass 12 | 13 | @abc.abstractmethod 14 | def storePreKey(self, preKeyId, preKeyRecord): 15 | pass 16 | 17 | @abc.abstractmethod 18 | def containsPreKey(self, preKeyId): 19 | pass 20 | 21 | @abc.abstractmethod 22 | def removePreKey(self, preKeyId): 23 | pass 24 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/sessionstore.py: -------------------------------------------------------------------------------- 1 | # -*- cosing: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class SessionStore(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | @abc.abstractmethod 10 | def loadSession(self, recepientId, deviceId): 11 | pass 12 | 13 | @abc.abstractmethod 14 | def getSubDeviceSessions(self, recepientId): 15 | pass 16 | 17 | @abc.abstractmethod 18 | def storeSession(self, recepientId, deviceId, sessionRecord): 19 | pass 20 | 21 | @abc.abstractmethod 22 | def containsSession(self, recepientId, deviceId): 23 | pass 24 | 25 | @abc.abstractmethod 26 | def deleteSession(self, recepientId, deviceId): 27 | pass 28 | 29 | @abc.abstractmethod 30 | def deleteAllSessions(self, recepientId): 31 | pass 32 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/signedprekeyrecord.py: -------------------------------------------------------------------------------- 1 | # -*- coding; utf-8 -*- 2 | 3 | from .storageprotos_pb2 import SignedPreKeyRecordStructure 4 | from ..ecc.curve import Curve 5 | from ..ecc.eckeypair import ECKeyPair 6 | 7 | 8 | class SignedPreKeyRecord: 9 | def __init__(self, _id=None, timestamp=None, ecKeyPair=None, signature=None, serialized=None): 10 | self.structure = SignedPreKeyRecordStructure() 11 | if serialized: 12 | self.structure.ParseFromString(serialized) 13 | else: 14 | self.structure.id = _id 15 | self.structure.publicKey = ecKeyPair.getPublicKey().serialize() 16 | self.structure.privateKey = ecKeyPair.getPrivateKey().serialize() 17 | self.structure.signature = signature 18 | self.structure.timestamp = timestamp 19 | 20 | def getId(self): 21 | return self.structure.id 22 | 23 | def getTimestamp(self): 24 | return self.structure.timestamp 25 | 26 | def getKeyPair(self): 27 | publicKey = Curve.decodePoint(bytearray(self.structure.publicKey), 0) 28 | privateKey = Curve.decodePrivatePoint(bytearray(self.structure.privateKey)) 29 | 30 | return ECKeyPair(publicKey, privateKey) 31 | 32 | def getSignature(self): 33 | return self.structure.signature 34 | 35 | def serialize(self): 36 | return self.structure.SerializeToString() 37 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/state/signedprekeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import abc 4 | 5 | 6 | class SignedPreKeyStore(object): 7 | __metaclass__ = abc.ABCMeta 8 | 9 | @abc.abstractmethod 10 | def loadSignedPreKey(self, signedPreKeyId): 11 | pass 12 | 13 | @abc.abstractmethod 14 | def loadSignedPreKeys(self): 15 | pass 16 | 17 | @abc.abstractmethod 18 | def storeSignedPreKey(self, signedPreKeyId, signedPreKeyRecord): 19 | pass 20 | 21 | @abc.abstractmethod 22 | def containsSignedPreKey(self, signedPreKeyId): 23 | pass 24 | 25 | @abc.abstractmethod 26 | def removeSignedPreKey(self, signedPreKeyId): 27 | pass 28 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/statekeyexchangeexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class StaleKeyExchangeException(Exception): 5 | pass 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/groups/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/groups/inmemorysenderkeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ...groups.state.senderkeystore import SenderKeyStore 4 | from ...groups.state.senderkeyrecord import SenderKeyRecord 5 | 6 | 7 | class InMemorySenderKeyStore(SenderKeyStore): 8 | def __init__(self): 9 | self.store = {} 10 | 11 | def storeSenderKey(self, senderKeyName, senderKeyRecord): 12 | self.store[senderKeyName] = senderKeyRecord 13 | 14 | def loadSenderKey(self, senderKeyName): 15 | if senderKeyName in self.store: 16 | return SenderKeyRecord(serialized=self.store[senderKeyName].serialize()) 17 | 18 | return SenderKeyRecord() 19 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/inmemoryidentitykeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..state.identitykeystore import IdentityKeyStore 4 | from ..ecc.curve import Curve 5 | from ..identitykey import IdentityKey 6 | from ..util.keyhelper import KeyHelper 7 | from ..identitykeypair import IdentityKeyPair 8 | 9 | 10 | class InMemoryIdentityKeyStore(IdentityKeyStore): 11 | def __init__(self): 12 | self.trustedKeys = {} 13 | identityKeyPairKeys = Curve.generateKeyPair() 14 | self.identityKeyPair = IdentityKeyPair(IdentityKey(identityKeyPairKeys.getPublicKey()), 15 | identityKeyPairKeys.getPrivateKey()) 16 | self.localRegistrationId = KeyHelper.generateRegistrationId() 17 | 18 | def getIdentityKeyPair(self): 19 | return self.identityKeyPair 20 | 21 | def getLocalRegistrationId(self): 22 | return self.localRegistrationId 23 | 24 | def saveIdentity(self, recepientId, identityKey): 25 | self.trustedKeys[recepientId] = identityKey 26 | 27 | def isTrustedIdentity(self, recepientId, identityKey): 28 | if recepientId not in self.trustedKeys: 29 | return True 30 | return self.trustedKeys[recepientId] == identityKey 31 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/inmemoryprekeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..state.prekeystore import PreKeyStore 4 | from ..state.prekeyrecord import PreKeyRecord 5 | from ..invalidkeyidexception import InvalidKeyIdException 6 | 7 | 8 | class InMemoryPreKeyStore(PreKeyStore): 9 | def __init__(self): 10 | self.store = {} 11 | 12 | def loadPreKey(self, preKeyId): 13 | if preKeyId not in self.store: 14 | raise InvalidKeyIdException("No such prekeyRecord!") 15 | 16 | return PreKeyRecord(serialized=self.store[preKeyId]) 17 | 18 | def storePreKey(self, preKeyId, preKeyRecord): 19 | self.store[preKeyId] = preKeyRecord.serialize() 20 | 21 | def containsPreKey(self, preKeyId): 22 | return preKeyId in self.store 23 | 24 | def removePreKey(self, preKeyId): 25 | if preKeyId in self.store: 26 | del self.store[preKeyId] 27 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/inmemorysessionstore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..state.sessionstore import SessionStore 4 | from ..state.sessionrecord import SessionRecord 5 | 6 | 7 | class InMemorySessionStore(SessionStore): 8 | def __init__(self): 9 | self.sessions = {} 10 | 11 | def loadSession(self, recepientId, deviceId): 12 | if self.containsSession(recepientId, deviceId): 13 | return SessionRecord(serialized=self.sessions[(recepientId, deviceId)]) 14 | else: 15 | return SessionRecord() 16 | 17 | def getSubDeviceSessions(self, recepientId): 18 | deviceIds = [] 19 | for k in self.sessions.keys(): 20 | if k[0] == recepientId: 21 | deviceIds.append(k[1]) 22 | 23 | return deviceIds 24 | 25 | def storeSession(self, recepientId, deviceId, sessionRecord): 26 | self.sessions[(recepientId, deviceId)] = sessionRecord.serialize() 27 | 28 | def containsSession(self, recepientId, deviceId): 29 | return (recepientId, deviceId) in self.sessions 30 | 31 | def deleteSession(self, recepientId, deviceId): 32 | del self.sessions[(recepientId, deviceId)] 33 | 34 | def deleteAllSessions(self, recepientId): 35 | for k in self.sessions.keys(): 36 | if k[0] == recepientId: 37 | del self.sessions[k] 38 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/inmemorysignedprekeystore.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from ..state.signedprekeystore import SignedPreKeyStore 4 | from ..state.signedprekeyrecord import SignedPreKeyRecord 5 | from ..invalidkeyidexception import InvalidKeyIdException 6 | 7 | 8 | class InMemorySignedPreKeyStore(SignedPreKeyStore): 9 | def __init__(self): 10 | self.store = {} 11 | 12 | def loadSignedPreKey(self, signedPreKeyId): 13 | if signedPreKeyId not in self.store: 14 | raise InvalidKeyIdException("No such signedprekeyrecord! %s " % signedPreKeyId) 15 | 16 | return SignedPreKeyRecord(serialized=self.store[signedPreKeyId]) 17 | 18 | def loadSignedPreKeys(self): 19 | results = [] 20 | for serialized in self.store.values(): 21 | results.append(SignedPreKeyRecord(serialized=serialized)) 22 | 23 | return results 24 | 25 | def storeSignedPreKey(self, signedPreKeyId, signedPreKeyRecord): 26 | self.store[signedPreKeyId] = signedPreKeyRecord.serialize() 27 | 28 | def containsSignedPreKey(self, signedPreKeyId): 29 | return signedPreKeyId in self.store 30 | 31 | def removeSignedPreKey(self, signedPreKeyId): 32 | del self.store[signedPreKeyId] 33 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/kdf/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- cosing: utf-8 -*- 2 | 3 | __author__ = 'tarek' 4 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/ratchet/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __author__ = 'tarek' 4 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/util/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | __author__ = 'tarek' 4 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/tests/util/test_byteutil.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import unittest 4 | 5 | from ...util.byteutil import ByteUtil 6 | # from ...util.hexutil import HexUtil 7 | 8 | 9 | class ByteUtilTest(unittest.TestCase): 10 | def test_split(self): 11 | # okm = HexUtil.decodeHex('02a9aa6c7dbd64f9d3aa92f92a277bf54609dadf0b00' 12 | # '828acfc61e3c724b84a7bfbe5efb603030526742e3ee' 13 | # '89c7024e884e440f1ff376bb2317b2d64deb7c8322f4' 14 | # 'c5015d9d895849411ba1d793a827') 15 | 16 | data = [i for i in range(0, 80)] 17 | a_data = [i for i in range(0, 32)] 18 | b_data = [i for i in range(32, 64)] 19 | c_data = [i for i in range(64, 80)] 20 | 21 | a, b, c = ByteUtil.split(data, 32, 32, 16) 22 | 23 | self.assertEqual(a, a_data) 24 | self.assertEqual(b, b_data) 25 | self.assertEqual(c, c_data) 26 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/untrustedidentityexception.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | class UntrustedIdentityException(Exception): 4 | def __init__(self, name, identityKey): 5 | self.name = name 6 | self.identityKey = identityKey 7 | 8 | def getName(self): 9 | return self.name 10 | 11 | def getIdentityKey(self): 12 | return self.identityKey 13 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/util/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/util/hexutil.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import codecs 4 | import sys 5 | 6 | decode_hex = codecs.getdecoder("hex_codec") 7 | 8 | 9 | class HexUtil: 10 | @staticmethod 11 | def decodeHex(hexString): 12 | hexString = hexString.encode() if type(hexString) is str else hexString 13 | result = decode_hex(hexString)[0] 14 | if sys.version_info >= (3, 0): 15 | result = result.decode('latin-1') 16 | return result 17 | -------------------------------------------------------------------------------- /libs/python-axolotl/axolotl/util/medium.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | 4 | class Medium: 5 | MAX_VALUE = 0xFFFFFF 6 | -------------------------------------------------------------------------------- /libs/python-axolotl/tox.ini: -------------------------------------------------------------------------------- 1 | # Tox (http://tox.testrun.org/) is a tool for running tests 2 | # in multiple virtualenvs. This configuration file will run the 3 | # test suite on all supported python versions. To use it, "pip install tox" 4 | # and then run "tox" from this directory. 5 | 6 | [tox] 7 | skip_missing_interpreters = true 8 | envlist = py26, py27, py32, py33, py34, py35, py36 9 | 10 | [testenv] 11 | commands = nosetests axolotl.tests 12 | deps = 13 | nose 14 | protobuf==3.0.0b2 15 | pycrypto 16 | python-axolotl-curve25519 17 | -------------------------------------------------------------------------------- /libs/yowsup.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.1 2 | Name: yowsup 3 | Version: 3.2.3 4 | Summary: The WhatsApp lib 5 | Home-page: http://github.com/tgalal/yowsup/ 6 | Author: Tarek Galal 7 | Author-email: tare2.galal@gmail.com 8 | License: GPL-3+ 9 | Description: UNKNOWN 10 | Platform: any 11 | Classifier: Programming Language :: Python 12 | Classifier: Development Status :: 4 - Beta 13 | Classifier: Natural Language :: English 14 | Classifier: Intended Audience :: Developers 15 | Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) 16 | Classifier: Operating System :: OS Independent 17 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 18 | -------------------------------------------------------------------------------- /libs/yowsup.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | yowsup.egg-info/PKG-INFO 2 | yowsup.egg-info/SOURCES.txt 3 | yowsup.egg-info/dependency_links.txt 4 | yowsup.egg-info/requires.txt 5 | yowsup.egg-info/top_level.txt -------------------------------------------------------------------------------- /libs/yowsup.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/yowsup.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | consonance==0.1.3-1 2 | argparse 3 | python-axolotl==0.2.2 4 | six==1.10 5 | appdirs 6 | protobuf>=3.6.0 7 | -------------------------------------------------------------------------------- /libs/yowsup.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libs/yowsup/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.class 3 | todo 4 | *.egg-info 5 | tp 6 | tests 7 | dist 8 | build 9 | .idea 10 | .tox 11 | -------------------------------------------------------------------------------- /libs/yowsup/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: '3.6' 3 | # command to install dependencies 4 | 5 | env: 6 | global: 7 | - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so 8 | - SEGFAULT_SIGNALS=all 9 | matrix: 10 | - TOXENV=py27 11 | - TOXENV=py33 12 | - TOXENV=py34 13 | - TOXENV=py35 14 | - TOXENV=py36 15 | - TOXENV=py37 16 | before_install: 17 | - python --version 18 | - uname -a 19 | - lsb_release -a 20 | install: 21 | - pip install tox 22 | - virtualenv --version 23 | - easy_install --version 24 | - pip --version 25 | - tox --version 26 | # command to run tests 27 | script: 28 | - tox -v 29 | after_failure: 30 | - more .tox/log/* | cat 31 | - more .tox/*/log/* | cat 32 | before_cache: 33 | - rm -rf $HOME/.cache/pip/log 34 | cache: 35 | directories: 36 | - $HOME/.cache/pip 37 | branches: 38 | only: 39 | - master 40 | -------------------------------------------------------------------------------- /libs/yowsup/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include yowsup/common/mime.types 2 | -------------------------------------------------------------------------------- /libs/yowsup/tox.ini: -------------------------------------------------------------------------------- 1 | # Tox (http://tox.testrun.org/) is a tool for running tests 2 | # in multiple virtualenvs. This configuration file will run the 3 | # test suite on all supported python versions. To use it, "pip install tox" 4 | # and then run "tox" from this directory. 5 | 6 | [tox] 7 | skip_missing_interpreters = true 8 | envlist = py27, py32, py33, py34, py35, py36, py37 9 | 10 | [testenv] 11 | commands = nosetests --exclude demos yowsup 12 | deps = 13 | py26: importlib 14 | nose 15 | python-dateutil 16 | appdirs 17 | python-axolotl==0.2.2 18 | protobuf>=3.6.0 19 | consonance==0.1.3-1 20 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | __version__ = "3.2.3" 4 | __author__ = "Tarek Galal" 5 | 6 | logger = logging.getLogger(__name__) 7 | 8 | # create console handler and set level to debug 9 | ch = logging.StreamHandler() 10 | ch.setLevel(logging.DEBUG) 11 | 12 | # create formatter 13 | formatter = logging.Formatter('%(levelname).1s %(asctime)s %(name)s - %(message)s') 14 | 15 | # add formatter to ch 16 | ch.setFormatter(formatter) 17 | 18 | # add ch to logger 19 | logger.addHandler(ch) 20 | 21 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/axolotl/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger(__name__) 4 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/axolotl/exceptions.py: -------------------------------------------------------------------------------- 1 | class NoSessionException(Exception): 2 | pass 3 | 4 | 5 | class UntrustedIdentityException(Exception): 6 | def __init__(self, name, identity_key): 7 | self._name = name 8 | self._identity_key = identity_key 9 | 10 | @property 11 | def name(self): 12 | return self._name 13 | 14 | @property 15 | def identity_key(self): 16 | return self._identity_key 17 | 18 | 19 | class InvalidMessageException(Exception): 20 | pass 21 | 22 | 23 | class InvalidKeyIdException(Exception): 24 | pass 25 | 26 | 27 | class DuplicateMessageException(Exception): 28 | pass 29 | 30 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/axolotl/factory.py: -------------------------------------------------------------------------------- 1 | from yowsup.axolotl.manager import AxolotlManager 2 | from yowsup.common.tools import StorageTools 3 | from yowsup.axolotl.store.sqlite.liteaxolotlstore import LiteAxolotlStore 4 | import logging 5 | 6 | logger = logging.getLogger(__name__) 7 | 8 | 9 | class AxolotlManagerFactory(object): 10 | DB = "axolotl.db" 11 | 12 | def get_manager(self, profile_name, username): 13 | logger.debug("get_manager(profile_name=%s, username=%s)" % (profile_name, username)) 14 | dbpath = StorageTools.constructPath(profile_name, self.DB) 15 | store = LiteAxolotlStore(dbpath) 16 | return AxolotlManager(store, username) 17 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/axolotl/store/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/axolotl/store/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/axolotl/store/sqlite/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/axolotl/store/sqlite/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/common/__init__.py: -------------------------------------------------------------------------------- 1 | from .constants import YowConstants -------------------------------------------------------------------------------- /libs/yowsup/yowsup/common/constants.py: -------------------------------------------------------------------------------- 1 | class YowConstants: 2 | DOMAIN = "s.whatsapp.net" 3 | ENDPOINTS = ( 4 | ("e1.whatsapp.net", 443), 5 | ("e2.whatsapp.net", 443), 6 | ("e3.whatsapp.net", 443), 7 | ("e4.whatsapp.net", 443), 8 | ("e5.whatsapp.net", 443), 9 | ("e6.whatsapp.net", 443), 10 | ("e7.whatsapp.net", 443), 11 | ("e8.whatsapp.net", 443), 12 | ("e9.whatsapp.net", 443), 13 | ("e10.whatsapp.net", 443), 14 | ("e11.whatsapp.net", 443), 15 | ("e12.whatsapp.net", 443), 16 | ("e13.whatsapp.net", 443), 17 | ("e14.whatsapp.net", 443), 18 | ("e15.whatsapp.net", 443), 19 | ("e16.whatsapp.net", 443), 20 | ) 21 | 22 | WHATSAPP_SERVER = "s.whatsapp.net" 23 | WHATSAPP_GROUP_SERVER = "g.us" 24 | 25 | YOWSUP = "yowsup" 26 | 27 | PREVIEW_WIDTH = 64 28 | PREVIEW_HEIGHT = 64 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/common/http/__init__.py: -------------------------------------------------------------------------------- 1 | from .httpproxy import HttpProxy 2 | from .warequest import WARequest 3 | from .waresponseparser import JSONResponseParser -------------------------------------------------------------------------------- /libs/yowsup/yowsup/common/http/test_warequest.py: -------------------------------------------------------------------------------- 1 | from yowsup.common.http.warequest import WARequest -------------------------------------------------------------------------------- /libs/yowsup/yowsup/common/mime.types: -------------------------------------------------------------------------------- 1 | audio/3gpp 3gpp 2 | audio/aac aac 3 | audio/aiff aif 4 | audio/amr amr 5 | audio/mp4 m4a 6 | audio/mpeg mp3 mp2 mpga mpega 7 | audio/ogg oga ogg opus spx 8 | audio/qcelp qcp 9 | audio/wav wav 10 | audio/webm webm 11 | audio/x-caf caf 12 | audio/x-ms-wma wma 13 | audio/ogg ogg 14 | image/gif gif 15 | image/jpeg jpe jpg jpeg 16 | image/png png 17 | video/3gpp 3gp 18 | video/avi avi 19 | video/mp4 mp4 20 | video/mpeg m1v mpeg mpa mpg mpe 21 | video/quicktime mov qt 22 | video/x-flv flv 23 | video/x-ms-asf asf asx 24 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/config/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/base/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/config/base/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/base/serialize.py: -------------------------------------------------------------------------------- 1 | class ConfigSerialize(object): 2 | 3 | def __init__(self, transforms): 4 | self._transforms = transforms 5 | 6 | def serialize(self, config): 7 | """ 8 | :param config: 9 | :type config: yowsup.config.base.config.Config 10 | :return: 11 | :rtype: bytes 12 | """ 13 | for transform in self._transforms: 14 | config = transform.transform(config) 15 | return config 16 | 17 | def deserialize(self, data): 18 | """ 19 | :type cls: type 20 | :param data: 21 | :type data: bytes 22 | :return: 23 | :rtype: yowsup.config.base.config.Config 24 | """ 25 | for transform in self._transforms[::-1]: 26 | data = transform.reverse(data) 27 | return data 28 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/base/transform.py: -------------------------------------------------------------------------------- 1 | class ConfigTransform(object): 2 | def transform(self, config): 3 | """ 4 | :param config: 5 | :type config: yowsup.config.base.config.Config 6 | :return: dict 7 | :rtype: 8 | """ 9 | 10 | def reverse(self, data): 11 | """ 12 | :param data: 13 | :type data: 14 | :return: 15 | :rtype: yowsup.config.base.config.Config 16 | """ 17 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/config/transforms/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/config_dict.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | 3 | 4 | class ConfigDictTransform(ConfigTransform): 5 | def __init__(self, cls): 6 | self._cls = cls 7 | 8 | def transform(self, config): 9 | """ 10 | :param config: 11 | :type config: dict 12 | :return: 13 | :rtype: yowsup.config.config.Config 14 | """ 15 | out = {} 16 | for prop in vars(config): 17 | out[prop] = getattr(config, prop) 18 | return out 19 | 20 | def reverse(self, data): 21 | """ 22 | :param data: 23 | :type data: yowsup,config.config.Config 24 | :return: 25 | :rtype: dict 26 | """ 27 | return self._cls(**data) 28 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/dict_json.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | import json 3 | 4 | 5 | class DictJsonTransform(ConfigTransform): 6 | def transform(self, data): 7 | return json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')) 8 | 9 | def reverse(self, data): 10 | return json.loads(data) 11 | 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/dict_keyval.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | 3 | 4 | class DictKeyValTransform(ConfigTransform): 5 | def transform(self, data): 6 | """ 7 | :param data: 8 | :type data: dict 9 | :return: 10 | :rtype: 11 | """ 12 | out=[] 13 | keys = sorted(data.keys()) 14 | for k in keys: 15 | out.append("%s=%s" % (k, data[k])) 16 | return "\n".join(out) 17 | 18 | def reverse(self, data): 19 | out = {} 20 | for l in data.split('\n'): 21 | line = l.strip() 22 | if len(line) and line[0] not in ('#',';'): 23 | prep = line.split('#', 1)[0].split(';', 1)[0].split('=', 1) 24 | varname = prep[0].strip() 25 | val = prep[1].strip() 26 | out[varname.replace('-', '_')] = val 27 | return out 28 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/filter.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | 3 | 4 | class FilterTransform(ConfigTransform): 5 | 6 | def __init__(self, transform_filter=None, reverse_filter=None): 7 | """ 8 | :param transform_filter: 9 | :type transform_filter: function | None 10 | :param reverse_filter: 11 | :type reverse_filter: function | None 12 | """ 13 | self._transform_filter = transform_filter # type: function | None 14 | self._reverse_filter = reverse_filter # type: function | None 15 | 16 | def transform(self, data): 17 | if self._transform_filter is not None: 18 | out = {} 19 | for key, val in data.items(): 20 | if self._transform_filter(key, val): 21 | out[key] = val 22 | return out 23 | return data 24 | 25 | def reverse(self, data): 26 | if self._reverse_filter is not None: 27 | out = {} 28 | for key, val in data.items(): 29 | if self._reverse_filter(key, val): 30 | out[key] = val 31 | return out 32 | return data 33 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/map.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | 3 | 4 | class MapTransform(ConfigTransform): 5 | 6 | def __init__(self, transform_map=None, reverse_map=None): 7 | """ 8 | :param transform_map: 9 | :type transform_map: function | None 10 | :param reverse_map: 11 | :type reverse_map: function | None 12 | """ 13 | self._transform_map = transform_map # type: function | None 14 | self._reverse_map = reverse_map # type: function | None 15 | 16 | def transform(self, data): 17 | if self._transform_map is not None: 18 | out = {} 19 | for key, val in data.items(): 20 | key, val = self._transform_map(key, val) 21 | out[key] = val 22 | return out 23 | return data 24 | 25 | def reverse(self, data): 26 | if self._reverse_map is not None: 27 | out = {} 28 | for key, val in data.items(): 29 | key, val = self._reverse_map(key, val) 30 | out[key] = val 31 | return out 32 | return data 33 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/meta.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | from yowsup.config.transforms.props import PropsTransform 3 | 4 | 5 | class MetaPropsTransform(ConfigTransform): 6 | META_FORMAT = "__%s__" 7 | 8 | def __init__(self, meta_props=None, meta_format=META_FORMAT): 9 | meta_props = meta_props or () 10 | meta_format = meta_format 11 | transform_map = {} 12 | reverse_map = {} 13 | for prop in meta_props: 14 | formatted = meta_format % prop 15 | transform_map[prop] = lambda key, val, formatted=formatted: (formatted, val) 16 | reverse_map[formatted] = lambda key, val, prop=prop: (prop, val) 17 | 18 | self._props_transform = PropsTransform(transform_map=transform_map, reverse_map=reverse_map) 19 | 20 | def transform(self, data): 21 | return self._props_transform.transform(data) 22 | 23 | def reverse(self, data): 24 | return self._props_transform.reverse(data) 25 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/props.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.base.transform import ConfigTransform 2 | import types 3 | 4 | 5 | class PropsTransform(ConfigTransform): 6 | def __init__(self, transform_map=None, reverse_map=None): 7 | self._transform_map = transform_map or {} 8 | self._reverse_map = reverse_map or {} 9 | 10 | def transform(self, data): 11 | """ 12 | :param data: 13 | :type data: dict 14 | :return: 15 | :rtype: dict 16 | """ 17 | out = {} 18 | for key, val in data.items(): 19 | if key in self._transform_map: 20 | target = self._transform_map[key] 21 | key, val = target(key, val) if type(target) == types.FunctionType else (key, target) 22 | 23 | out[key] = val 24 | 25 | 26 | return out 27 | 28 | def reverse(self, data): 29 | transformed_dict = {} 30 | 31 | for key, val in data.items(): 32 | if key in self._reverse_map: 33 | target = self._reverse_map[key] 34 | key, val = target(key, val) if type(target) == types.FunctionType else (key, target) 35 | 36 | transformed_dict[key] = val 37 | 38 | return transformed_dict 39 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/transforms/serialize.py: -------------------------------------------------------------------------------- 1 | from yowsup.config.transforms.props import PropsTransform 2 | 3 | 4 | class SerializeTransform(PropsTransform): 5 | 6 | def __init__(self, serialize_map): 7 | """ 8 | { 9 | "keystore": serializer 10 | } 11 | :param serialize_map: 12 | :type serialize_map: 13 | """ 14 | transform_map = {} 15 | reverse_map = {} 16 | for key, val in serialize_map: 17 | transform_map[key] = lambda key, val: key, serialize_map[key].serialize(val) 18 | reverse_map[key] = lambda key, val: key, serialize_map[key].deserialize(val) 19 | 20 | super(SerializeTransform, self).__init__(transform_map=transform_map, reverse_map=reverse_map) 21 | 22 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/config/v1/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/config/v1/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/demos/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/cli/__init__.py: -------------------------------------------------------------------------------- 1 | from .stack import YowsupCliStack 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/cli/stack.py: -------------------------------------------------------------------------------- 1 | from yowsup.stacks import YowStackBuilder 2 | from .layer import YowsupCliLayer 3 | from yowsup.layers import YowLayerEvent 4 | from yowsup.layers.axolotl.props import PROP_IDENTITY_AUTOTRUST 5 | import sys 6 | 7 | 8 | class YowsupCliStack(object): 9 | def __init__(self, profile): 10 | stackBuilder = YowStackBuilder() 11 | 12 | self._stack = stackBuilder\ 13 | .pushDefaultLayers()\ 14 | .push(YowsupCliLayer)\ 15 | .build() 16 | 17 | self._stack.setProfile(profile) 18 | self._stack.setProp(PROP_IDENTITY_AUTOTRUST, True) 19 | 20 | def set_prop(self, prop, val): 21 | self._stack.setProp(prop, val) 22 | 23 | def start(self): 24 | print("Yowsup Cli client\n==================\nType /help for available commands\n") 25 | self._stack.broadcastEvent(YowLayerEvent(YowsupCliLayer.EVENT_START)) 26 | 27 | try: 28 | self._stack.loop() 29 | except KeyboardInterrupt: 30 | print("\nYowsdown") 31 | sys.exit(0) 32 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/common/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/demos/common/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/contacts/__init__.py: -------------------------------------------------------------------------------- 1 | from .stack import YowsupSyncStack 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/contacts/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.interface import YowInterfaceLayer, ProtocolEntityCallback 2 | from yowsup.layers.protocol_contacts.protocolentities import GetSyncIqProtocolEntity, ResultSyncIqProtocolEntity 3 | from yowsup.layers.protocol_iq.protocolentities import ErrorIqProtocolEntity 4 | import threading 5 | import logging 6 | logger = logging.getLogger(__name__) 7 | 8 | class SyncLayer(YowInterfaceLayer): 9 | 10 | PROP_CONTACTS = "org.openwhatsapp.yowsup.prop.syncdemo.contacts" 11 | 12 | def __init__(self): 13 | super(SyncLayer, self).__init__() 14 | 15 | #call back function when there is a successful connection to whatsapp server 16 | @ProtocolEntityCallback("success") 17 | def onSuccess(self, successProtocolEntity): 18 | contacts= self.getProp(self.__class__.PROP_CONTACTS, []) 19 | contactEntity = GetSyncIqProtocolEntity(contacts) 20 | self._sendIq(contactEntity, self.onGetSyncResult, self.onGetSyncError) 21 | 22 | def onGetSyncResult(self, resultSyncIqProtocolEntity, originalIqProtocolEntity): 23 | print(resultSyncIqProtocolEntity) 24 | raise KeyboardInterrupt() 25 | 26 | def onGetSyncError(self, errorSyncIqProtocolEntity, originalIqProtocolEntity): 27 | print(errorSyncIqProtocolEntity) 28 | raise KeyboardInterrupt() 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/contacts/stack.py: -------------------------------------------------------------------------------- 1 | from .layer import SyncLayer 2 | 3 | from yowsup.stacks import YowStackBuilder 4 | from yowsup.layers import YowLayerEvent 5 | from yowsup.layers.auth import YowAuthenticationProtocolLayer 6 | from yowsup.layers.network import YowNetworkLayer 7 | 8 | 9 | class YowsupSyncStack(object): 10 | def __init__(self, profile, contacts): 11 | """ 12 | :param profile: 13 | :param contacts: list of [jid ] 14 | :return: 15 | """ 16 | stackBuilder = YowStackBuilder() 17 | 18 | self._stack = stackBuilder \ 19 | .pushDefaultLayers() \ 20 | .push(SyncLayer) \ 21 | .build() 22 | 23 | self._stack.setProp(SyncLayer.PROP_CONTACTS, contacts) 24 | self._stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True) 25 | self._stack.setProfile(profile) 26 | 27 | def set_prop(self, key, val): 28 | self._stack.setProp(key, val) 29 | 30 | def start(self): 31 | self._stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) 32 | self._stack.loop() 33 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/echoclient/__init__.py: -------------------------------------------------------------------------------- 1 | from .stack import YowsupEchoStack -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/echoclient/stack.py: -------------------------------------------------------------------------------- 1 | from yowsup.stacks import YowStackBuilder 2 | from .layer import EchoLayer 3 | from yowsup.layers import YowLayerEvent 4 | from yowsup.layers.network import YowNetworkLayer 5 | 6 | 7 | class YowsupEchoStack(object): 8 | def __init__(self, profile): 9 | stackBuilder = YowStackBuilder() 10 | 11 | self._stack = stackBuilder\ 12 | .pushDefaultLayers()\ 13 | .push(EchoLayer)\ 14 | .build() 15 | 16 | self._stack.setProfile(profile) 17 | 18 | def set_prop(self, key, val): 19 | self._stack.setProp(key, val) 20 | 21 | def start(self): 22 | self._stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) 23 | self._stack.loop() 24 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/mediasink/__init__.py: -------------------------------------------------------------------------------- 1 | from .stack import MediaSinkStack -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/mediasink/stack.py: -------------------------------------------------------------------------------- 1 | from yowsup.stacks import YowStackBuilder 2 | from .layer import MediaSinkLayer 3 | from yowsup.layers import YowLayerEvent 4 | from yowsup.layers.network import YowNetworkLayer 5 | 6 | 7 | class MediaSinkStack(object): 8 | def __init__(self, profile, storage_dir=None): 9 | stackBuilder = YowStackBuilder() 10 | 11 | self._stack = stackBuilder\ 12 | .pushDefaultLayers()\ 13 | .push(MediaSinkLayer)\ 14 | .build() 15 | self._stack.setProp(MediaSinkLayer.PROP_STORAGE_DIR, storage_dir) 16 | self._stack.setProfile(profile) 17 | 18 | def set_prop(self, key, val): 19 | self._stack.setProp(key, val) 20 | 21 | def start(self): 22 | self._stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) 23 | self._stack.loop() 24 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/sendclient/__init__.py: -------------------------------------------------------------------------------- 1 | from .stack import YowsupSendStack -------------------------------------------------------------------------------- /libs/yowsup/yowsup/demos/sendclient/stack.py: -------------------------------------------------------------------------------- 1 | from yowsup.stacks import YowStackBuilder 2 | from .layer import SendLayer 3 | from yowsup.layers import YowLayerEvent 4 | from yowsup.layers.auth import YowAuthenticationProtocolLayer 5 | from yowsup.layers.network import YowNetworkLayer 6 | 7 | 8 | class YowsupSendStack(object): 9 | def __init__(self, profile, messages): 10 | """ 11 | :param profile: 12 | :param messages: list of (jid, message) tuples 13 | :return: 14 | """ 15 | stackBuilder = YowStackBuilder() 16 | 17 | self._stack = stackBuilder\ 18 | .pushDefaultLayers()\ 19 | .push(SendLayer)\ 20 | .build() 21 | 22 | self._stack.setProp(SendLayer.PROP_MESSAGES, messages) 23 | self._stack.setProp(YowAuthenticationProtocolLayer.PROP_PASSIVE, True) 24 | self._stack.setProfile(profile) 25 | 26 | def set_prop(self, key, val): 27 | self._stack.setProp(key, val) 28 | 29 | def start(self): 30 | self._stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT)) 31 | self._stack.loop() 32 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/env/__init__.py: -------------------------------------------------------------------------------- 1 | from .env import YowsupEnv 2 | from .env_android import AndroidYowsupEnv 3 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer_authentication import YowAuthenticationProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/layer_interface_authentication.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayerInterface 2 | 3 | class YowAuthenticationProtocolLayerInterface(YowLayerInterface): 4 | def setCredentials(self, phone, keypair): 5 | self._layer.setCredentials((phone, keypair)) 6 | 7 | def getUsername(self, full = False): 8 | return self._layer.getUsername(full) 9 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .auth import AuthProtocolEntity 2 | from .challenge import ChallengeProtocolEntity 3 | from .response import ResponseProtocolEntity 4 | from .stream_features import StreamFeaturesProtocolEntity 5 | from .success import SuccessProtocolEntity 6 | from .failure import FailureProtocolEntity 7 | from .stream_error import StreamErrorProtocolEntity 8 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/auth.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class AuthProtocolEntity(ProtocolEntity): 3 | def __init__(self, user, mechanism = "WAUTH-2", passive = False, nonce = None): 4 | super(AuthProtocolEntity, self).__init__("auth") 5 | self.user = user 6 | self.mechanism = mechanism 7 | self.passive = passive 8 | self.nonce = nonce 9 | 10 | def toProtocolTreeNode(self): 11 | attributes = { 12 | "user" : self.user, 13 | "mechanism" : self.mechanism, 14 | "passive" : "true" if self.passive else "false" 15 | } 16 | return self._createProtocolTreeNode(attributes, children = None, data = self.nonce) 17 | 18 | @staticmethod 19 | def fromProtocolTreeNode(node): 20 | return AuthProtocolEntity( 21 | node.getAttributeValue("user"), 22 | node.getAttributeValue("mechanism"), 23 | node.getAttributeValue("passive") != "false", 24 | node.getData() 25 | ) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/challenge.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class ChallengeProtocolEntity(ProtocolEntity): 3 | def __init__(self, nonce): 4 | super(ChallengeProtocolEntity, self).__init__("challenge") 5 | self.nonce = nonce 6 | 7 | def getNonce(self): 8 | return self.nonce 9 | 10 | def toProtocolTreeNode(self): 11 | #return self._createProtocolTreeNode({}, children = None, data = self.nonce) 12 | return self._createProtocolTreeNode({}, children = [], data = "".join(map(chr, self.nonce))) 13 | 14 | def __str__(self): 15 | out = "Challenge\n" 16 | out += "Nonce: %s\n" % self.nonce 17 | return out 18 | 19 | @staticmethod 20 | def fromProtocolTreeNode(node): 21 | nonce = list(map(ord,node.getData())) 22 | entity = ChallengeProtocolEntity(bytearray(nonce)) 23 | return entity 24 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/failure.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class FailureProtocolEntity(ProtocolEntity): 3 | 4 | def __init__(self, reason): 5 | super(FailureProtocolEntity, self).__init__("failure") 6 | self.reason = reason 7 | 8 | def __str__(self): 9 | out = "Failure:\n" 10 | out += "Reason: %s\n" % self.reason 11 | return out 12 | 13 | def getReason(self): 14 | return self.reason 15 | 16 | def toProtocolTreeNode(self): 17 | return self._createProtocolTreeNode({"reason": self.reason}) 18 | 19 | @staticmethod 20 | def fromProtocolTreeNode(node): 21 | return FailureProtocolEntity( node["reason"] ) 22 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/response.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class ResponseProtocolEntity(ProtocolEntity): 3 | def __init__(self, data, xmlns = "urn:ietf:params:xml:ns:xmpp-sasl"): 4 | super(ResponseProtocolEntity, self).__init__("response") 5 | self.xmlns = xmlns 6 | self.data = data 7 | 8 | def toProtocolTreeNode(self): 9 | return self._createProtocolTreeNode({"xmlns": self.xmlns}, children = None, data = self.data) 10 | 11 | @staticmethod 12 | def fromProtocolTreeNode(node): 13 | return ResponseProtocolEntity(node.getData(), node.getAttributeValue("xmlns")) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/stream_features.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class StreamFeaturesProtocolEntity(ProtocolEntity): 3 | def __init__(self, features = None): 4 | super(StreamFeaturesProtocolEntity, self).__init__("stream:features") 5 | self.setFeatures(features) 6 | 7 | def setFeatures(self, features = None): 8 | self.features = features or [] 9 | 10 | def toProtocolTreeNode(self): 11 | featureNodes = [ProtocolTreeNode(feature) for feature in self.features] 12 | return self._createProtocolTreeNode({}, children = featureNodes, data = None) 13 | 14 | 15 | @staticmethod 16 | def fromProtocolTreeNode(node): 17 | return StreamFeaturesProtocolEntity([fnode.tag for fnode in node.getAllChildren()]) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/success.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class SuccessProtocolEntity(ProtocolEntity): 3 | def __init__(self, creation, props, t, location): 4 | super(SuccessProtocolEntity, self).__init__("success") 5 | self.location = location 6 | self.creation = int(creation) 7 | self.props = props 8 | self.t = int(t) ##whatever that is ! 9 | 10 | def __str__(self): 11 | out = "Account:\n" 12 | out += "Location: %s\n" % self.location 13 | out += "Creation: %s\n" % self.creation 14 | out += "Props: %s\n" % self.props 15 | out += "t: %s\n" % self.t 16 | return out 17 | 18 | def toProtocolTreeNode(self): 19 | attributes = { 20 | "location" : self.location, 21 | "creation" : str(self.creation), 22 | "props" : self.props, 23 | "t" : str(self.t) 24 | } 25 | return self._createProtocolTreeNode(attributes) 26 | 27 | @staticmethod 28 | def fromProtocolTreeNode(node): 29 | return SuccessProtocolEntity( 30 | node.getAttributeValue("creation"), 31 | node.getAttributeValue("props"), 32 | node.getAttributeValue("t"), 33 | node.getAttributeValue("location") 34 | ) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/test_failure.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.auth.protocolentities.failure import FailureProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | 7 | class FailureProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = FailureProtocolEntity 10 | self.node = ProtocolTreeNode("failure", {"reason": "not-authorized"}) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/auth/protocolentities/test_success.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.auth.protocolentities.success import SuccessProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | 7 | class SuccessProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = SuccessProtocolEntity 10 | attribs = { 11 | "creation": "1234", 12 | "location": "atn", 13 | "props": "2", 14 | "t": "1415470561" 15 | } 16 | self.node = ProtocolTreeNode("success", attribs) 17 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer_send import AxolotlSendLayer 2 | from .layer_control import AxolotlControlLayer 3 | from .layer_receive import AxolotlReceivelayer 4 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/props.py: -------------------------------------------------------------------------------- 1 | PROP_IDENTITY_AUTOTRUST = "org.openwhatsapp.yowsup.prop.axolotl.INDENTITY_AUTOTRUST" -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .iq_key_get import GetKeysIqProtocolEntity 2 | from .iq_keys_set import SetKeysIqProtocolEntity 3 | from .iq_keys_get_result import ResultGetKeysIqProtocolEntity 4 | from .message_encrypted import EncryptedMessageProtocolEntity 5 | from .enc import EncProtocolEntity 6 | from .receipt_outgoing_retry import RetryOutgoingReceiptProtocolEntity 7 | from .receipt_incoming_retry import RetryIncomingReceiptProtocolEntity 8 | from .notification_encrypt_identitychange import IdentityChangeEncryptNotification 9 | from .notification_encrypt_requestkeys import RequestKeysEncryptNotification 10 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/protocolentities/notification_encrypt_identitychange.py: -------------------------------------------------------------------------------- 1 | from yowsup.common import YowConstants 2 | from yowsup.layers.protocol_notifications.protocolentities import NotificationProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | 6 | class IdentityChangeEncryptNotification(NotificationProtocolEntity): 7 | """ 8 | 9 | 10 | 11 | """ 12 | def __init__(self, timestamp, _id = None, notify = None, offline = None): 13 | super(IdentityChangeEncryptNotification, self).__init__( 14 | "encrypt", _id, YowConstants.WHATSAPP_SERVER, timestamp, notify, offline 15 | ) 16 | 17 | def toProtocolTreeNode(self): 18 | node = super(IdentityChangeEncryptNotification, self).toProtocolTreeNode() 19 | node.addChild(ProtocolTreeNode("identity")) 20 | return node 21 | 22 | @staticmethod 23 | def fromProtocolTreeNode(node): 24 | entity = NotificationProtocolEntity.fromProtocolTreeNode(node) 25 | entity.__class__ = IdentityChangeEncryptNotification 26 | return entity 27 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/protocolentities/test_iq_keys_set.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.axolotl.protocolentities import SetKeysIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | class SetKeysIqProtocolEntityTest(IqProtocolEntityTest): 5 | def setUp(self): 6 | super(SetKeysIqProtocolEntityTest, self).setUp() 7 | # self.ProtocolEntity = SetKeysIqProtocolEntity 8 | # 9 | # regNode = ProtocolTreeNode("registration", data = "abcd") 10 | # idNode = ProtocolTreeNode("identity", data = "efgh") 11 | # typeNode = ProtocolTreeNode("type", data = "ijkl") 12 | # listNode = ProtocolTreeNode("list") 13 | # for i in range(0, 2): 14 | # keyNode = ProtocolTreeNode("key", children=[ 15 | # ProtocolTreeNode("id", data = "id_%s" % i), 16 | # ProtocolTreeNode("value", data = "val_%s" % i) 17 | # ]) 18 | # listNode.addChild(keyNode) 19 | # 20 | # self.node.addChildren([regNode, idNode, typeNode, listNode]) 21 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/axolotl/protocolentities/test_notification_encrypt_requestkeys.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.test_notification import NotificationProtocolEntityTest 2 | from yowsup.layers.axolotl.protocolentities import RequestKeysEncryptNotification 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | 6 | class TestRequestKeysEncryptNotification(NotificationProtocolEntityTest): 7 | def setUp(self): 8 | super(TestRequestKeysEncryptNotification, self).setUp() 9 | self.ProtocolEntity = RequestKeysEncryptNotification 10 | self.node.addChild(ProtocolTreeNode("count", {"value": "9"})) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/coder/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowCoderLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/coder/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer 2 | from .encoder import WriteEncoder 3 | from .decoder import ReadDecoder 4 | from .tokendictionary import TokenDictionary 5 | 6 | 7 | class YowCoderLayer(YowLayer): 8 | 9 | def __init__(self): 10 | YowLayer.__init__(self) 11 | tokenDictionary = TokenDictionary() 12 | self.writer = WriteEncoder(tokenDictionary) 13 | self.reader = ReadDecoder(tokenDictionary) 14 | 15 | def send(self, data): 16 | self.write(self.writer.protocolTreeNodeToBytes(data)) 17 | 18 | def receive(self, data): 19 | node = self.reader.getProtocolTreeNode(bytearray(data)) 20 | if node: 21 | self.toUpper(node) 22 | 23 | def write(self, i): 24 | if(type(i) in(list, tuple)): 25 | self.toLower(bytearray(i)) 26 | else: 27 | self.toLower(bytearray([i])) 28 | 29 | def __str__(self): 30 | return "Coder Layer" 31 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/coder/test_decoder.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from yowsup.layers.coder.decoder import ReadDecoder 3 | from yowsup.layers.coder.tokendictionary import TokenDictionary 4 | from yowsup.structs import ProtocolTreeNode 5 | class DecoderTest(unittest.TestCase): 6 | def setUp(self): 7 | self.decoder = ReadDecoder(TokenDictionary()) 8 | self.decoder.streamStarted = True 9 | 10 | def test_decode(self): 11 | data = bytearray([0, 248, 6, 95, 179, 252, 3, 120, 121, 122, 252, 4, 102, 111, 114, 109, 252, 3, 97, 98, 99, 248, 1, 248, 4, 93, 12 | 236, 104, 255, 130, 18, 63, 252, 6, 49, 50, 51, 52, 53, 54]) 13 | node = self.decoder.getProtocolTreeNode(data) 14 | targetNode = ProtocolTreeNode("message", {"form": "abc", "to":"xyz"}, [ProtocolTreeNode("media", {"width" : "123"}, data=b"123456")]) 15 | self.assertEqual(node, targetNode) 16 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/coder/test_encoder.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.coder.encoder import WriteEncoder 4 | from yowsup.layers.coder.tokendictionary import TokenDictionary 5 | 6 | class EncoderTest(unittest.TestCase): 7 | def setUp(self): 8 | self.res = [] 9 | self.encoder = WriteEncoder(TokenDictionary()) 10 | 11 | def test_encode(self): 12 | node = ProtocolTreeNode("message", {"form": "abc", "to":"xyz"}, [ProtocolTreeNode("media", {"width" : "123"}, data=b"123456")]) 13 | result = self.encoder.protocolTreeNodeToBytes(node) 14 | 15 | self.assertTrue(result in ( 16 | [0, 248, 6, 95, 179, 252, 3, 120, 121, 122, 252, 4, 102, 111, 114, 109, 252, 3, 97, 98, 99, 248, 1, 248, 4, 93, 17 | 236, 104, 255, 130, 18, 63, 252, 6, 49, 50, 51, 52, 53, 54], 18 | [0, 248, 6, 95, 252, 4, 102, 111, 114, 109, 252, 3, 97, 98, 99, 179, 252, 3, 120, 121, 122, 248, 1, 248, 4, 93, 19 | 236, 104, 255, 130, 18, 63, 252, 6, 49, 50, 51, 52, 53, 54] 20 | ) 21 | ) 22 | 23 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/coder/test_tokendictionary.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.coder.tokendictionary import TokenDictionary 2 | import unittest 3 | class TokenDictionaryTest(unittest.TestCase): 4 | def setUp(self): 5 | self.tokenDictionary = TokenDictionary() 6 | 7 | def test_getToken(self): 8 | self.assertEqual(self.tokenDictionary.getToken(80), "iq") 9 | 10 | def test_getIndex(self): 11 | self.assertEqual(self.tokenDictionary.getIndex("iq"), (80, False)) 12 | 13 | def test_getSecondaryToken(self): 14 | self.assertEqual(self.tokenDictionary.getToken(238), "amrnb") 15 | 16 | def test_getSecondaryTokenExplicit(self): 17 | self.assertEqual(self.tokenDictionary.getToken(11, True), "wmv") 18 | 19 | def test_getSecondaryIndex(self): 20 | self.assertEqual(self.tokenDictionary.getIndex("wmv"), (11, True)) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/interface/__init__.py: -------------------------------------------------------------------------------- 1 | from .interface import YowInterfaceLayer, ProtocolEntityCallback -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/logger/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowLoggerLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/logger/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer 2 | import logging 3 | logger = logging.getLogger(__name__) 4 | class YowLoggerLayer(YowLayer): 5 | 6 | def send(self, data): 7 | ldata = list(data) if type(data) is bytearray else data 8 | logger.debug("tx:\n%s" % ldata) 9 | self.toLower(data) 10 | 11 | def receive(self, data): 12 | ldata = list(data) if type(data) is bytearray else data 13 | logger.debug("rx:\n%s" % ldata) 14 | self.toUpper(data) 15 | 16 | def __str__(self): 17 | return "Logger Layer" -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/network/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowNetworkLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/network/dispatcher/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/layers/network/dispatcher/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/network/dispatcher/dispatcher.py: -------------------------------------------------------------------------------- 1 | class ConnectionCallbacks(object): 2 | def onConnected(self): 3 | pass 4 | 5 | def onDisconnected(self): 6 | pass 7 | 8 | def onRecvData(self, data): 9 | pass 10 | 11 | def onConnecting(self): 12 | pass 13 | 14 | def onConnectionError(self, error): 15 | pass 16 | 17 | 18 | class YowConnectionDispatcher(object): 19 | def __init__(self, connectionCallbacks): 20 | assert isinstance(connectionCallbacks, ConnectionCallbacks) 21 | self.connectionCallbacks = connectionCallbacks 22 | 23 | def connect(self, host): 24 | pass 25 | 26 | def disconnect(self): 27 | pass 28 | 29 | def sendData(self, data): 30 | pass -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/network/layer_interface.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayerInterface 2 | class YowNetworkLayerInterface(YowLayerInterface): 3 | def connect(self): 4 | self._layer.createConnection() 5 | 6 | def disconnect(self): 7 | self._layer.destroyConnection() 8 | 9 | def getStatus(self): 10 | return self._layer.getStatus() -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/noise/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/layers/noise/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/noise/workers/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/layers/noise/workers/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowAckProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowProtocolLayer 2 | from .protocolentities import * 3 | class YowAckProtocolLayer(YowProtocolLayer): 4 | def __init__(self): 5 | handleMap = { 6 | "ack": (self.recvAckNode, self.sendAckEntity) 7 | } 8 | super(YowAckProtocolLayer, self).__init__(handleMap) 9 | 10 | def __str__(self): 11 | return "Ack Layer" 12 | 13 | def sendAckEntity(self, entity): 14 | self.entityToLower(entity) 15 | 16 | def recvAckNode(self, node): 17 | self.toUpper(IncomingAckProtocolEntity.fromProtocolTreeNode(node)) 18 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .ack import AckProtocolEntity 2 | from .ack_incoming import IncomingAckProtocolEntity 3 | from .ack_outgoing import OutgoingAckProtocolEntity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/protocolentities/ack.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class AckProtocolEntity(ProtocolEntity): 3 | 4 | ''' 5 | 6 | 7 | ''' 8 | 9 | def __init__(self, _id, _class): 10 | super(AckProtocolEntity, self).__init__("ack") 11 | self._id = _id 12 | self._class = _class 13 | 14 | def getId(self): 15 | return self._id 16 | 17 | def getClass(self): 18 | return self._class 19 | 20 | def toProtocolTreeNode(self): 21 | attribs = { 22 | "id" : self._id, 23 | "class" : self._class, 24 | } 25 | 26 | return self._createProtocolTreeNode(attribs, None, data = None) 27 | 28 | def __str__(self): 29 | out = "ACK:\n" 30 | out += "ID: %s\n" % self._id 31 | out += "Class: %s\n" % self._class 32 | return out 33 | 34 | @staticmethod 35 | def fromProtocolTreeNode(node): 36 | return AckProtocolEntity( 37 | node.getAttributeValue("id"), 38 | node.getAttributeValue("class") 39 | ) 40 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/protocolentities/test_ack_incoming.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_acks.protocolentities.ack_incoming import IncomingAckProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | import time 5 | 6 | entity = IncomingAckProtocolEntity("12345", "message", "sender@s.whatsapp.com", int(time.time())) 7 | 8 | class IncomingAckProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 9 | def setUp(self): 10 | self.ProtocolEntity = IncomingAckProtocolEntity 11 | self.node = entity.toProtocolTreeNode() 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/protocolentities/test_ack_outgoing.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_acks.protocolentities.ack_outgoing import OutgoingAckProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = OutgoingAckProtocolEntity("12345", "receipt", "delivery", "to_jid") 6 | 7 | class OutgoingAckProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = OutgoingAckProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_acks/test_layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowProtocolLayerTest 2 | from yowsup.layers.protocol_acks import YowAckProtocolLayer 3 | from yowsup.layers.protocol_acks.protocolentities.test_ack_incoming import entity as incomingAckEntity 4 | from yowsup.layers.protocol_acks.protocolentities.test_ack_outgoing import entity as outgoingAckEntity 5 | class YowAckProtocolLayerTest(YowProtocolLayerTest, YowAckProtocolLayer): 6 | def setUp(self): 7 | YowAckProtocolLayer.__init__(self) 8 | 9 | def test_receive(self): 10 | self.assertReceived(incomingAckEntity) 11 | 12 | def test_send(self): 13 | self.assertSent(outgoingAckEntity) 14 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_calls/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowCallsProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_calls/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowProtocolLayer 2 | from .protocolentities import * 3 | from yowsup.layers.protocol_acks.protocolentities import OutgoingAckProtocolEntity 4 | from yowsup.layers.protocol_receipts.protocolentities import OutgoingReceiptProtocolEntity 5 | class YowCallsProtocolLayer(YowProtocolLayer): 6 | 7 | def __init__(self): 8 | handleMap = { 9 | "call": (self.recvCall, self.sendCall) 10 | } 11 | super(YowCallsProtocolLayer, self).__init__(handleMap) 12 | 13 | def __str__(self): 14 | return "call Layer" 15 | 16 | def sendCall(self, entity): 17 | if entity.getTag() == "call": 18 | self.toLower(entity.toProtocolTreeNode()) 19 | 20 | def recvCall(self, node): 21 | entity = CallProtocolEntity.fromProtocolTreeNode(node) 22 | if entity.getType() == "offer": 23 | receipt = OutgoingReceiptProtocolEntity(node["id"], node["from"], callId = entity.getCallId()) 24 | self.toLower(receipt.toProtocolTreeNode()) 25 | else: 26 | ack = OutgoingAckProtocolEntity(node["id"], "call", None, node["from"]) 27 | self.toLower(ack.toProtocolTreeNode()) 28 | self.toUpper(entity) 29 | 30 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_calls/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .call import CallProtocolEntity 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_calls/protocolentities/test_call.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_calls.protocolentities.call import CallProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class CallProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = CallProtocolEntity 9 | children = [ProtocolTreeNode("offer", {"call-id": "call_id"})] 10 | attribs = { 11 | "t": "12345", 12 | "from": "from_jid", 13 | "offline": "0", 14 | "id": "message_id", 15 | "notify": "notify_name" 16 | } 17 | self.node = ProtocolTreeNode("call", attribs, children) 18 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowChatstateProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer, YowLayerEvent, YowProtocolLayer 2 | from .protocolentities import * 3 | class YowChatstateProtocolLayer(YowProtocolLayer): 4 | def __init__(self): 5 | handleMap = { 6 | "chatstate": (self.recvChatstateNode, self.sendChatstateEntity) 7 | } 8 | super(YowChatstateProtocolLayer, self).__init__(handleMap) 9 | 10 | def __str__(self): 11 | return "Chatstate Layer" 12 | 13 | def sendChatstateEntity(self, entity): 14 | self.entityToLower(entity) 15 | 16 | def recvChatstateNode(self, node): 17 | self.toUpper(IncomingChatstateProtocolEntity.fromProtocolTreeNode(node)) 18 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .chatstate import ChatstateProtocolEntity 2 | from .chatstate_incoming import IncomingChatstateProtocolEntity 3 | from .chatstate_outgoing import OutgoingChatstateProtocolEntity 4 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/chatstate.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class ChatstateProtocolEntity(ProtocolEntity): 3 | 4 | ''' 5 | INCOMING 6 | 7 | 8 | <{{composing|paused}}> 9 | 10 | 11 | OUTGOING 12 | 13 | 14 | <{{composing|paused}}> 15 | 16 | ''' 17 | 18 | STATE_TYPING = "composing" 19 | STATE_PAUSED = "paused" 20 | STATES = (STATE_TYPING, STATE_PAUSED) 21 | 22 | def __init__(self, _state): 23 | super(ChatstateProtocolEntity, self).__init__("chatstate") 24 | assert _state in self.__class__.STATES, "Expected chat state to be in %s, got %s" % (self.__class__.STATES, _state) 25 | self._state = _state 26 | 27 | def getState(self): 28 | return self._state 29 | 30 | def toProtocolTreeNode(self): 31 | node = self._createProtocolTreeNode({}, None, data = None) 32 | node.addChild(ProtocolTreeNode(self._state)) 33 | return node 34 | 35 | def __str__(self): 36 | out = "CHATSTATE:\n" 37 | out += "State: %s\n" % self._state 38 | return out 39 | 40 | @staticmethod 41 | def fromProtocolTreeNode(node): 42 | return ChatstateProtocolEntity( 43 | node.getAllChildren()[0].tag, 44 | ) 45 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/chatstate_incoming.py: -------------------------------------------------------------------------------- 1 | from .chatstate import ChatstateProtocolEntity 2 | class IncomingChatstateProtocolEntity(ChatstateProtocolEntity): 3 | ''' 4 | INCOMING 5 | 6 | 7 | <{{composing|paused}}> 8 | 9 | 10 | OUTGOING 11 | 12 | 13 | <{{composing|paused}}> 14 | 15 | ''' 16 | 17 | def __init__(self, _state, _from): 18 | super(IncomingChatstateProtocolEntity, self).__init__(_state) 19 | self.setIncomingData(_from) 20 | 21 | def setIncomingData(self, _from): 22 | self._from = _from 23 | 24 | def toProtocolTreeNode(self): 25 | node = super(IncomingChatstateProtocolEntity, self).toProtocolTreeNode() 26 | node.setAttribute("from", self._from) 27 | return node 28 | 29 | def __str__(self): 30 | out = super(IncomingChatstateProtocolEntity, self).__str__() 31 | out += "From: %s\n" % self._from 32 | return out 33 | 34 | @staticmethod 35 | def fromProtocolTreeNode(node): 36 | entity = ChatstateProtocolEntity.fromProtocolTreeNode(node) 37 | entity.__class__ = IncomingChatstateProtocolEntity 38 | entity.setIncomingData( 39 | node.getAttributeValue("from"), 40 | ) 41 | return entity 42 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/chatstate_outgoing.py: -------------------------------------------------------------------------------- 1 | from .chatstate import ChatstateProtocolEntity 2 | class OutgoingChatstateProtocolEntity(ChatstateProtocolEntity): 3 | ''' 4 | INCOMING 5 | 6 | 7 | <{{composing|paused}}> 8 | 9 | 10 | OUTGOING 11 | 12 | 13 | <{{composing|paused}}> 14 | 15 | ''' 16 | 17 | def __init__(self, _state, _to): 18 | super(OutgoingChatstateProtocolEntity, self).__init__(_state) 19 | self.setOutgoingData(_to) 20 | 21 | def setOutgoingData(self, _to): 22 | self._to = _to 23 | 24 | def toProtocolTreeNode(self): 25 | node = super(OutgoingChatstateProtocolEntity, self).toProtocolTreeNode() 26 | node.setAttribute("to", self._to) 27 | return node 28 | 29 | def __str__(self): 30 | out = super(OutgoingChatstateProtocolEntity, self).__str__() 31 | out += "To: %s\n" % self._to 32 | return out 33 | 34 | @staticmethod 35 | def fromProtocolTreeNode(node): 36 | entity = ChatstateProtocolEntity.fromProtocolTreeNode(node) 37 | entity.__class__ = OutgoingChatstateProtocolEntity 38 | entity.setOutgoingData( 39 | node.getAttributeValue("to"), 40 | ) 41 | return entity 42 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/test_chatstate_incoming.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_chatstate.protocolentities.chatstate_incoming import IncomingChatstateProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = IncomingChatstateProtocolEntity(IncomingChatstateProtocolEntity.STATE_TYPING, "jid@s.whatsapp.net") 6 | 7 | class IncomingChatstateProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = IncomingChatstateProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/protocolentities/test_chatstate_outgoing.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_chatstate.protocolentities.chatstate_outgoing import OutgoingChatstateProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = OutgoingChatstateProtocolEntity(OutgoingChatstateProtocolEntity.STATE_PAUSED, "jid@s.whatsapp.net") 6 | 7 | class OutgoingChatstateProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = OutgoingChatstateProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_chatstate/test_layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowProtocolLayerTest 2 | from yowsup.layers.protocol_chatstate import YowChatstateProtocolLayer 3 | from yowsup.layers.protocol_chatstate.protocolentities import IncomingChatstateProtocolEntity, OutgoingChatstateProtocolEntity 4 | 5 | class YowChatStateProtocolLayerTest(YowProtocolLayerTest, YowChatstateProtocolLayer): 6 | def setUp(self): 7 | YowChatstateProtocolLayer.__init__(self) 8 | 9 | def test_send(self): 10 | entity = OutgoingChatstateProtocolEntity(OutgoingChatstateProtocolEntity.STATE_PAUSED, "jid@s.whatsapp.net") 11 | self.assertSent(entity) 12 | 13 | def test_receive(self): 14 | entity = IncomingChatstateProtocolEntity(IncomingChatstateProtocolEntity.STATE_TYPING, "jid@s.whatsapp.net") 15 | self.assertReceived(entity) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowContactsIqProtocolLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .iq_sync import SyncIqProtocolEntity 2 | from .iq_sync_get import GetSyncIqProtocolEntity 3 | from .iq_sync_result import ResultSyncIqProtocolEntity 4 | from .notification_contact_add import AddContactNotificationProtocolEntity 5 | from .notification_contact_remove import RemoveContactNotificationProtocolEntity 6 | from .notification_contact_update import UpdateContactNotificationProtocolEntity 7 | from .notificiation_contacts_sync import ContactsSyncNotificationProtocolEntity 8 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/notification_contact.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from yowsup.layers.protocol_notifications.protocolentities import NotificationProtocolEntity 3 | class ContactNotificationProtocolEntity(NotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | 9 | ''' 10 | 11 | def __init__(self, _id, _from, timestamp, notify, offline = False): 12 | super(ContactNotificationProtocolEntity, self).__init__("contacts", _id, _from, timestamp, notify, offline) 13 | 14 | 15 | @staticmethod 16 | def fromProtocolTreeNode(node): 17 | entity = NotificationProtocolEntity.fromProtocolTreeNode(node) 18 | entity.__class__ = ContactNotificationProtocolEntity 19 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/notification_contact_add.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolTreeNode 2 | from .notification_contact import ContactNotificationProtocolEntity 3 | class AddContactNotificationProtocolEntity(ContactNotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | 9 | ''' 10 | 11 | def __init__(self, _id, _from, timestamp, notify, offline, contactJid): 12 | super(AddContactNotificationProtocolEntity, self).__init__(_id, _from, timestamp, notify, offline) 13 | self.setData(contactJid) 14 | 15 | def setData(self, jid): 16 | self.contactJid = jid 17 | 18 | def toProtocolTreeNode(self): 19 | node = super(AddContactNotificationProtocolEntity, self).toProtocolTreeNode() 20 | removeNode = ProtocolTreeNode("add", {"jid": self.contactJid}, None, None) 21 | node.addChild(removeNode) 22 | return node 23 | 24 | @staticmethod 25 | def fromProtocolTreeNode(node): 26 | entity = ContactNotificationProtocolEntity.fromProtocolTreeNode(node) 27 | entity.__class__ = AddContactNotificationProtocolEntity 28 | removeNode = node.getChild("add") 29 | entity.setData(removeNode.getAttributeValue("jid")) 30 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/notification_contact_remove.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolTreeNode 2 | from .notification_contact import ContactNotificationProtocolEntity 3 | class RemoveContactNotificationProtocolEntity(ContactNotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | 9 | ''' 10 | 11 | def __init__(self, _id, _from, timestamp, notify, offline, contactJid): 12 | super(RemoveContactNotificationProtocolEntity, self).__init__(_id, _from, timestamp, notify, offline) 13 | self.setData(contactJid) 14 | 15 | def setData(self, jid): 16 | self.contactJid = jid 17 | 18 | def toProtocolTreeNode(self): 19 | node = super(RemoveContactNotificationProtocolEntity, self).toProtocolTreeNode() 20 | removeNode = ProtocolTreeNode("remove", {"jid": self.contactJid}, None, None) 21 | node.addChild(removeNode) 22 | return node 23 | 24 | @staticmethod 25 | def fromProtocolTreeNode(node): 26 | entity = ContactNotificationProtocolEntity.fromProtocolTreeNode(node) 27 | entity.__class__ = RemoveContactNotificationProtocolEntity 28 | removeNode = node.getChild("remove") 29 | entity.setData(removeNode.getAttributeValue("jid")) 30 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/notification_contact_update.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolTreeNode 2 | from .notification_contact import ContactNotificationProtocolEntity 3 | class UpdateContactNotificationProtocolEntity(ContactNotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | 9 | ''' 10 | 11 | def __init__(self, _id, _from, timestamp, notify, offline, contactJid): 12 | super(UpdateContactNotificationProtocolEntity, self).__init__(_id, _from, timestamp, notify, offline) 13 | self.setData(contactJid) 14 | 15 | def setData(self, jid): 16 | self.contactJid = jid 17 | 18 | def toProtocolTreeNode(self): 19 | node = super(UpdateContactNotificationProtocolEntity, self).toProtocolTreeNode() 20 | removeNode = ProtocolTreeNode("update", {"jid": self.contactJid}, None, None) 21 | node.addChild(removeNode) 22 | return node 23 | 24 | @staticmethod 25 | def fromProtocolTreeNode(node): 26 | entity = ContactNotificationProtocolEntity.fromProtocolTreeNode(node) 27 | entity.__class__ = UpdateContactNotificationProtocolEntity 28 | removeNode = node.getChild("update") 29 | entity.setData(removeNode.getAttributeValue("jid")) 30 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/notificiation_contacts_sync.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolTreeNode 2 | from .notification_contact import ContactNotificationProtocolEntity 3 | class ContactsSyncNotificationProtocolEntity(ContactNotificationProtocolEntity): 4 | ''' 5 | 6 | 7 | 8 | ''' 9 | 10 | def __init__(self, _id, _from, timestamp, notify, offline, after): 11 | super(ContactsSyncNotificationProtocolEntity, self).__init__(_id, _from, timestamp, notify, offline) 12 | self.setData(after) 13 | 14 | def setData(self, after): 15 | self.after = int(after) 16 | 17 | def toProtocolTreeNode(self): 18 | node = super(ContactsSyncNotificationProtocolEntity, self).toProtocolTreeNode() 19 | syncNode = ProtocolTreeNode("sync", {"after": str(self.after)}, None, None) 20 | node.addChild(syncNode) 21 | return node 22 | 23 | @staticmethod 24 | def fromProtocolTreeNode(node): 25 | entity = ContactNotificationProtocolEntity.fromProtocolTreeNode(node) 26 | entity.__class__ = ContactsSyncNotificationProtocolEntity 27 | syncNode = node.getChild("sync") 28 | entity.setData(syncNode.getAttributeValue("after")) 29 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/test_iq_sync_get.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_contacts.protocolentities.iq_sync_get import GetSyncIqProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = GetSyncIqProtocolEntity(["12345678", "8764543121"]) 6 | 7 | class GetSyncIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = GetSyncIqProtocolEntity 10 | self.node = entity.toProtocolTreeNode() -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/test_iq_sync_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_contacts.protocolentities.iq_sync_result import ResultSyncIqProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = ResultSyncIqProtocolEntity("123", "1.30615237617e+17", 0, 6 | True, "123456", {"12345678": "12345678@s.whatsapp.net"}, 7 | {"12345678": "12345678@s.whatsapp.net"}, ["1234"]) 8 | 9 | class ResultSyncIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 10 | def setUp(self): 11 | self.ProtocolEntity = ResultSyncIqProtocolEntity 12 | self.node = entity.toProtocolTreeNode() 13 | 14 | def test_delta_result(self): 15 | del self.node.getChild("sync")["wait"] 16 | self.test_generation() 17 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/test_notification_contact_add.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_contacts.protocolentities import AddContactNotificationProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import time 4 | import unittest 5 | 6 | entity = AddContactNotificationProtocolEntity("1234", "jid@s.whatsapp.net", int(time.time()), "notify", False, 7 | "sender@s.whatsapp.net") 8 | 9 | class AddContactNotificationProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 10 | def setUp(self): 11 | super(AddContactNotificationProtocolEntityTest, self).setUp() 12 | self.ProtocolEntity = AddContactNotificationProtocolEntity 13 | self.node = entity.toProtocolTreeNode() 14 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/test_notification_contact_remove.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_contacts.protocolentities import RemoveContactNotificationProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import time 4 | import unittest 5 | 6 | entity = RemoveContactNotificationProtocolEntity("1234", "jid@s.whatsapp.net", 7 | int(time.time()), "notify", False, "contactjid@s.whatsapp.net") 8 | 9 | class RemoveContactNotificationProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 10 | def setUp(self): 11 | self.ProtocolEntity = RemoveContactNotificationProtocolEntity 12 | self.node = entity.toProtocolTreeNode() 13 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/protocolentities/test_notification_contact_update.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_contacts.protocolentities import UpdateContactNotificationProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import time 4 | import unittest 5 | 6 | entity = UpdateContactNotificationProtocolEntity("1234", "jid@s.whatsapp.net", 7 | int(time.time()), "notify", False,"contactjid@s.whatsapp.net") 8 | 9 | class UpdateContactNotificationProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 10 | def setUp(self): 11 | self.ProtocolEntity = UpdateContactNotificationProtocolEntity 12 | self.node = entity.toProtocolTreeNode() 13 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_contacts/test_layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowProtocolLayerTest 2 | from yowsup.layers.protocol_contacts import YowContactsIqProtocolLayer 3 | from yowsup.layers.protocol_contacts.protocolentities.test_notification_contact_add import entity as addEntity 4 | from yowsup.layers.protocol_contacts.protocolentities.test_notification_contact_update import entity as updateEntity 5 | from yowsup.layers.protocol_contacts.protocolentities.test_notification_contact_remove import entity as removeEntity 6 | from yowsup.layers.protocol_contacts.protocolentities.test_iq_sync_result import entity as syncResultEntity 7 | from yowsup.layers.protocol_contacts.protocolentities.test_iq_sync_get import entity as syncGetEntity 8 | 9 | class YowContactsIqProtocolLayerTest(YowProtocolLayerTest, YowContactsIqProtocolLayer): 10 | def setUp(self): 11 | YowContactsIqProtocolLayer.__init__(self) 12 | 13 | def test_sync(self): 14 | self.assertSent(syncGetEntity) 15 | 16 | def test_syncResult(self): 17 | self.assertReceived(syncResultEntity) 18 | 19 | def test_notificationAdd(self): 20 | self.assertReceived(addEntity) 21 | 22 | def test_notificationUpdate(self): 23 | self.assertReceived(updateEntity) 24 | 25 | def test_notificationRemove(self): 26 | self.assertReceived(removeEntity) 27 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowGroupsProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from yowsup.layers.protocol_iq.protocolentities import IqProtocolEntity 3 | class GroupsIqProtocolEntity(IqProtocolEntity): 4 | ''' 5 | 6 | 7 | ''' 8 | def __init__(self, to = None, _from = None, _id = None, _type = None): 9 | super(GroupsIqProtocolEntity, self).__init__("w:g2", _id, _type, to = to, _from = _from) 10 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_create_success.py: -------------------------------------------------------------------------------- 1 | from yowsup.common import YowConstants 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.protocol_iq.protocolentities import ResultIqProtocolEntity 4 | class SuccessCreateGroupsIqProtocolEntity(ResultIqProtocolEntity): 5 | ''' 6 | 7 | 8 | 9 | ''' 10 | 11 | def __init__(self, _id, groupId): 12 | super(SuccessCreateGroupsIqProtocolEntity, self).__init__(_from = YowConstants.WHATSAPP_GROUP_SERVER, _id = _id) 13 | self.setProps(groupId) 14 | 15 | def setProps(self, groupId): 16 | self.groupId = groupId 17 | 18 | def toProtocolTreeNode(self): 19 | node = super(SuccessCreateGroupsIqProtocolEntity, self).toProtocolTreeNode() 20 | node.addChild(ProtocolTreeNode("group",{"id": self.groupId})) 21 | return node 22 | 23 | @staticmethod 24 | def fromProtocolTreeNode(node): 25 | entity = super(SuccessCreateGroupsIqProtocolEntity, SuccessCreateGroupsIqProtocolEntity).fromProtocolTreeNode(node) 26 | entity.__class__ = SuccessCreateGroupsIqProtocolEntity 27 | entity.setProps(node.getChild("group").getAttributeValue("id")) 28 | return entity 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_add.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_groups_participants import ParticipantsGroupsIqProtocolEntity 3 | 4 | class AddParticipantsIqProtocolEntity(ParticipantsGroupsIqProtocolEntity): 5 | ''' 6 | 7 | 8 | 9 | 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, group_jid, participantList, _id = None): 15 | super(AddParticipantsIqProtocolEntity, self).__init__(group_jid, participantList, "add", _id = _id) 16 | 17 | @staticmethod 18 | def fromProtocolTreeNode(node): 19 | entity = super(AddParticipantsIqProtocolEntity, AddParticipantsIqProtocolEntity).fromProtocolTreeNode(node) 20 | entity.__class__ = AddParticipantsIqProtocolEntity 21 | participantList = [] 22 | for participantNode in node.getChild("add").getAllChildren(): 23 | participantList.append(participantNode["jid"]) 24 | entity.setProps(node.getAttributeValue("to"), participantList) 25 | return entity 26 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_add_failure.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities import ErrorIqProtocolEntity 2 | class FailureAddParticipantsIqProtocolEntity(ErrorIqProtocolEntity): 3 | ''' 4 | 5 | 6 | 7 | 8 | ''' 9 | 10 | def __init__(self, _id, _from, _code, _text, _backoff= 0 ): 11 | super(FailureAddParticipantsIqProtocolEntity, self).__init__(_from = _from, 12 | _id = _id, code = _code, 13 | text = _text, backoff = _backoff) 14 | @staticmethod 15 | def fromProtocolTreeNode(node): 16 | entity = ErrorIqProtocolEntity.fromProtocolTreeNode(node) 17 | entity.__class__ = FailureAddParticipantsIqProtocolEntity 18 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_demote.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_groups_participants import ParticipantsGroupsIqProtocolEntity 3 | 4 | class DemoteParticipantsIqProtocolEntity(ParticipantsGroupsIqProtocolEntity): 5 | ''' 6 | 7 | 8 | 9 | 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, group_jid, participantList, _id = None): 15 | super(DemoteParticipantsIqProtocolEntity, self).__init__(group_jid, participantList, "demote", _id = _id) 16 | 17 | @staticmethod 18 | def fromProtocolTreeNode(node): 19 | entity = super(DemoteParticipantsIqProtocolEntity, DemoteParticipantsIqProtocolEntity).fromProtocolTreeNode(node) 20 | entity.__class__ = DemoteParticipantsIqProtocolEntity 21 | participantList = [] 22 | for participantNode in node.getChild("demote").getAllChildren(): 23 | participantList.append(participantNode["jid"]) 24 | entity.setProps(node.getAttributeValue("to"), participantList) 25 | return entity 26 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_promote.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_groups_participants import ParticipantsGroupsIqProtocolEntity 3 | 4 | class PromoteParticipantsIqProtocolEntity(ParticipantsGroupsIqProtocolEntity): 5 | ''' 6 | 7 | 8 | 9 | 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, group_jid, participantList, _id = None): 15 | super(PromoteParticipantsIqProtocolEntity, self).__init__(group_jid, participantList, "promote", _id = _id) 16 | 17 | @staticmethod 18 | def fromProtocolTreeNode(node): 19 | entity = super(PromoteParticipantsIqProtocolEntity, PromoteParticipantsIqProtocolEntity).fromProtocolTreeNode(node) 20 | entity.__class__ = PromoteParticipantsIqProtocolEntity 21 | participantList = [] 22 | for participantNode in node.getChild("promote").getAllChildren(): 23 | participantList.append(participantNode["jid"]) 24 | entity.setProps(node.getAttributeValue("to"), participantList) 25 | return entity 26 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_participants_remove.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_groups_participants import ParticipantsGroupsIqProtocolEntity 3 | 4 | class RemoveParticipantsIqProtocolEntity(ParticipantsGroupsIqProtocolEntity): 5 | ''' 6 | 7 | 8 | 9 | 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, group_jid, participantList, _id = None): 15 | super(RemoveParticipantsIqProtocolEntity, self).__init__(group_jid, participantList, "remove", _id = _id) 16 | 17 | @staticmethod 18 | def fromProtocolTreeNode(node): 19 | entity = super(RemoveParticipantsIqProtocolEntity, RemoveParticipantsIqProtocolEntity).fromProtocolTreeNode(node) 20 | entity.__class__ = RemoveParticipantsIqProtocolEntity 21 | participantList = [] 22 | for participantNode in node.getChild("remove").getAllChildren(): 23 | participantList.append(participantNode["jid"]) 24 | entity.setProps(node.getAttributeValue("to"), participantList) 25 | return entity 26 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/iq_groups_subject.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_groups import GroupsIqProtocolEntity 3 | class SubjectGroupsIqProtocolEntity(GroupsIqProtocolEntity): 4 | ''' 5 | 6 | 7 | {{NEW_VAL}} 8 | 9 | 10 | ''' 11 | def __init__(self, jid, subject, _id = None): 12 | super(SubjectGroupsIqProtocolEntity, self).__init__(to = jid, _id = _id, _type = "set") 13 | self.setProps(subject) 14 | 15 | def setProps(self, subject): 16 | self.subject = subject 17 | 18 | def toProtocolTreeNode(self): 19 | node = super(SubjectGroupsIqProtocolEntity, self).toProtocolTreeNode() 20 | node.addChild(ProtocolTreeNode("subject",{}, None, self.subject)) 21 | return node 22 | 23 | @staticmethod 24 | def fromProtocolTreeNode(node): 25 | entity = super(SubjectGroupsIqProtocolEntity, SubjectGroupsIqProtocolEntity).fromProtocolTreeNode(node) 26 | entity.__class__ = SubjectGroupsIqProtocolEntity 27 | entity.setProps(node.getChild("subject").getData()) 28 | return entity 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_groups.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | 3 | class GroupsIqProtocolEntityTest(IqProtocolEntityTest): 4 | pass 5 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_groups_create.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_groups.protocolentities.iq_groups_create import CreateGroupsIqProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = CreateGroupsIqProtocolEntity("group subject") 6 | 7 | class CreateGroupsIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = CreateGroupsIqProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_groups_create_success.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs.protocolentity import ProtocolEntityTest 2 | from yowsup.layers.protocol_groups.protocolentities import SuccessCreateGroupsIqProtocolEntity 3 | import unittest 4 | 5 | entity = SuccessCreateGroupsIqProtocolEntity("123-456", "431-123") 6 | 7 | class SuccessCreateGroupsIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = SuccessCreateGroupsIqProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_groups_list.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_groups.protocolentities.iq_groups_list import ListGroupsIqProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | entity = ListGroupsIqProtocolEntity() 6 | 7 | class ListGroupsIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 8 | def setUp(self): 9 | self.ProtocolEntity = ListGroupsIqProtocolEntity 10 | self.node = entity.toProtocolTreeNode() 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_result_groups.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq_result import ResultIqProtocolEntityTest 2 | 3 | class GroupsResultIqProtocolEntityTest(ResultIqProtocolEntityTest): 4 | pass -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/protocolentities/test_iq_result_groups_list.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_groups.protocolentities.iq_result_groups_list import ListGroupsResultIqProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | from yowsup.layers.protocol_groups.structs import Group 4 | import unittest 5 | import time 6 | 7 | entity = ListGroupsResultIqProtocolEntity( 8 | [ 9 | Group("1234-456", "owner@s.whatsapp.net", "subject", "sOwnerJid@s.whatsapp.net", int(time.time()), int(time.time())), 10 | Group("4321-456", "owner@s.whatsapp.net", "subject", "sOwnerJid@s.whatsapp.net", int(time.time()), int(time.time())) 11 | ] 12 | ) 13 | 14 | class ListGroupsResultIqProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 15 | def setUp(self): 16 | self.ProtocolEntity = ListGroupsResultIqProtocolEntity 17 | self.node = entity.toProtocolTreeNode() 18 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/structs/__init__.py: -------------------------------------------------------------------------------- 1 | from .group import Group -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_groups/structs/group.py: -------------------------------------------------------------------------------- 1 | class Group(object): 2 | def __init__(self, groupId, creatorJid, subject, subjectOwnerJid, subjectTime, creationTime, participants=None): 3 | self._groupId = groupId 4 | self._creatorJid = creatorJid 5 | self._subject = subject 6 | self._subjectOwnerJid = subjectOwnerJid 7 | self._subjectTime = int(subjectTime) 8 | self._creationTime = int(creationTime) 9 | self._participants = participants or {} 10 | 11 | def getId(self): 12 | return self._groupId 13 | 14 | def getCreator(self): 15 | return self._creatorJid 16 | 17 | def getOwner(self): 18 | return self.getCreator() 19 | 20 | def getSubject(self): 21 | return self._subject 22 | 23 | def getSubjectOwner(self): 24 | return self._subjectOwnerJid 25 | 26 | def getSubjectTime(self): 27 | return self._subjectTime 28 | 29 | def getCreationTime(self): 30 | return self._creationTime 31 | 32 | def __str__(self): 33 | return "ID: %s, Subject: %s, Creation: %s, Creator: %s, Subject Owner: %s, Subject Time: %s\nParticipants: %s" %\ 34 | (self.getId(), self.getSubject(), self.getCreationTime(), self.getCreator(), self.getSubjectOwner(), self.getSubjectTime(), ", ".join(self._participants.keys())) 35 | 36 | def getParticipants(self): 37 | return self._participants 38 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowIbProtocolLayer 2 | 3 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .clean_iq import CleanIqProtocolEntity 2 | from .dirty_ib import DirtyIbProtocolEntity 3 | from .offline_ib import OfflineIbProtocolEntity 4 | from .account_ib import AccountIbProtocolEntity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/ib.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class IbProtocolEntity(ProtocolEntity): 3 | ''' 4 | 5 | ''' 6 | def __init__(self): 7 | super(IbProtocolEntity, self).__init__("ib") 8 | 9 | def toProtocolTreeNode(self): 10 | return self._createProtocolTreeNode({}, None, None) 11 | 12 | def __str__(self): 13 | out = "Ib:\n" 14 | return out 15 | 16 | @staticmethod 17 | def fromProtocolTreeNode(node): 18 | return IbProtocolEntity() 19 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/offline_ib.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .ib import IbProtocolEntity 3 | class OfflineIbProtocolEntity(IbProtocolEntity): 4 | ''' 5 | 6 | 7 | 8 | ''' 9 | def __init__(self, count): 10 | super(IbProtocolEntity, self).__init__() 11 | self.setProps(count) 12 | 13 | 14 | def setProps(self, count): 15 | self.count = int(count) 16 | 17 | def toProtocolTreeNode(self): 18 | node = super(OfflineIbProtocolEntity, self).toProtocolTreeNode() 19 | offlineChild = ProtocolTreeNode("offline", {"count": str(self.count)}) 20 | node.addChild(offlineChild) 21 | return node 22 | 23 | def __str__(self): 24 | out = super(OfflineIbProtocolEntity, self).__str__() 25 | out += "Offline count: %s\n" % self.count 26 | return out 27 | 28 | @staticmethod 29 | def fromProtocolTreeNode(node): 30 | entity = IbProtocolEntity.fromProtocolTreeNode(node) 31 | entity.__class__ = OfflineIbProtocolEntity 32 | entity.setProps(node.getChild("offline")["count"]) 33 | return entity 34 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/test_clean_iq.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolTreeNode 2 | from yowsup.layers.protocol_ib.protocolentities.clean_iq import CleanIqProtocolEntity 3 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 4 | 5 | class CleanIqProtocolEntityTest(IqProtocolEntityTest): 6 | def setUp(self): 7 | super(CleanIqProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = CleanIqProtocolEntity 9 | cleanNode = ProtocolTreeNode("clean", {"type": "groups"}) 10 | self.node.addChild(cleanNode) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/test_dirty_ib.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_ib.protocolentities.test_ib import IbProtocolEntityTest 2 | from yowsup.layers.protocol_ib.protocolentities.dirty_ib import DirtyIbProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | class DirtyIbProtocolEntityTest(IbProtocolEntityTest): 5 | def setUp(self): 6 | super(DirtyIbProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = DirtyIbProtocolEntity 8 | dirtyNode = ProtocolTreeNode("dirty") 9 | dirtyNode["timestamp"] = "123456" 10 | dirtyNode["type"] = "groups" 11 | self.node.addChild(dirtyNode) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/test_ib.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_ib.protocolentities.ib import IbProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class IbProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = IbProtocolEntity 9 | self.node = ProtocolTreeNode("ib") 10 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_ib/protocolentities/test_offline_iq.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_ib.protocolentities.test_ib import IbProtocolEntityTest 2 | from yowsup.layers.protocol_ib.protocolentities.offline_ib import OfflineIbProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | class OfflineIbProtocolEntityTest(IbProtocolEntityTest): 5 | def setUp(self): 6 | super(OfflineIbProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = OfflineIbProtocolEntity 8 | self.node.addChild(ProtocolTreeNode("offline", {"count": "5"})) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowIqProtocolLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .iq import IqProtocolEntity 2 | from .iq_result import ResultIqProtocolEntity 3 | from .iq_ping import PingIqProtocolEntity 4 | from .iq_result_pong import PongResultIqProtocolEntity 5 | from .iq_error import ErrorIqProtocolEntity 6 | from .iq_push import PushIqProtocolEntity 7 | from .iq_props import PropsIqProtocolEntity 8 | from .iq_crypto import CryptoIqProtocolEntity 9 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_crypto.py: -------------------------------------------------------------------------------- 1 | from .iq import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | class CryptoIqProtocolEntity(IqProtocolEntity): 4 | def __init__(self): 5 | super(CryptoIqProtocolEntity, self).__init__("urn:xmpp:whatsapp:account", _type="get") 6 | 7 | def toProtocolTreeNode(self): 8 | node = super(CryptoIqProtocolEntity, self).toProtocolTreeNode() 9 | cryptoNode = ProtocolTreeNode("crypto", {"action": "create"}) 10 | googleNode = ProtocolTreeNode("google", data = "fe5cf90c511fb899781bbed754577098e460d048312c8b36c11c91ca4b49ca34".decode('hex')) 11 | cryptoNode.addChild(googleNode) 12 | node.addChild(cryptoNode) 13 | return node -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_ping.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq import IqProtocolEntity 3 | class PingIqProtocolEntity(IqProtocolEntity): 4 | 5 | ''' 6 | Receive 7 | 8 | 9 | Send 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, _from = None, to = None, _id = None): 15 | super(PingIqProtocolEntity, self).__init__("urn:xmpp:ping" if _from else "w:p", _id = _id, _type = "get", _from = _from, to = to) 16 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_props.py: -------------------------------------------------------------------------------- 1 | from .iq import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | class PropsIqProtocolEntity(IqProtocolEntity): 4 | def __init__(self): 5 | super(PropsIqProtocolEntity, self).__init__("w", _type="get") 6 | 7 | def toProtocolTreeNode(self): 8 | node = super(PropsIqProtocolEntity, self).toProtocolTreeNode() 9 | node.addChild(ProtocolTreeNode("props")) 10 | return node -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_push.py: -------------------------------------------------------------------------------- 1 | from .iq import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | class PushIqProtocolEntity(IqProtocolEntity): 4 | def __init__(self): 5 | super(PushIqProtocolEntity, self).__init__("urn:xmpp:whatsapp:push", _type="get") 6 | 7 | def toProtocolTreeNode(self): 8 | node = super(PushIqProtocolEntity, self).toProtocolTreeNode() 9 | node.addChild(ProtocolTreeNode("config")) 10 | return node -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq import IqProtocolEntity 3 | class ResultIqProtocolEntity(IqProtocolEntity): 4 | 5 | ''' 6 | 7 | 8 | ''' 9 | 10 | def __init__(self, xmlns = None, _id = None, to = None, _from = None): 11 | super(ResultIqProtocolEntity, self).__init__(xmlns = xmlns, _id = _id, _type = "result", to = to, _from = _from) 12 | 13 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/iq_result_pong.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .iq_result import ResultIqProtocolEntity 3 | class PongResultIqProtocolEntity(ResultIqProtocolEntity): 4 | 5 | ''' 6 | 7 | 8 | ''' 9 | def __init__(self, to, _id = None): 10 | super(PongResultIqProtocolEntity, self).__init__("w:p", _id = _id, to = to) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/test_iq.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.iq import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class IqProtocolEntityTest(unittest.TestCase, ProtocolEntityTest): 7 | def setUp(self): 8 | self.ProtocolEntity = IqProtocolEntity 9 | self.node = ProtocolTreeNode("iq", {"id": "test_id", "type": "get", "xmlns": "iq_xmlns"}, None, None) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/test_iq_error.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_iq.protocolentities import ErrorIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | class ErrorIqProtocolEntityTest(IqProtocolEntityTest): 6 | def setUp(self): 7 | super(ErrorIqProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = ErrorIqProtocolEntity 9 | errorNode = ProtocolTreeNode("error", {"code": "123", "text": "abc"}) 10 | self.node.addChild(errorNode) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_iq/protocolentities/test_iq_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | class ResultIqProtocolEntityTest(IqProtocolEntityTest): 3 | def setUp(self): 4 | super(ResultIqProtocolEntityTest, self).setUp() 5 | self.node.setAttribute("type", "result") -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowMediaProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .message_media import MediaMessageProtocolEntity 2 | from .message_media_downloadable import DownloadableMediaMessageProtocolEntity 3 | from .message_media_downloadable_image import ImageDownloadableMediaMessageProtocolEntity 4 | from .message_media_downloadable_audio import AudioDownloadableMediaMessageProtocolEntity 5 | from .message_media_downloadable_video import VideoDownloadableMediaMessageProtocolEntity 6 | from .message_media_downloadable_document import DocumentDownloadableMediaMessageProtocolEntity 7 | from .message_media_downloadable_sticker import StickerDownloadableMediaMessageProtocolEntity 8 | from .message_media_location import LocationMediaMessageProtocolEntity 9 | from .message_media_contact import ContactMediaMessageProtocolEntity 10 | from .message_media_extendedtext import ExtendedTextMediaMessageProtocolEntity 11 | from .iq_requestupload import RequestUploadIqProtocolEntity 12 | from .iq_requestupload_result import ResultRequestUploadIqProtocolEntity 13 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/message_media_contact.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_message_meta import MessageMetaAttributes 2 | from .message_media import MediaMessageProtocolEntity 3 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_contact import ContactAttributes 4 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_message import MessageAttributes 5 | 6 | 7 | class ContactMediaMessageProtocolEntity(MediaMessageProtocolEntity): 8 | def __init__(self, contact_attrs, message_meta_attrs): 9 | # type: (ContactAttributes, MessageMetaAttributes) -> None 10 | super(ContactMediaMessageProtocolEntity, self).__init__( 11 | "contact", MessageAttributes(contact=contact_attrs), message_meta_attrs 12 | ) 13 | 14 | @property 15 | def media_specific_attributes(self): 16 | return self.message_attributes.contact 17 | 18 | @property 19 | def display_name(self): 20 | return self.media_specific_attributes.display_name 21 | 22 | @display_name.setter 23 | def display_name(self, value): 24 | self.media_specific_attributes.display_name = value 25 | 26 | @property 27 | def vcard(self): 28 | return self.media_specific_attributes.vcard 29 | 30 | @vcard.setter 31 | def vcard(self, value): 32 | self.media_specific_attributes.vcard = value 33 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_iq_requestupload.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_media.protocolentities import RequestUploadIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | class RequestUploadIqProtocolEntityTest(IqProtocolEntityTest): 5 | def setUp(self): 6 | super(RequestUploadIqProtocolEntityTest, self).setUp() 7 | mediaNode = ProtocolTreeNode("encr_media", {"hash": "hash", "size": "1234", "orighash": "orighash", "type": "image"}) 8 | self.ProtocolEntity = RequestUploadIqProtocolEntity 9 | self.node.setAttribute("type", "set") 10 | self.node.addChild(mediaNode) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_iq_requestupload_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq_result import ResultIqProtocolEntityTest 2 | from yowsup.layers.protocol_media.protocolentities import ResultRequestUploadIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | class ResultRequestUploadIqProtocolEntityTest(ResultIqProtocolEntityTest): 5 | def setUp(self): 6 | super(ResultRequestUploadIqProtocolEntityTest, self).setUp() 7 | mediaNode = ProtocolTreeNode("encr_media", {"url": "url", "ip": "1.2.3.4"}) 8 | self.ProtocolEntity = ResultRequestUploadIqProtocolEntity 9 | self.node.addChild(mediaNode) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.message_media import MediaMessageProtocolEntity 2 | from yowsup.layers.protocol_messages.protocolentities.test_message import MessageProtocolEntityTest 3 | from yowsup.structs import ProtocolTreeNode 4 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 5 | 6 | 7 | class MediaMessageProtocolEntityTest(MessageProtocolEntityTest): 8 | def setUp(self): 9 | super(MediaMessageProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = MediaMessageProtocolEntity 11 | proto_node = ProtocolTreeNode("proto", {"mediatype": "image"}, None, Message().SerializeToString()) 12 | self.node.addChild(proto_node) 13 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media_contact.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.test_message_media import MediaMessageProtocolEntityTest 2 | from yowsup.layers.protocol_media.protocolentities import ContactMediaMessageProtocolEntity 3 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 4 | 5 | 6 | class ContactMediaMessageProtocolEntityTest(MediaMessageProtocolEntityTest): 7 | def setUp(self): 8 | super(ContactMediaMessageProtocolEntityTest, self).setUp() 9 | self.ProtocolEntity = ContactMediaMessageProtocolEntity 10 | m = Message() 11 | contact_message = Message.ContactMessage() 12 | contact_message.display_name = "abc" 13 | contact_message.vcard = b"VCARD_DATA" 14 | m.contact_message.MergeFrom(contact_message) 15 | proto_node = self.node.getChild("proto") 16 | proto_node["mediatype"] = "contact" 17 | proto_node.setData(m.SerializeToString()) 18 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media_downloadable_audio.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.message_media_downloadable_audio import AudioDownloadableMediaMessageProtocolEntity 2 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 3 | from .test_message_media import MediaMessageProtocolEntityTest 4 | 5 | 6 | class AudioDownloadableMediaMessageProtocolEntityTest(MediaMessageProtocolEntityTest): 7 | def setUp(self): 8 | super(AudioDownloadableMediaMessageProtocolEntityTest, self).setUp() 9 | self.ProtocolEntity = AudioDownloadableMediaMessageProtocolEntity 10 | proto_node = self.node.getChild("proto") 11 | m = Message() 12 | media_message = Message.AudioMessage() 13 | media_message.url = "url" 14 | media_message.mimetype = "audio/ogg" 15 | media_message.file_sha256 = b"SHA256" 16 | media_message.file_length = 123 17 | media_message.media_key = b"MEDIA_KEY" 18 | media_message.seconds = 24 19 | media_message.ptt = True 20 | m.audio_message.MergeFrom(media_message) 21 | proto_node.setData(m.SerializeToString()) 22 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media_downloadable_image.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.message_media_downloadable_image \ 2 | import ImageDownloadableMediaMessageProtocolEntity 3 | from .test_message_media import MediaMessageProtocolEntityTest 4 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 5 | 6 | 7 | class ImageDownloadableMediaMessageProtocolEntityTest(MediaMessageProtocolEntityTest): 8 | def setUp(self): 9 | super(ImageDownloadableMediaMessageProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = ImageDownloadableMediaMessageProtocolEntity 11 | proto_node = self.node.getChild("proto") 12 | m = Message() 13 | media_message = Message.ImageMessage() 14 | media_message.url = "url" 15 | media_message.mimetype = "image/jpeg" 16 | media_message.caption = "caption" 17 | media_message.file_sha256 = b"SHA256" 18 | media_message.file_length = 123 19 | media_message.height = 20 20 | media_message.width = 20 21 | media_message.media_key = b"MEDIA_KEY" 22 | media_message.jpeg_thumbnail = b"THUMBNAIL" 23 | m.image_message.MergeFrom(media_message) 24 | proto_node.setData(m.SerializeToString()) 25 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media_downloadable_video.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.message_media_downloadable_video \ 2 | import VideoDownloadableMediaMessageProtocolEntity 3 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 4 | from .test_message_media import MediaMessageProtocolEntityTest 5 | 6 | 7 | class VideoDownloadableMediaMessageProtocolEntityTest(MediaMessageProtocolEntityTest): 8 | def setUp(self): 9 | super(VideoDownloadableMediaMessageProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = VideoDownloadableMediaMessageProtocolEntity 11 | proto_node = self.node.getChild("proto") 12 | m = Message() 13 | media_message = Message.VideoMessage() 14 | media_message.url = "url" 15 | media_message.mimetype = "video/mp4" 16 | media_message.caption = "caption" 17 | media_message.file_sha256 = b"shaval" 18 | media_message.file_length = 4 19 | media_message.width = 1 20 | media_message.height = 2 21 | media_message.seconds = 3 22 | media_message.media_key = b"MEDIA_KEY" 23 | media_message.jpeg_thumbnail = b"THUMBNAIL" 24 | media_message.gif_attribution = 0 25 | media_message.gif_playback = False 26 | media_message.streaming_sidecar = b'' 27 | m.video_message.MergeFrom(media_message) 28 | proto_node.setData(m.SerializeToString()) 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_media/protocolentities/test_message_media_location.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_media.protocolentities.test_message_media import MediaMessageProtocolEntityTest 2 | from yowsup.layers.protocol_media.protocolentities import LocationMediaMessageProtocolEntity 3 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 4 | 5 | 6 | class LocationMediaMessageProtocolEntityTest(MediaMessageProtocolEntityTest): 7 | def setUp(self): 8 | super(LocationMediaMessageProtocolEntityTest, self).setUp() 9 | self.ProtocolEntity = LocationMediaMessageProtocolEntity 10 | 11 | m = Message() 12 | location_message = Message.LocationMessage() 13 | location_message.degrees_latitude = 30.089037 14 | location_message.degrees_longitude = 31.319488 15 | location_message.name = "kaos" 16 | location_message.url = "kaos_url" 17 | 18 | m.location_message.MergeFrom(location_message) 19 | 20 | proto_node = self.node.getChild("proto") 21 | proto_node["mediatype"] = "location" 22 | proto_node.setData(m.SerializeToString()) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowMessagesProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/proto/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/layers/protocol_messages/proto/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .message_text import TextMessageProtocolEntity 2 | from .message import MessageProtocolEntity 3 | from .message_text_broadcast import BroadcastTextMessage 4 | from .message_extendedtext import ExtendedTextMessageProtocolEntity 5 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/attributes_contact.py: -------------------------------------------------------------------------------- 1 | class ContactAttributes(object): 2 | def __init__(self, display_name, vcard, context_info=None): 3 | self._display_name = display_name 4 | self._vcard = vcard 5 | self._context_info = context_info 6 | 7 | def __str__(self): 8 | attrs = [] 9 | if self.display_name is not None: 10 | attrs.append(("display_name", self.display_name)) 11 | if self.vcard is not None: 12 | attrs.append(("vcard", "[binary data]")) 13 | if self.context_info is not None: 14 | attrs.append(("context_info", self.context_info)) 15 | 16 | return "[%s]" % " ".join((map(lambda item: "%s=%s" % item, attrs))) 17 | 18 | @property 19 | def display_name(self): 20 | return self._display_name 21 | 22 | @display_name.setter 23 | def display_name(self, value): 24 | self._display_name = value 25 | 26 | @property 27 | def vcard(self): 28 | return self._vcard 29 | 30 | @vcard.setter 31 | def vcard(self, value): 32 | self._vcard = value 33 | 34 | @property 35 | def context_info(self): 36 | return self._context_info 37 | 38 | @context_info.setter 39 | def context_info(self, value): 40 | self.context_info = value 41 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/attributes_media.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_context_info import ContextInfoAttributes 2 | 3 | 4 | class MediaAttributes(object): 5 | def __init__(self, context_info=None): 6 | """ 7 | :type context_info: ContextInfo | None 8 | """ 9 | if context_info: 10 | assert type(context_info) is ContextInfoAttributes, type(context_info) 11 | self._context_info = context_info # type: ContextInfoAttributes | None 12 | else: 13 | self._context_info = None 14 | 15 | @property 16 | def context_info(self): 17 | return self._context_info 18 | 19 | @context_info.setter 20 | def context_info(self, value): 21 | assert type(value) is ContextInfoAttributes, type(value) 22 | self._context_info = value 23 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/attributes_message_meta.py: -------------------------------------------------------------------------------- 1 | class MessageMetaAttributes(object): 2 | def __init__( 3 | self, id=None, sender=None, recipient=None, notify=None, timestamp=None, participant=None, offline=None, 4 | retry=None 5 | ): 6 | assert (sender or recipient), "Must specify either sender or recipient " \ 7 | "jid to create the message " 8 | assert not (sender and recipient), "Can't set both attributes to message at same " \ 9 | "time (sender, recipient) " 10 | self.id = id 11 | self.sender = sender 12 | self.recipient = recipient 13 | self.notify = notify 14 | self.timestamp = int(timestamp) if timestamp else None 15 | self.participant = participant 16 | self.offline = offline in ("1", True) 17 | self.retry = int(retry) if retry else None 18 | 19 | @staticmethod 20 | def from_message_protocoltreenode(node): 21 | return MessageMetaAttributes( 22 | node["id"], node["from"], node["to"], node["notify"], node["t"], node["participant"], node["offline"], 23 | node["retry"] 24 | ) 25 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/attributes_protocol.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_message_key import MessageKeyAttributes 2 | 3 | 4 | class ProtocolAttributes(object): 5 | TYPE_REOVOKE = 0 6 | TYPES = { 7 | TYPE_REOVOKE: "REVOKE" 8 | } 9 | 10 | def __init__(self, key, type): 11 | self.key = key 12 | self.type = type 13 | 14 | def __str__(self): 15 | return "[type=%s, key=%s]" % (self.TYPES[self.type], self.key) 16 | 17 | @property 18 | def key(self): 19 | return self._key 20 | 21 | @key.setter 22 | def key(self, value): 23 | assert isinstance(value, MessageKeyAttributes), type(value) 24 | self._key = value 25 | 26 | @property 27 | def type(self): 28 | return self._type 29 | 30 | @type.setter 31 | def type(self, value): 32 | assert value in self.TYPES, "Unknown type: %s" % value 33 | self._type = value 34 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/attributes/attributes_sender_key_distribution_message.py: -------------------------------------------------------------------------------- 1 | class SenderKeyDistributionMessageAttributes(object): 2 | def __init__(self, group_id, axolotl_sender_key_distribution_message): 3 | self._group_id = group_id 4 | self._axolotl_sender_key_distribution_message = axolotl_sender_key_distribution_message 5 | 6 | def __str__(self): 7 | attrs = [] 8 | if self.group_id is not None: 9 | attrs.append(("group_id", self.group_id)) 10 | if self.axolotl_sender_key_distribution_message is not None: 11 | attrs.append(("axolotl_sender_key_distribution_message", "[binary omitted]")) 12 | 13 | return "[%s]" % " ".join((map(lambda item: "%s=%s" % item, attrs))) 14 | 15 | @property 16 | def group_id(self): 17 | return self._group_id 18 | 19 | @group_id.setter 20 | def group_id(self, value): 21 | self._group_id = value 22 | 23 | @property 24 | def axolotl_sender_key_distribution_message(self): 25 | return self._axolotl_sender_key_distribution_message 26 | 27 | @axolotl_sender_key_distribution_message.setter 28 | def axolotl_sender_key_distribution_message(self, value): 29 | self._axolotl_sender_key_distribution_message = value 30 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/message_extendedtext.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_message_meta import MessageMetaAttributes 2 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_extendedtext import ExtendedTextAttributes 3 | from yowsup.layers.protocol_messages.protocolentities.protomessage import ProtomessageProtocolEntity 4 | from yowsup.layers.protocol_messages.protocolentities.attributes.attributes_message import MessageAttributes 5 | 6 | 7 | class ExtendedTextMessageProtocolEntity(ProtomessageProtocolEntity): 8 | def __init__(self, extended_text_attrs, message_meta_attrs): 9 | # type: (ExtendedTextAttributes, MessageMetaAttributes) -> None 10 | super(ExtendedTextMessageProtocolEntity, self).__init__( 11 | "text", MessageAttributes(extended_text=extended_text_attrs), message_meta_attrs 12 | ) 13 | 14 | @property 15 | def text(self): 16 | return self.message_attributes.extended_text.text 17 | 18 | @text.setter 19 | def text(self, value): 20 | self.message_attributes.extended_text.text = value 21 | 22 | @property 23 | def context_info(self): 24 | return self.message_attributes.extended_text.context_info 25 | 26 | @context_info.setter 27 | def context_info(self, value): 28 | self.message_attributes.extended_text.context_info = value 29 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/message_text.py: -------------------------------------------------------------------------------- 1 | from .protomessage import ProtomessageProtocolEntity 2 | from .message import MessageMetaAttributes 3 | from .attributes.attributes_message import MessageAttributes 4 | 5 | 6 | class TextMessageProtocolEntity(ProtomessageProtocolEntity): 7 | def __init__(self, body, message_meta_attributes=None, to=None): 8 | # flexible attributes for temp backwards compat 9 | assert(bool(message_meta_attributes) ^ bool(to)), "Either set message_meta_attributes, or to, and not both" 10 | if to: 11 | message_meta_attributes = MessageMetaAttributes(recipient=to) 12 | super(TextMessageProtocolEntity, self).__init__("text", MessageAttributes(body), message_meta_attributes) 13 | self.setBody(body) 14 | 15 | @property 16 | def conversation(self): 17 | return self.message_attributes.conversation 18 | 19 | @conversation.setter 20 | def conversation(self, value): 21 | self.message_attributes.conversation = value 22 | 23 | def getBody(self): 24 | #obsolete 25 | return self.conversation 26 | 27 | def setBody(self, body): 28 | #obsolete 29 | self.conversation = body 30 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/message_text_broadcast.py: -------------------------------------------------------------------------------- 1 | from .message_text import TextMessageProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | import time 4 | class BroadcastTextMessage(TextMessageProtocolEntity): 5 | def __init__(self, jids, body): 6 | broadcastTime = int(time.time() * 1000) 7 | super(BroadcastTextMessage, self).__init__(body, to = "%s@broadcast" % broadcastTime) 8 | self.setBroadcastProps(jids) 9 | 10 | def setBroadcastProps(self, jids): 11 | assert type(jids) is list, "jids must be a list, got %s instead." % type(jids) 12 | self.jids = jids 13 | 14 | def toProtocolTreeNode(self): 15 | node = super(BroadcastTextMessage, self).toProtocolTreeNode() 16 | toNodes = [ProtocolTreeNode("to", {"jid": jid}) for jid in self.jids] 17 | broadcastNode = ProtocolTreeNode("broadcast", children = toNodes) 18 | node.addChild(broadcastNode) 19 | return node 20 | 21 | @staticmethod 22 | def fromProtocolTreeNode(node): 23 | entity = TextMessageProtocolEntity.fromProtocolTreeNode(node) 24 | entity.__class__ = BroadcastTextMessage 25 | jids = [toNode.getAttributeValue("jid") for toNode in node.getChild("broadcast").getAllChildren()] 26 | entity.setBroadcastProps(jids) 27 | return entity 28 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/proto.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class ProtoProtocolEntity(ProtocolEntity): 3 | 4 | def __init__(self, protoData, mediaType = None): 5 | super(ProtoProtocolEntity, self).__init__("proto") 6 | self.mediaType = mediaType 7 | self.protoData = protoData 8 | 9 | def getProtoData(self): 10 | return self.protoData 11 | 12 | def getMediaType(self): 13 | return self.mediaType 14 | 15 | def toProtocolTreeNode(self): 16 | attribs = {} 17 | if self.mediaType: 18 | attribs["mediatype"] = self.mediaType 19 | return ProtocolTreeNode("proto", attribs, data=self.protoData) 20 | 21 | @staticmethod 22 | def fromProtocolTreeNode(node): 23 | return ProtoProtocolEntity(node.data, node["mediatype"]) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/test_message.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.message import MessageProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class MessageProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = MessageProtocolEntity 9 | # ORDER_MATTERS for node.toString() to output return attribs in same order 10 | attribs = { 11 | "type": "message_type", 12 | "id": "message-id", 13 | "t": "12345", 14 | "offline": "0", 15 | "from": "from_jid", 16 | "notify": "notify_name" 17 | } 18 | self.node = ProtocolTreeNode("message", attribs) 19 | 20 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/test_message_text.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.message_text import TextMessageProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.protocol_messages.protocolentities.test_message import MessageProtocolEntityTest 4 | from yowsup.layers.protocol_messages.proto.e2e_pb2 import Message 5 | 6 | 7 | class TextMessageProtocolEntityTest(MessageProtocolEntityTest): 8 | def setUp(self): 9 | super(TextMessageProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = TextMessageProtocolEntity 11 | m = Message() 12 | m.conversation = "body_data" 13 | proto_node = ProtocolTreeNode("proto", {}, None, m.SerializeToString()) 14 | self.node.addChild(proto_node) 15 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_messages/protocolentities/test_message_text_broadcast.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_messages.protocolentities.test_message_text import TextMessageProtocolEntityTest 2 | from yowsup.layers.protocol_messages.protocolentities.message_text_broadcast import BroadcastTextMessage 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | 6 | class BroadcastTextMessageTest(TextMessageProtocolEntityTest): 7 | def setUp(self): 8 | super(BroadcastTextMessageTest, self).setUp() 9 | self.ProtocolEntity = BroadcastTextMessage 10 | broadcastNode = ProtocolTreeNode("broadcast") 11 | jids = ["jid1", "jid2"] 12 | toNodes = [ProtocolTreeNode("to", {"jid" : jid}) for jid in jids] 13 | broadcastNode.addChildren(toNodes) 14 | self.node.addChild(broadcastNode) 15 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowNotificationsProtocolLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .notification import NotificationProtocolEntity 2 | from .notification_picture import PictureNotificationProtocolEntity 3 | from .notification_picture_set import SetPictureNotificationProtocolEntity 4 | from .notification_picture_delete import DeletePictureNotificationProtocolEntity 5 | from .notification_status import StatusNotificationProtocolEntity 6 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/notification_picture.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .notification import NotificationProtocolEntity 3 | class PictureNotificationProtocolEntity(NotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | ''' 9 | 10 | def __init__(self, _id, _from, status, timestamp, notify, offline, setJid, setId): 11 | super(PictureNotificationProtocolEntity, self).__init__("picture", _id, _from, timestamp, notify, offline) 12 | self.setData(setJid, setId) 13 | 14 | @staticmethod 15 | def fromProtocolTreeNode(node): 16 | entity = NotificationProtocolEntity.fromProtocolTreeNode(node) 17 | entity.__class__ = PictureNotificationProtocolEntity 18 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/notification_status.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .notification import NotificationProtocolEntity 3 | class StatusNotificationProtocolEntity(NotificationProtocolEntity): 4 | ''' 5 | 7 | 8 | {{STATUS}} 9 | 10 | 11 | 12 | ''' 13 | 14 | def __init__(self, _type, _id, _from, status, timestamp, notify, offline = False): 15 | super(StatusNotificationProtocolEntity, self).__init__("status", _id, _from, timestamp, notify, offline) 16 | self.setStatus(status) 17 | 18 | def setStatus(self, status): 19 | self.status = status 20 | 21 | def toProtocolTreeNode(self): 22 | node = super(StatusNotificationProtocolEntity, self).toProtocolTreeNode() 23 | setNode = ProtocolTreeNode("set", {}, None, self.status) 24 | node.addChild(setNode) 25 | return node 26 | 27 | @staticmethod 28 | def fromProtocolTreeNode(node): 29 | entity = NotificationProtocolEntity.fromProtocolTreeNode(node) 30 | entity.__class__ = StatusNotificationProtocolEntity 31 | entity.setStatus(node.getChild("set").getData()) 32 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/test_notification.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.notification import NotificationProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class NotificationProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = NotificationProtocolEntity 9 | attribs = { 10 | "t": "12345", 11 | "from": "from_jid", 12 | "offline": "0", 13 | "type": "notif_type", 14 | "id": "message-id", 15 | "notify": "notify_name" 16 | } 17 | self.node = ProtocolTreeNode("notification", attribs) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/test_notification_picture.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.notification_picture import PictureNotificationProtocolEntity 2 | from yowsup.layers.protocol_notifications.protocolentities.test_notification import NotificationProtocolEntityTest 3 | 4 | class PictureNotificationProtocolEntityTest(NotificationProtocolEntityTest): 5 | def setUp(self): 6 | super(PictureNotificationProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = PictureNotificationProtocolEntity 8 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/test_notification_picture_delete.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.notification_picture_delete import DeletePictureNotificationProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.protocol_notifications.protocolentities.test_notification_picture import PictureNotificationProtocolEntityTest 4 | 5 | class DeletePictureNotificationProtocolEntityTest(PictureNotificationProtocolEntityTest): 6 | def setUp(self): 7 | super(DeletePictureNotificationProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = DeletePictureNotificationProtocolEntity 9 | deleteNode = ProtocolTreeNode("delete", {"jid": "DELETE_JID"}, None, None) 10 | self.node.addChild(deleteNode) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/test_notification_picture_set.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.notification_picture_set import SetPictureNotificationProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.protocol_notifications.protocolentities.test_notification_picture import PictureNotificationProtocolEntityTest 4 | 5 | class SetPictureNotificationProtocolEntityTest(PictureNotificationProtocolEntityTest): 6 | def setUp(self): 7 | super(SetPictureNotificationProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = SetPictureNotificationProtocolEntity 9 | setNode = ProtocolTreeNode("set", {"jid": "SET_JID", "id": "123"}, None, None) 10 | self.node.addChild(setNode) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_notifications/protocolentities/test_notification_status.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_notifications.protocolentities.notification_status import StatusNotificationProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.layers.protocol_notifications.protocolentities.test_notification import NotificationProtocolEntityTest 4 | 5 | class StatusNotificationProtocolEntityTest(NotificationProtocolEntityTest): 6 | def setUp(self): 7 | super(StatusNotificationProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = StatusNotificationProtocolEntity 9 | setNode = ProtocolTreeNode("set", {}, [], b"status_data") 10 | self.node.addChild(setNode) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowPresenceProtocolLayer 2 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer, YowLayerEvent, YowProtocolLayer 2 | from .protocolentities import * 3 | from yowsup.layers.protocol_iq.protocolentities import ErrorIqProtocolEntity 4 | class YowPresenceProtocolLayer(YowProtocolLayer): 5 | def __init__(self): 6 | handleMap = { 7 | "presence": (self.recvPresence, self.sendPresence), 8 | "iq": (None, self.sendIq) 9 | } 10 | super(YowPresenceProtocolLayer, self).__init__(handleMap) 11 | 12 | def __str__(self): 13 | return "Presence Layer" 14 | 15 | def sendPresence(self, entity): 16 | self.entityToLower(entity) 17 | 18 | def recvPresence(self, node): 19 | self.toUpper(PresenceProtocolEntity.fromProtocolTreeNode(node)) 20 | 21 | def sendIq(self, entity): 22 | if entity.getXmlns() == LastseenIqProtocolEntity.XMLNS: 23 | self._sendIq(entity, self.onLastSeenSuccess, self.onLastSeenError) 24 | 25 | def onLastSeenSuccess(self, protocolTreeNode, lastSeenEntity): 26 | self.toUpper(ResultLastseenIqProtocolEntity.fromProtocolTreeNode(protocolTreeNode)) 27 | 28 | def onLastSeenError(self, protocolTreeNode, lastSeenEntity): 29 | self.toUpper(ErrorIqProtocolEntity.fromProtocolTreeNode(protocolTreeNode)) 30 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .presence import PresenceProtocolEntity 2 | from .presence_available import AvailablePresenceProtocolEntity 3 | from .presence_unavailable import UnavailablePresenceProtocolEntity 4 | from .presence_subscribe import SubscribePresenceProtocolEntity 5 | from .presence_unsubscribe import UnsubscribePresenceProtocolEntity 6 | from .iq_lastseen import LastseenIqProtocolEntity 7 | from .iq_lastseen_result import ResultLastseenIqProtocolEntity 8 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/iq_lastseen.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.iq import IqProtocolEntity 2 | from yowsup.structs.protocoltreenode import ProtocolTreeNode 3 | class LastseenIqProtocolEntity(IqProtocolEntity): 4 | XMLNS = "jabber:iq:last" 5 | def __init__(self, jid, _id = None): 6 | super(LastseenIqProtocolEntity, self).__init__(self.__class__.XMLNS, _type = "get", to = jid, _id = _id) 7 | 8 | @staticmethod 9 | def fromProtocolTreeNode(node): 10 | return LastseenIqProtocolEntity(node["to"]) 11 | 12 | def toProtocolTreeNode(self): 13 | node = super(LastseenIqProtocolEntity, self).toProtocolTreeNode() 14 | node.setAttribute("xmlns", self.__class__.XMLNS) 15 | node.addChild(ProtocolTreeNode("query")) 16 | return node 17 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/iq_lastseen_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.iq_result import ResultIqProtocolEntity 2 | from yowsup.structs.protocoltreenode import ProtocolTreeNode 3 | class ResultLastseenIqProtocolEntity(ResultIqProtocolEntity): 4 | def __init__(self, jid, seconds, _id = None): 5 | super(ResultLastseenIqProtocolEntity, self).__init__(_from=jid, _id=_id) 6 | self.setSeconds(seconds) 7 | 8 | def setSeconds(self, seconds): 9 | self.seconds = int(seconds) 10 | 11 | def getSeconds(self): 12 | return self.seconds 13 | 14 | def __str__(self): 15 | out = super(ResultIqProtocolEntity, self).__str__() 16 | out += "Seconds: %s\n" % self.seconds 17 | return out 18 | 19 | def toProtocolTreeNode(self): 20 | node = super(ResultLastseenIqProtocolEntity, self).toProtocolTreeNode() 21 | node.addChild(ProtocolTreeNode("query", {"seconds": str(self.seconds)})) 22 | return node 23 | 24 | @staticmethod 25 | def fromProtocolTreeNode(node): 26 | return ResultLastseenIqProtocolEntity(node["from"], node.getChild("query")["seconds"], node["id"]) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/presence_available.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .presence import PresenceProtocolEntity 3 | class AvailablePresenceProtocolEntity(PresenceProtocolEntity): 4 | ''' 5 | 6 | response: 7 | 8 | 9 | 10 | ''' 11 | def __init__(self): 12 | super(AvailablePresenceProtocolEntity, self).__init__("available") -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/presence_subscribe.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .presence import PresenceProtocolEntity 3 | class SubscribePresenceProtocolEntity(PresenceProtocolEntity): 4 | 5 | ''' 6 | 7 | ''' 8 | 9 | def __init__(self, jid): 10 | super(SubscribePresenceProtocolEntity, self).__init__("subscribe") 11 | self.setProps(jid) 12 | 13 | def setProps(self, jid): 14 | self.jid = jid 15 | 16 | def toProtocolTreeNode(self): 17 | node = super(SubscribePresenceProtocolEntity, self).toProtocolTreeNode() 18 | node.setAttribute("to", self.jid) 19 | return node 20 | 21 | def __str__(self): 22 | out = super(SubscribePresenceProtocolEntity, self).__str__() 23 | out += "To: %s\n" % self.jid 24 | return out 25 | 26 | @staticmethod 27 | def fromProtocolTreeNode(node): 28 | entity = PresenceProtocolEntity.fromProtocolTreeNode(node) 29 | entity.__class__ = SubscribePresenceProtocolEntity 30 | entity.setProps( 31 | node.getAttributeValue("to") 32 | ) 33 | return entity 34 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/presence_unavailable.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .presence import PresenceProtocolEntity 3 | class UnavailablePresenceProtocolEntity(PresenceProtocolEntity): 4 | ''' 5 | 6 | response: 7 | 8 | 9 | ''' 10 | def __init__(self): 11 | super(UnavailablePresenceProtocolEntity, self).__init__("unavailable") -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/presence_unsubscribe.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | from .presence import PresenceProtocolEntity 3 | class UnsubscribePresenceProtocolEntity(PresenceProtocolEntity): 4 | 5 | ''' 6 | 7 | ''' 8 | 9 | def __init__(self, jid): 10 | super(UnsubscribePresenceProtocolEntity, self).__init__("unsubscribe") 11 | self.setProps(jid) 12 | 13 | def setProps(self, jid): 14 | self.jid = jid 15 | 16 | def toProtocolTreeNode(self): 17 | node = super(UnsubscribePresenceProtocolEntity, self).toProtocolTreeNode() 18 | node.setAttribute("to", self.jid) 19 | return node 20 | 21 | def __str__(self): 22 | out = super(UnsubscribePresenceProtocolEntity, self).__str__() 23 | out += "To: %s\n" % self.jid 24 | return out 25 | 26 | @staticmethod 27 | def fromProtocolTreeNode(node): 28 | entity = PresenceProtocolEntity.fromProtocolTreeNode(node) 29 | entity.__class__ = UnsubscribePresenceProtocolEntity 30 | entity.setProps( 31 | node.getAttributeValue("to") 32 | ) 33 | return entity 34 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/test_presence.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_presence.protocolentities.presence import PresenceProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | from yowsup.structs.protocolentity import ProtocolEntityTest 4 | import unittest 5 | 6 | class PresenceProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = PresenceProtocolEntity 9 | self.node = ProtocolTreeNode("presence", {"type": "presence_type", "name": "presence_name"}, None, None) 10 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/test_presence_available.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_presence.protocolentities.presence_available import AvailablePresenceProtocolEntity 2 | from yowsup.layers.protocol_presence.protocolentities.test_presence import PresenceProtocolEntityTest 3 | 4 | class AvailablePresenceProtocolEntityTest(PresenceProtocolEntityTest): 5 | def setUp(self): 6 | super(AvailablePresenceProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = AvailablePresenceProtocolEntity 8 | self.node.setAttribute("type", "available") 9 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/test_presence_subscribe.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_presence.protocolentities.presence_subscribe import SubscribePresenceProtocolEntity 2 | from yowsup.layers.protocol_presence.protocolentities.test_presence import PresenceProtocolEntityTest 3 | 4 | class SubscribePresenceProtocolEntityTest(PresenceProtocolEntityTest): 5 | def setUp(self): 6 | super(SubscribePresenceProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = SubscribePresenceProtocolEntity 8 | self.node.setAttribute("type", "subscribe") 9 | self.node.setAttribute("to", "subscribe_jid") -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/test_presence_unavailable.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_presence.protocolentities.presence_unavailable import UnavailablePresenceProtocolEntity 2 | from yowsup.layers.protocol_presence.protocolentities.test_presence import PresenceProtocolEntityTest 3 | 4 | class UnavailablePresenceProtocolEntityTest(PresenceProtocolEntityTest): 5 | def setUp(self): 6 | super(UnavailablePresenceProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = UnavailablePresenceProtocolEntity 8 | self.node.setAttribute("type", "unavailable") 9 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_presence/protocolentities/test_presence_unsubscribe.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_presence.protocolentities.presence_unsubscribe import UnsubscribePresenceProtocolEntity 2 | from yowsup.layers.protocol_presence.protocolentities.test_presence import PresenceProtocolEntityTest 3 | 4 | class UnsubscribePresenceProtocolEntityTest(PresenceProtocolEntityTest): 5 | def setUp(self): 6 | super(UnsubscribePresenceProtocolEntityTest, self).setUp() 7 | self.ProtocolEntity = UnsubscribePresenceProtocolEntity 8 | self.node.setAttribute("type", "unsubscribe") 9 | self.node.setAttribute("to", "some_jid") -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_privacy/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowPrivacyProtocolLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_privacy/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer, YowLayerEvent, YowProtocolLayer 2 | from .protocolentities import * 3 | class YowPrivacyProtocolLayer(YowProtocolLayer): 4 | def __init__(self): 5 | handleMap = { 6 | "iq": (self.recvIq, self.sendIq) 7 | } 8 | super(YowPrivacyProtocolLayer, self).__init__(handleMap) 9 | 10 | def __str__(self): 11 | return "Privacy Layer" 12 | 13 | def sendIq(self, entity): 14 | if entity.getXmlns() == "jabber:iq:privacy": 15 | self.entityToLower(entity) 16 | 17 | def recvIq(self, node): 18 | pass 19 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_privacy/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .privacylist_iq import PrivacyListIqProtocolEntity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_privacy/protocolentities/privacylist_iq.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | class PrivacyListIqProtocolEntity(IqProtocolEntity): 4 | def __init__(self, name = "default"): 5 | super(PrivacyListIqProtocolEntity, self).__init__("jabber:iq:privacy", _type="get") 6 | self.setListName(name) 7 | 8 | def setListName(self, name): 9 | self.listName = name 10 | 11 | def toProtocolTreeNode(self): 12 | node = super(PrivacyListIqProtocolEntity, self).toProtocolTreeNode() 13 | queryNode = ProtocolTreeNode("query") 14 | listNode = ProtocolTreeNode("list", {"name": self.listName}) 15 | queryNode.addChild(listNode) 16 | node.addChild(queryNode) 17 | return node 18 | 19 | @staticmethod 20 | def fromProtocolTreeNode(node): 21 | entity = IqProtocolEntity.fromProtocolTreeNode(node) 22 | entity.__class__ = PrivacyListIqProtocolEntity 23 | entity.setListName(node.getChild("query").getChild("list")["name"]) 24 | return entity 25 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowProfilesProtocolLayer -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .iq_unregister import UnregisterIqProtocolEntity 2 | from .iq_status_set import SetStatusIqProtocolEntity 3 | from .iq_statuses_get import GetStatusesIqProtocolEntity 4 | from .iq_statuses_result import ResultStatusesIqProtocolEntity 5 | from .iq_picture_get import GetPictureIqProtocolEntity 6 | from .iq_picture_get_result import ResultGetPictureIqProtocolEntity 7 | from .iq_pictures_list import ListPicturesIqProtocolEntity 8 | from .iq_picture_set import SetPictureIqProtocolEntity 9 | from .iq_privacy_set import SetPrivacyIqProtocolEntity 10 | from .iq_privacy_get import GetPrivacyIqProtocolEntity 11 | from .iq_privacy_result import ResultPrivacyIqProtocolEntity 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/iq_picture.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities import IqProtocolEntity 2 | class PictureIqProtocolEntity(IqProtocolEntity): 3 | ''' 4 | When receiving a profile picture: 5 | 6 | 7 | {{Binary bytes of the picture.}} 8 | 9 | 10 | ''' 11 | XMLNS = "w:profile:picture" 12 | 13 | def __init__(self, jid, _id = None, type = "get"): 14 | super(PictureIqProtocolEntity, self).__init__(self.__class__.XMLNS, _id = _id, _type=type, to = jid) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/iq_picture_get.py: -------------------------------------------------------------------------------- 1 | from .iq_picture import PictureIqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | class GetPictureIqProtocolEntity(PictureIqProtocolEntity): 4 | ''' 5 | 6 | 7 | 8 | ''' 9 | def __init__(self, jid, preview = True, _id = None): 10 | super(GetPictureIqProtocolEntity, self).__init__(jid, _id, "get") 11 | self.setGetPictureProps(preview) 12 | 13 | def setGetPictureProps(self, preview = True): 14 | self.preview = preview 15 | 16 | def isPreview(self): 17 | return self.preview 18 | 19 | def toProtocolTreeNode(self): 20 | node = super(GetPictureIqProtocolEntity, self).toProtocolTreeNode() 21 | pictureNode = ProtocolTreeNode("picture", {"type": "preview" if self.isPreview() else "image" }) 22 | node.addChild(pictureNode) 23 | return node 24 | 25 | @staticmethod 26 | def fromProtocolTreeNode(node): 27 | entity = PictureIqProtocolEntity.fromProtocolTreeNode(node) 28 | entity.__class__ = GetPictureIqProtocolEntity 29 | entity.setGetPictureProps(node.getChild("picture").getAttributeValue("type")) 30 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/iq_privacy_get.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities import IqProtocolEntity 2 | from yowsup.structs import ProtocolTreeNode 3 | 4 | ''' 5 | 6 | 7 | 8 | 9 | ''' 10 | 11 | class GetPrivacyIqProtocolEntity(IqProtocolEntity): 12 | XMLNS = "privacy" 13 | def __init__(self): 14 | super(GetPrivacyIqProtocolEntity, self).__init__(self.__class__.XMLNS, _type="get") 15 | 16 | def toProtocolTreeNode(self): 17 | node = super(GetPrivacyIqProtocolEntity, self).toProtocolTreeNode() 18 | queryNode = ProtocolTreeNode(self.__class__.XMLNS) 19 | node.addChild(queryNode) 20 | return node 21 | 22 | @staticmethod 23 | def fromProtocolTreeNode(node): 24 | assert node.getChild(GetPrivacyIqProtocolEntity.XMLNS) is not None, "Not a get privacy iq node %s" % node 25 | entity = IqProtocolEntity.fromProtocolTreeNode(node) 26 | entity.__class__ = GetPrivacyIqProtocolEntity 27 | return entity 28 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/iq_unregister.py: -------------------------------------------------------------------------------- 1 | from yowsup.common import YowConstants 2 | from yowsup.layers.protocol_iq.protocolentities import IqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | class UnregisterIqProtocolEntity(IqProtocolEntity): 6 | 7 | XMLNS = "urn:xmpp:whatsapp:account" 8 | 9 | def __init__(self): 10 | super(UnregisterIqProtocolEntity, self).__init__(_type = "get", to = YowConstants.WHATSAPP_SERVER) 11 | 12 | def toProtocolTreeNode(self): 13 | node = super(UnregisterIqProtocolEntity, self).toProtocolTreeNode() 14 | rmNode = ProtocolTreeNode("remove", {"xmlns": self.__class__.XMLNS}) 15 | node.addChild(rmNode) 16 | return node 17 | 18 | @staticmethod 19 | def fromProtocolTreeNode(node): 20 | entity = IqProtocolEntity.fromProtocolTreeNode(node) 21 | entity.__class__ = UnregisterIqProtocolEntity 22 | removeNode = node.getChild("remove") 23 | assert removeNode["xmlns"] == UnregisterIqProtocolEntity.XMLNS, "Not an account delete xmlns, got %s" % removeNode["xmlns"] 24 | 25 | return entity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/test_iq_privacy_get.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_profiles.protocolentities import GetPrivacyIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | entity = GetPrivacyIqProtocolEntity() 6 | 7 | class GetPrivacyIqProtocolEntityTest(IqProtocolEntityTest): 8 | def setUp(self): 9 | super(GetPrivacyIqProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = GetPrivacyIqProtocolEntity 11 | self.node = entity.toProtocolTreeNode() 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/test_iq_privacy_result.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_profiles.protocolentities import ResultPrivacyIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | entity = ResultPrivacyIqProtocolEntity({"profile":"all","last":"none","status":"contacts"}) 6 | 7 | class ResultPrivacyIqProtocolEntityTest(IqProtocolEntityTest): 8 | def setUp(self): 9 | super(ResultPrivacyIqProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = ResultPrivacyIqProtocolEntity 11 | self.node = entity.toProtocolTreeNode() 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/test_iq_privacy_set.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_profiles.protocolentities import SetPrivacyIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | entity = SetPrivacyIqProtocolEntity("all", ["profile","last","status"]) 6 | 7 | class SetPrivacyIqProtocolEntityTest(IqProtocolEntityTest): 8 | def setUp(self): 9 | super(SetPrivacyIqProtocolEntityTest, self).setUp() 10 | self.ProtocolEntity = SetPrivacyIqProtocolEntity 11 | self.node = entity.toProtocolTreeNode() 12 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/test_iq_status_set.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_profiles.protocolentities import SetStatusIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | class SetStatusIqProtocolEntityTest(IqProtocolEntityTest): 6 | def setUp(self): 7 | super(SetStatusIqProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = SetStatusIqProtocolEntity 9 | statusNode = ProtocolTreeNode("status", {}, [], b"Hey there, I'm using WhatsApp") 10 | self.node.addChild(statusNode) 11 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_profiles/protocolentities/test_iq_unregister.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_iq.protocolentities.test_iq import IqProtocolEntityTest 2 | from yowsup.layers.protocol_profiles.protocolentities import UnregisterIqProtocolEntity 3 | from yowsup.structs import ProtocolTreeNode 4 | 5 | class UnregisterIqProtocolEntityTest(IqProtocolEntityTest): 6 | def setUp(self): 7 | super(UnregisterIqProtocolEntityTest, self).setUp() 8 | self.ProtocolEntity = UnregisterIqProtocolEntity 9 | self.node.addChild(ProtocolTreeNode("remove", {"xmlns": "urn:xmpp:whatsapp:account"})) -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/__init__.py: -------------------------------------------------------------------------------- 1 | from .layer import YowReceiptProtocolLayer 2 | 3 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/layer.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers import YowLayer, YowLayerEvent, YowProtocolLayer 2 | from .protocolentities import * 3 | class YowReceiptProtocolLayer(YowProtocolLayer): 4 | def __init__(self): 5 | handleMap = { 6 | "receipt": (self.recvReceiptNode, self.sendReceiptEntity) 7 | } 8 | super(YowReceiptProtocolLayer, self).__init__(handleMap) 9 | 10 | def __str__(self): 11 | return "Receipt Layer" 12 | 13 | def sendReceiptEntity(self, entity): 14 | self.entityToLower(entity) 15 | 16 | def recvReceiptNode(self, node): 17 | self.toUpper(IncomingReceiptProtocolEntity.fromProtocolTreeNode(node)) 18 | 19 | 20 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/protocolentities/__init__.py: -------------------------------------------------------------------------------- 1 | from .receipt import ReceiptProtocolEntity 2 | from .receipt_incoming import IncomingReceiptProtocolEntity 3 | from .receipt_outgoing import OutgoingReceiptProtocolEntity -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/protocolentities/receipt.py: -------------------------------------------------------------------------------- 1 | from yowsup.structs import ProtocolEntity, ProtocolTreeNode 2 | class ReceiptProtocolEntity(ProtocolEntity): 3 | 4 | ''' 5 | delivered: 6 | 7 | 8 | read 9 | 10 | 11 | INCOMING 12 | 13 | ''' 14 | 15 | def __init__(self, _id): 16 | super(ReceiptProtocolEntity, self).__init__("receipt") 17 | self._id = _id 18 | 19 | def getId(self): 20 | return self._id 21 | 22 | def toProtocolTreeNode(self): 23 | attribs = { 24 | "id" : self._id 25 | } 26 | return self._createProtocolTreeNode(attribs, None, data = None) 27 | 28 | 29 | def __str__(self): 30 | out = "Receipt:\n" 31 | out += "ID: %s\n" % self._id 32 | return out 33 | 34 | @staticmethod 35 | def fromProtocolTreeNode(node): 36 | return ReceiptProtocolEntity( 37 | node.getAttributeValue("id") 38 | ) 39 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/protocolentities/test_receipt_incoming.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_receipts.protocolentities import IncomingReceiptProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | import time 5 | 6 | class IncomingReceiptProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 7 | def setUp(self): 8 | self.ProtocolEntity = IncomingReceiptProtocolEntity 9 | self.node = IncomingReceiptProtocolEntity("123", "sender", int(time.time())).toProtocolTreeNode() 10 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/layers/protocol_receipts/protocolentities/test_receipt_outgoing.py: -------------------------------------------------------------------------------- 1 | from yowsup.layers.protocol_receipts.protocolentities import OutgoingReceiptProtocolEntity 2 | from yowsup.structs.protocolentity import ProtocolEntityTest 3 | import unittest 4 | 5 | class OutgoingReceiptProtocolEntityTest(ProtocolEntityTest, unittest.TestCase): 6 | def setUp(self): 7 | self.ProtocolEntity = OutgoingReceiptProtocolEntity 8 | self.node = OutgoingReceiptProtocolEntity("123", "target", "read").toProtocolTreeNode() -------------------------------------------------------------------------------- /libs/yowsup/yowsup/profile/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/libs/yowsup/yowsup/profile/__init__.py -------------------------------------------------------------------------------- /libs/yowsup/yowsup/registration/__init__.py: -------------------------------------------------------------------------------- 1 | from .coderequest import WACodeRequest 2 | from .existsrequest import WAExistsRequest 3 | from .regrequest import WARegRequest -------------------------------------------------------------------------------- /libs/yowsup/yowsup/registration/existsrequest.py: -------------------------------------------------------------------------------- 1 | from yowsup.common.http.warequest import WARequest 2 | from yowsup.common.http.waresponseparser import JSONResponseParser 3 | from yowsup.env import YowsupEnv 4 | 5 | 6 | class WAExistsRequest(WARequest): 7 | 8 | def __init__(self, config): 9 | """ 10 | :param config: 11 | :type config: yowsup.config.v1.config.Config 12 | """ 13 | super(WAExistsRequest,self).__init__(config) 14 | if config.id is None: 15 | raise ValueError("Config does not contain id") 16 | 17 | self.url = "v.whatsapp.net/v2/exist" 18 | 19 | self.pvars = ["status", "reason", "sms_length", "voice_length", "result","param", "login", "type", 20 | "chat_dns_domain", "edge_routing_info" 21 | ] 22 | 23 | self.setParser(JSONResponseParser()) 24 | self.addParam("token", YowsupEnv.getCurrent().getToken(self._p_in)) 25 | -------------------------------------------------------------------------------- /libs/yowsup/yowsup/structs/__init__.py: -------------------------------------------------------------------------------- 1 | from .protocolentity import ProtocolEntity 2 | from .protocoltreenode import ProtocolTreeNode -------------------------------------------------------------------------------- /modules/__init__.py: -------------------------------------------------------------------------------- 1 | # Add here the modules you want to enable here 2 | from modules import hiExample 3 | -------------------------------------------------------------------------------- /modules/hiExample/__init__.py: -------------------------------------------------------------------------------- 1 | from app.mac import mac, signals 2 | 3 | ''' 4 | Signals this module listents to: 5 | 1. When a message is received (signals.command_received) 6 | ========================================================== 7 | ''' 8 | @signals.command_received.connect 9 | def handle(message): 10 | if message.command == "hi": 11 | hi(message) 12 | elif message.command == "help": 13 | help(message) 14 | 15 | ''' 16 | Actual module code 17 | ========================================================== 18 | ''' 19 | def hi(message): 20 | who_name = message.who_name 21 | answer = "Hi " + who_name 22 | mac.send_message(answer, message.conversation) 23 | 24 | def help(message): 25 | answer = "*Bot called mac* \nWhatsapp framework made in Python"+ 26 | "\n*Version:* 1.0.0 \n*Status:* Beta "+ 27 | "\nhttps://github.com/danielcardeenas/whatsapp-framework"+ 28 | "\nhttps://github.com/tgalal/yowsup"+ 29 | "\nhttps://github.com/devalexanderdaza/yowsapp-framework" 30 | mac.send_message(answer, message.conversation) 31 | -------------------------------------------------------------------------------- /modules/hihelp/__init__.py: -------------------------------------------------------------------------------- 1 | import threading 2 | import requests 3 | from app.mac import mac, signals 4 | 5 | @signals.message_received.connect 6 | def handle(message): 7 | BotRequest(message) 8 | 9 | class BotRequest(object): 10 | def __init__(self, msg): 11 | self.message = msg 12 | thread = threading.Thread(target=self.run, args=()) 13 | thread.daemon = True 14 | thread.start() 15 | 16 | def run(self): 17 | try: 18 | message = self.message 19 | # mac.send_message("Mensaje recibido: " + message.message, message.conversation) 20 | # requests.post('http://localhost:3001/paymentbot/whatsappwebhook', json={'event': 'INBOX', 'from': message.who, 'name': message.who_name, 'conversation': message.conversation, 'text': message.text, 'AppClient': 'Yowsup'}) 21 | except Exception as e: 22 | print(e) 23 | print("Error sending Orchestrator Request") 24 | -------------------------------------------------------------------------------- /modules/misdatos/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/devalexanderdaza/yowsapp-framework/62d73e932cdb26565cfc810f6aa84ff014adb63b/modules/misdatos/__init__.py -------------------------------------------------------------------------------- /start.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | until sudo python3 run.py; do 3 | echo "Whatsapp bot crashed with code $?. Respawning.." >&2 4 | sleep 1 5 | done -------------------------------------------------------------------------------- /yowsup.egg-info/PKG-INFO: -------------------------------------------------------------------------------- 1 | Metadata-Version: 1.1 2 | Name: yowsup 3 | Version: 3.2.0 4 | Summary: The WhatsApp lib 5 | Home-page: http://github.com/tgalal/yowsup/ 6 | Author: Tarek Galal 7 | Author-email: tare2.galal@gmail.com 8 | License: GPL-3+ 9 | Description: UNKNOWN 10 | Platform: any 11 | Classifier: Programming Language :: Python 12 | Classifier: Development Status :: 4 - Beta 13 | Classifier: Natural Language :: English 14 | Classifier: Intended Audience :: Developers 15 | Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+) 16 | Classifier: Operating System :: OS Independent 17 | Classifier: Topic :: Software Development :: Libraries :: Python Modules 18 | -------------------------------------------------------------------------------- /yowsup.egg-info/SOURCES.txt: -------------------------------------------------------------------------------- 1 | README.md 2 | app/__init__.py 3 | app/layer.py 4 | app/mac/__init__.py 5 | app/mac/layer.py 6 | app/mac/mac.py 7 | app/mac/run.py 8 | app/mac/signals.py 9 | app/models/__init__.py 10 | app/models/message.py 11 | app/models/receipt.py 12 | app/receiver/__init__.py 13 | app/receiver/receiver.py 14 | app/utils/__init__.py 15 | app/utils/downloader.py 16 | app/utils/helper.py 17 | app/utils/media_decrypter.py 18 | modules/__init__.py 19 | modules/hihelp/__init__.py 20 | modules/hihelp/hihelp.py 21 | modules/pokedex/__init__.py 22 | modules/pokedex/pykemon/__init__.py 23 | modules/pokedex/pykemon/api.py 24 | modules/pokedex/pykemon/exceptions.py 25 | modules/pokedex/pykemon/models.py 26 | modules/pokedex/pykemon/request.py 27 | modules/pokedex/pykemon/resources.py 28 | modules/poker/__init__.py 29 | modules/poker/constants.py 30 | modules/poker/player.py 31 | modules/poker/poker.py 32 | modules/poker/deuces/__init__.py 33 | modules/poker/deuces/card.py 34 | modules/poker/deuces/deck.py 35 | modules/poker/deuces/evaluator.py 36 | modules/poker/deuces/lookup.py 37 | modules/poll/__init__.py 38 | modules/poll/poll.py 39 | modules/poll/voter.py 40 | modules/poll2/__init__.py 41 | modules/poll2/poll2.py 42 | yowsup.egg-info/PKG-INFO 43 | yowsup.egg-info/SOURCES.txt 44 | yowsup.egg-info/dependency_links.txt 45 | yowsup.egg-info/requires.txt 46 | yowsup.egg-info/top_level.txt -------------------------------------------------------------------------------- /yowsup.egg-info/dependency_links.txt: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /yowsup.egg-info/requires.txt: -------------------------------------------------------------------------------- 1 | consonance==0.1.2 2 | argparse 3 | python-axolotl>=0.1.39 4 | six==1.10 5 | appdirs 6 | protobuf>=3.6.0 7 | -------------------------------------------------------------------------------- /yowsup.egg-info/top_level.txt: -------------------------------------------------------------------------------- 1 | app 2 | modules 3 | --------------------------------------------------------------------------------