{"action":"created","issue":{"url":"https://api.github.com/repos/tgalal/yowsup/issues/1648","repository_url":"https://api.github.com/repos/tgalal/yowsup","labels_url":"https://api.github.com/repos/tgalal/yowsup/issues/1648/labels{/name}","comments_url":"https://api.github.com/repos/tgalal/yowsup/issues/1648/comments","events_url":"https://api.github.com/repos/tgalal/yowsup/issues/1648/events","html_url":"https://github.com/tgalal/yowsup/issues/1648","id":160416595,"number":1648,"title":"Send presence","user":{"login":"langioletto","id":19941926,"avatar_url":"https://avatars.githubusercontent.com/u/19941926?v=3","gravatar_id":"","url":"https://api.github.com/users/langioletto","html_url":"https://github.com/langioletto","followers_url":"https://api.github.com/users/langioletto/followers","following_url":"https://api.github.com/users/langioletto/following{/other_user}","gists_url":"https://api.github.com/users/langioletto/gists{/gist_id}","starred_url":"https://api.github.com/users/langioletto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langioletto/subscriptions","organizations_url":"https://api.github.com/users/langioletto/orgs","repos_url":"https://api.github.com/users/langioletto/repos","events_url":"https://api.github.com/users/langioletto/events{/privacy}","received_events_url":"https://api.github.com/users/langioletto/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":50,"created_at":"2016-06-15T13:03:19Z","updated_at":"2016-07-18T22:32:43Z","closed_at":null,"body":"Hello tagal, can I ask you a few examples to send the presence before the answer\r\n\r\ntaking as example /yowsup/demos/echoclient\r\n\r\nreceive the message (it's already present)\r\nactive presence\r\nresponds (it's already present)\r\ndeactivates the presence\r\n\r\nThanks for your project, I donated.\r\n\r\n```\r\nfrom yowsup.layers.interface                           import YowInterfaceLayer, ProtocolEntityCallback\r\n\r\nclass EchoLayer(YowInterfaceLayer):\r\n\r\n    @ProtocolEntityCallback(\"message\")\r\n    def onMessage(self, messageProtocolEntity):\r\n\r\n        if messageProtocolEntity.getType() == 'text':\r\n            self.onTextMessage(messageProtocolEntity)\r\n        elif messageProtocolEntity.getType() == 'media':\r\n            self.onMediaMessage(messageProtocolEntity)\r\n\r\n        self.toLower(messageProtocolEntity.forward(messageProtocolEntity.getFrom()))\r\n        self.toLower(messageProtocolEntity.ack())\r\n        self.toLower(messageProtocolEntity.ack(True))\r\n\r\n\r\n    @ProtocolEntityCallback(\"receipt\")\r\n    def onReceipt(self, entity):\r\n        self.toLower(entity.ack())\r\n\r\n    def onTextMessage(self,messageProtocolEntity):\r\n        # just print info\r\n        print(\"Echoing %s to %s\" % (messageProtocolEntity.getBody(), messageProtocolEntity.getFrom(False)))\r\n\r\n    def onMediaMessage(self, messageProtocolEntity):\r\n        # just print info\r\n        if messageProtocolEntity.getMediaType() == \"image\":\r\n            print(\"Echoing image %s to %s\" % (messageProtocolEntity.url, messageProtocolEntity.getFrom(False)))\r\n\r\n        elif messageProtocolEntity.getMediaType() == \"location\":\r\n            print(\"Echoing location (%s, %s) to %s\" % (messageProtocolEntity.getLatitude(), messageProtocolEntity.getLongitude(), messageProtocolEntity.getFrom(False)))\r\n\r\n        elif messageProtocolEntity.getMediaType() == \"vcard\":\r\n            print(\"Echoing vcard (%s, %s) to %s\" % (messageProtocolEntity.getName(), messageProtocolEntity.getCardData(), messageProtocolEntity.getFrom(False)))\r\n\r\n```\r\nrun.py\r\n\r\n```\r\nfrom yowsup.stacks                             import YowStackBuilder\r\nfrom yowsup.layers.protocol_messages           import YowMessagesProtocolLayer\r\nfrom yowsup.layers.stanzaregulator             import YowStanzaRegulator\r\nfrom yowsup.layers.protocol_receipts           import YowReceiptProtocolLayer\r\nfrom yowsup.layers.protocol_acks               import YowAckProtocolLayer\r\nfrom yowsup.stacks                             import YowStack\r\nfrom yowsup.common                             import YowConstants\r\nfrom yowsup.layers                             import YowLayerEvent\r\nfrom yowsup                                    import env\r\nfrom layer                                     import EchoLayer\r\nfrom yowsup.layers.auth                        import YowCryptLayer, YowAuthenticationProtocolLayer, AuthError\r\nfrom yowsup.layers.coder                       import YowCoderLayer\r\nfrom yowsup.layers.network                     import YowNetworkLayer\r\nfrom yowsup.layers.protocol_messages           import YowMessagesProtocolLayer\r\nfrom yowsup.layers.stanzaregulator             import YowStanzaRegulator\r\nfrom yowsup.layers.protocol_presence           import YowPresenceProtocolLayer\r\nfrom yowsup.env                                import YowsupEnv\r\n\r\n#Deccomentare per log\r\n#import logging\r\n#logging.basicConfig(level=logging.DEBUG)\r\n\r\nCREDENTIALS = (\"**************************\", \"**************************\") #replace with your phone and password\r\n\r\nif __name__==  \"__main__\":\r\n    stackBuilder = YowStackBuilder()\r\n\r\n    stack = stackBuilder\\\r\n        .pushDefaultLayers(True)\\\r\n        .push(EchoLayer)\\\r\n        .build()\r\n\r\n    stack.setProp(YowAuthenticationProtocolLayer.PROP_CREDENTIALS, CREDENTIALS)       #setting credentials\r\n    stack.broadcastEvent(YowLayerEvent(YowNetworkLayer.EVENT_STATE_CONNECT))          #sending the connect signal\r\n    stack.setProp(YowNetworkLayer.PROP_ENDPOINT, YowConstants.ENDPOINTS[0])           #whatsapp server address\r\n    stack.setProp(YowCoderLayer.PROP_DOMAIN, YowConstants.DOMAIN)\r\n    stack.setProp(YowCoderLayer.PROP_RESOURCE, YowsupEnv.getCurrent().getResource())  #info about us as WhatsApp client\r\n\r\n    stack.loop( timeout = 0.5, discrete = 0.5 )                                       #this is the program mainloop\r\n```"},"comment":{"url":"https://api.github.com/repos/tgalal/yowsup/issues/comments/233479232","html_url":"https://github.com/tgalal/yowsup/issues/1648#issuecomment-233479232","issue_url":"https://api.github.com/repos/tgalal/yowsup/issues/1648","id":233479232,"user":{"login":"controller-t","id":20387808,"avatar_url":"https://avatars.githubusercontent.com/u/20387808?v=3","gravatar_id":"","url":"https://api.github.com/users/controller-t","html_url":"https://github.com/controller-t","followers_url":"https://api.github.com/users/controller-t/followers","following_url":"https://api.github.com/users/controller-t/following{/other_user}","gists_url":"https://api.github.com/users/controller-t/gists{/gist_id}","starred_url":"https://api.github.com/users/controller-t/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/controller-t/subscriptions","organizations_url":"https://api.github.com/users/controller-t/orgs","repos_url":"https://api.github.com/users/controller-t/repos","events_url":"https://api.github.com/users/controller-t/events{/privacy}","received_events_url":"https://api.github.com/users/controller-t/received_events","type":"User","site_admin":false},"created_at":"2016-07-18T22:32:43Z","updated_at":"2016-07-18T22:32:43Z","body":"Yepp that's my current solution as i am idiot in programming language.\r\nThis is working but it is crude and there must be something we can directly do in layer.py\r\n\r\n#!/bin/bash\r\nmsg=$1\r\nsudo service whatsapp stop\r\nsleep 1\r\nsudo python whatsapp_photo.py $msg\r\nsleep 1\r\nsudo service whatsapp start\r\n\r\nrun.py is installed as service and whatsapp_photo.py is simple cli call"}}
{"actor":{"display_login":"controller-t"}}