def sendwhatapp(User, Message): password = "" #Password dada al registrar el numero. password = base64.b64decode(bytes(password.encode('utf-8'))) #Codificacion de Password para envio a los servidores de whatsApp. username = '' #Numero de telefono para el inicio de secion. keepAlive= False Text = "%s -> %s" %(str(User), str(Message)) #Conexion persistente con el servidor. whats = WhatsappEchoClient("", Text, keepAlive) #Inicia el cliente para el envio de mensajes por WhatsApp. whats2 = WhatsappEchoClient("", Text, keepAlive) #Inicia el cliente para el envio de mensajes por WhatsApp. print "Message sent to whatsApp" logging.info("Message sent to whatsApp") whats.login(username, password) whats2.login(username, password)
def send_cwmex(wu_cc, wu_phone_number, wu_passwd, dst_phone, body_mex): countryCode = wu_cc login = wu_cc+wu_phone_number identity = IDENTITY password = wu_passwd identity = Utilities.processIdentity(identity) password = base64.b64decode(bytes(password.encode('utf-8'))) phoneNumber = wu_phone_number phone = dst_phone message = body_mex.encode('utf-8') wa = WhatsappEchoClient(phone, message, False) wa.login(login, password)
def send_cwmex(wu_cc, wu_phone_number, wu_passwd, dst_phone, body_mex): countryCode = wu_cc login = wu_cc + wu_phone_number identity = IDENTITY password = wu_passwd identity = Utilities.processIdentity(identity) password = base64.b64decode(bytes(password.encode('utf-8'))) phoneNumber = wu_phone_number phone = dst_phone message = body_mex.encode('utf-8') wa = WhatsappEchoClient(phone, message, False) wa.login(login, password)
def main(phone): credentials = getCredentials(MINE_CONFIG or DEFAULT_CONFIG ) if credentials: countryCode, login, identity, password = credentials identity = Utilities.processIdentity(identity) password = base64.b64decode(password) # Custom message that will crash WhatsApp message = message = "\xf4\xaa\xde\x04\xbf" #print countryCode, login, identity, password wa = WhatsappEchoClient(phone, message) wa.login(login, password)
def main(phone): credentials = getCredentials(MINE_CONFIG or DEFAULT_CONFIG) if credentials: countryCode, login, identity, password = credentials identity = Utilities.processIdentity(identity) password = base64.b64decode(password) # Custom message that will crash WhatsApp message = message = "\xf4\xaa\xde\x04\xbf" #print countryCode, login, identity, password wa = WhatsappEchoClient(phone, message) wa.login(login, password)
def on_data(self, data): # Aqui eu usei o json para parsear o conte?do vindo do twitter. decoded = json.loads(data) # Abaixo ? um print do que quero ver do arquivo em json que vem. # ----------------------------------------------------------- # re.findall(r"#(\w+)", s) - essa parte do c?digo que pode ser encontrada # quase no fim do print me faz a separa??o de todas as hastags que contem no texto # que vem do twitter, existe no json as hastags, mas n?o consegui separar, fiz assim. # a linha "s = decoded['text'].encode('ascii', 'ignore')" pega o conte?do do texto e joga na variavel s s = decoded['text'].encode('ascii', 'ignore') print decoded['user']['screen_name'],"|",decoded['user']['location'],"|",decoded['user']['verified'],"|",decoded['user']['followers_count'],"|",decoded['user']['friends_count'],"|",decoded['user']['favourites_count'],"|",decoded['user']['statuses_count'],"|",decoded['user']['created_at'],"|",decoded['created_at'].encode('ascii','ignore'),"|",decoded['user']['lang'],"|",re.findall(r"#(\w+)", s),"|",decoded['text'].encode('ascii', 'ignore') # Aqui ? o seguinte, eu tinha feito o envio atravez da "API" do yowsup mesmo # mas achei que ficou lento, para testar, basta tirar os coment?rios e ajustar # as configura??es l? em cima message = str('@%s: %s' % (decoded['user']['screen_name'],decoded['text'].encode('ascii', 'ignore'))) wa = WhatsappEchoClient(telefone, message, keepAlive) wa.login(username, password)
def mainProcess(argumentsPro): #pdb.set_trace() parser = argparse.ArgumentParser( description='yowsup-cli Command line options') clientsGroup = parser.add_argument_group("Client options") regGroup = parser.add_argument_group("Registration options") modes = clientsGroup.add_mutually_exclusive_group() modes.add_argument('-l', '--listen', help='Listen to messages', action="store_true", required=False, default=False) modes.add_argument( '-s', '--send', help= "Send message to phone number and close connection. Phone is full number including country code, without '+' or '00'", action="store", nargs=2, metavar=('<phone>', '<message>'), required=False) modes.add_argument( '-p', '--sendImage', help= "Send image to phone number and close connection. Phone is full number including country code, without '+' or '00'", action="store", nargs=2, metavar=('<phone>', '<image path>'), required=False) modes.add_argument( '-i', '--interactive', help= "Start an interactive conversation with a contact. Phone is full number including country code, without '+' or '00'", action="store", metavar='<phone>', required=False) modes.add_argument( '-b', '--broadcast', help="Broadcast message to multiple recepients, comma seperated", action="store", nargs=2, metavar=('<jids>', '<message>'), required=False) #modes.add_argument('-b','--bot', help='Bot', action="store_true", required=False, default=False) clientsGroup.add_argument( '-w', '--wait', help= 'If used with -s, then connection will not close until server confirms reception of the message', action="store_true", required=False, default=False) clientsGroup.add_argument( '-a', '--autoack', help= 'If used with -l or -i, then a message received ack would be automatically sent for received messages', action="store_true", required=False, default=False) clientsGroup.add_argument( '-k', '--keepalive', help= "When used with -l or -i, Yowsup will automatically respond to server's ping requests to keep connection alive", action="store_true", required=False, default=False) regSteps = regGroup.add_mutually_exclusive_group() regSteps.add_argument( "-r", '--requestcode', help='Request the 3 digit registration code from Whatsapp.', action="store", required=False, metavar="(sms|voice)") regSteps.add_argument( "-R", '--register', help='Register account on Whatsapp using the provided 3 digit code', action="store", required=False, metavar="code") regSteps.add_argument( "-e", '--exists', help= 'Check if account credentials are valid. WARNING: Whatsapp now changes your password everytime you use this. Make sure you update your config file if the output informs about a password change', action="store_true", required=False) contactOptions = parser.add_argument_group( "Contacts options").add_mutually_exclusive_group() contactOptions.add_argument( '--sync', help= 'Sync provided numbers. Numbers should be comma-separated. If a number is not in international format, Whatsapp will assume your own country code for it. Returned data indicate which numbers are whatsapp users and which are not. For Whatsapp users, it will return some info about each user, like user status.', metavar="numbers", action="store", required=False) debugTools = parser.add_argument_group( "Debug tools").add_mutually_exclusive_group() debugTools.add_argument( '--generatepassword', help= "Generate password from given string in same way Whatsapp generates it from a given IMEI or MAC Address", action="store", metavar="input") debugTools.add_argument( '--decodestring', help= "Decode byte arrays found in decompiled version of Whatsapp. Tested with S40 version. Input should be comma separated without the enclosing brackets. Example: ./yowsup-cli --decodestring 112,61,100,123,114,103,96,114,99,99,61,125,118,103", action="store", metavar="encoded_array") parser.add_argument("--help-config", help="Display info about configuration format", action="store_true") parser.add_argument( '-c', '--config', help= "Path to config file containing authentication info. For more info about config format use --help-config", action="store", metavar="file", required=False, default=False) #parser.add_argument('-D','--dbus', help='Start DBUS interface', action="store_true", required=False, default=False) parser.add_argument('-I', '--ignorecached', help="Don't use cached token if exists", action="store_true", required=False, default=False) parser.add_argument('-d', '--debug', help='Enable debug messages', action="store_true", required=False, default=False) parser.add_argument('-v', '--version', help="Print version info and exit", action='store_true', required=False, default=False) args = vars(parser.parse_args(argumentsPro)) if len(sys.argv) == 1: parser.print_help() elif args["help_config"]: print(CONFIG_HELP) elif args["version"]: print("yowsup-cli %s, using Yowsup %s" % (__version__, Constants.v)) else: credentials = getCredentials(args["config"] or DEFAULT_CONFIG) if credentials: #cc, phone, idx, pw, admingp, adminusr, operatorusr, clientusr, nobodyusr countryCode, login, identity, password = credentials identity = Utilities.processIdentity(identity) password = base64.b64decode(bytes(password.encode('utf-8'))) if countryCode: phoneNumber = login[len(countryCode):] else: dissected = dissectPhoneNumber(login) if not dissected: sys.exit( "ERROR. Couldn't detect cc, you have to manually place it your config" ) countryCode, phoneNumber = dissected Debugger.enabled = args['debug'] if args["ignorecached"]: Utilities.tokenCacheEnabled = False if args["interactive"]: #val = args["interactive"] #wa = WhatsappCmdClient(val, args['keepalive'] ,args['autoack']) #wa.login(login, password) pass elif args['send']: #pdb.set_trace() phone = args["send"][0] message = args["send"][1] wa = WhatsappEchoClient(phone, message, args['wait']) wa.login(login, password) elif args["sendImage"]: phone = args["sendImage"][0] imagePath = args["sendImage"][1] wa = UploaderClient(phone, imagePath, args['wait']) wa.login(login, password) elif args['listen']: #pdb.set_trace() wa = WhatsappListenerClient(args['keepalive'], args['autoack']) wa.login(login, password) wa.listening() elif args['broadcast']: phones = args["broadcast"][0] message = args["broadcast"][1] wa = WhatsappEchoClient(phones, message, args['wait']) wa.login(login, password) elif args["requestcode"]: method = args["requestcode"] if method not in ("sms", "voice"): print("coderequest accepts only sms or voice as a value") else: wc = WACodeRequestV2(countryCode, phoneNumber, identity, method) result = wc.send() print(resultToString(result)) elif args["register"]: code = args["register"] code = "".join(code.split('-')) wr = WARegRequestV2(countryCode, phoneNumber, code, identity) result = wr.send() print(resultToString(result)) elif args["exists"]: we = WAExistsRequestV2(countryCode, phoneNumber, identity) result = we.send() print(resultToString(result)) if result["pw"] is not None: print( "\n=========\nWARNING: %s%s's has changed by server to \"%s\", you must update your config file with the new password\n=========" % (countryCode, phoneNumber, result["pw"])) elif args["sync"]: contacts = args["sync"].split(',') wsync = WAContactsSyncRequest(login, password, contacts) print("Syncing %s contacts" % len(contacts)) result = wsync.send() print(resultToString(result)) elif args["dbus"]: startDbusInterface() elif args["generatepassword"]: print(Utilities.processIdentity(args["generatepassword"])) elif args["decodestring"]: print( Utilities.decodeString( map(int, "".join(args["decodestring"].split(' ')).split(',')))) else: print("Error: config file is invalid")
def send_message(self, targetPhone, message): wa = WhatsappEchoClient(targetPhone, message) wa.login(self.username, self.password)
def mainProcess(argumentsPro): #pdb.set_trace() parser = argparse.ArgumentParser(description='yowsup-cli Command line options') clientsGroup = parser.add_argument_group("Client options") regGroup = parser.add_argument_group("Registration options") modes = clientsGroup.add_mutually_exclusive_group() modes.add_argument('-l','--listen', help='Listen to messages', action="store_true", required=False, default=False) modes.add_argument('-s','--send', help="Send message to phone number and close connection. Phone is full number including country code, without '+' or '00'", action="store", nargs=2, metavar=('<phone>','<message>'), required=False) modes.add_argument('-p','--sendImage', help="Send image to phone number and close connection. Phone is full number including country code, without '+' or '00'", action="store", nargs=2, metavar=('<phone>','<image path>'), required=False) modes.add_argument('-i','--interactive', help="Start an interactive conversation with a contact. Phone is full number including country code, without '+' or '00'", action="store", metavar='<phone>', required=False) modes.add_argument('-b','--broadcast', help="Broadcast message to multiple recepients, comma seperated", action="store", nargs=2, metavar=('<jids>', '<message>'), required=False) #modes.add_argument('-b','--bot', help='Bot', action="store_true", required=False, default=False) clientsGroup.add_argument('-w','--wait', help='If used with -s, then connection will not close until server confirms reception of the message', action="store_true", required=False, default=False) clientsGroup.add_argument('-a','--autoack', help='If used with -l or -i, then a message received ack would be automatically sent for received messages', action="store_true", required=False, default=False) clientsGroup.add_argument('-k','--keepalive', help="When used with -l or -i, Yowsup will automatically respond to server's ping requests to keep connection alive", action="store_true", required=False, default=False) regSteps = regGroup.add_mutually_exclusive_group() regSteps.add_argument("-r", '--requestcode', help='Request the 3 digit registration code from Whatsapp.', action="store", required=False, metavar="(sms|voice)") regSteps.add_argument("-R", '--register', help='Register account on Whatsapp using the provided 3 digit code', action="store", required=False, metavar="code") regSteps.add_argument("-e", '--exists', help='Check if account credentials are valid. WARNING: Whatsapp now changes your password everytime you use this. Make sure you update your config file if the output informs about a password change', action="store_true", required=False) contactOptions = parser.add_argument_group("Contacts options").add_mutually_exclusive_group(); contactOptions.add_argument('--sync', help='Sync provided numbers. Numbers should be comma-separated. If a number is not in international format, Whatsapp will assume your own country code for it. Returned data indicate which numbers are whatsapp users and which are not. For Whatsapp users, it will return some info about each user, like user status.', metavar="numbers", action="store", required=False) debugTools = parser.add_argument_group("Debug tools").add_mutually_exclusive_group(); debugTools.add_argument('--generatepassword', help="Generate password from given string in same way Whatsapp generates it from a given IMEI or MAC Address", action="store", metavar="input") debugTools.add_argument('--decodestring', help="Decode byte arrays found in decompiled version of Whatsapp. Tested with S40 version. Input should be comma separated without the enclosing brackets. Example: ./yowsup-cli --decodestring 112,61,100,123,114,103,96,114,99,99,61,125,118,103", action="store", metavar="encoded_array") parser.add_argument("--help-config", help="Display info about configuration format", action="store_true") parser.add_argument('-c','--config', help="Path to config file containing authentication info. For more info about config format use --help-config", action="store", metavar="file", required=False, default=False) #parser.add_argument('-D','--dbus', help='Start DBUS interface', action="store_true", required=False, default=False) parser.add_argument('-I','--ignorecached', help="Don't use cached token if exists", action="store_true", required=False, default=False) parser.add_argument('-d','--debug', help='Enable debug messages', action="store_true", required=False, default=False) parser.add_argument('-v', '--version', help="Print version info and exit", action='store_true', required=False, default=False) args = vars(parser.parse_args(argumentsPro)) if len(sys.argv) == 1: parser.print_help() elif args["help_config"]: print(CONFIG_HELP) elif args["version"]: print("yowsup-cli %s, using Yowsup %s"%(__version__, Constants.v)) else: credentials = getCredentials(args["config"] or DEFAULT_CONFIG) if credentials: #cc, phone, idx, pw, admingp, adminusr, operatorusr, clientusr, nobodyusr countryCode, login, identity, password = credentials identity = Utilities.processIdentity(identity) password = base64.b64decode(bytes(password.encode('utf-8'))) if countryCode: phoneNumber = login[len(countryCode):] else: dissected = dissectPhoneNumber(login) if not dissected: sys.exit("ERROR. Couldn't detect cc, you have to manually place it your config") countryCode, phoneNumber = dissected Debugger.enabled = args['debug'] if args["ignorecached"]: Utilities.tokenCacheEnabled = False if args["interactive"]: #val = args["interactive"] #wa = WhatsappCmdClient(val, args['keepalive'] ,args['autoack']) #wa.login(login, password) pass elif args['send']: #pdb.set_trace() phone = args["send"][0] message = args["send"][1] wa = WhatsappEchoClient(phone, message, args['wait']) wa.login(login, password) elif args["sendImage"]: phone = args["sendImage"][0] imagePath = args["sendImage"][1] wa = UploaderClient(phone, imagePath, args['wait']) wa.login(login, password) elif args['listen']: #pdb.set_trace() wa = WhatsappListenerClient(args['keepalive'], args['autoack']) wa.login(login, password) wa.listening() elif args['broadcast']: phones = args["broadcast"][0] message = args["broadcast"][1] wa = WhatsappEchoClient(phones, message, args['wait']) wa.login(login, password) elif args["requestcode"]: method = args["requestcode"] if method not in ("sms","voice"): print("coderequest accepts only sms or voice as a value") else: wc = WACodeRequestV2(countryCode, phoneNumber, identity, method) result = wc.send() print(resultToString(result)) elif args["register"]: code = args["register"] code = "".join(code.split('-')) wr = WARegRequestV2(countryCode, phoneNumber, code, identity) result = wr.send() print(resultToString(result)) elif args["exists"]: we = WAExistsRequestV2(countryCode, phoneNumber, identity) result = we.send() print(resultToString(result)) if result["pw"] is not None: print("\n=========\nWARNING: %s%s's has changed by server to \"%s\", you must update your config file with the new password\n=========" %(countryCode, phoneNumber, result["pw"])) elif args["sync"]: contacts = args["sync"].split(',') wsync = WAContactsSyncRequest(login, password, contacts) print("Syncing %s contacts" % len(contacts)) result = wsync.send() print(resultToString(result)) elif args["dbus"]: startDbusInterface() elif args["generatepassword"]: print(Utilities.processIdentity(args["generatepassword"])); elif args["decodestring"]: print(Utilities.decodeString(map(int, "".join(args["decodestring"].split(' ')).split(',')))) else: print("Error: config file is invalid")
message = message.replace("spacer","\n") #now s has all the required values . t = count/250 i = -250 j = 0 num = 0 phones = [] while(num < t): i += 250 j +=250 while(i<j): phones.append(s[i]) i+=1 wa = WhatsappEchoClient(phones, message, True) wa.login(login, password) num+=1 phones = [] i=j j= j+count%250 # print j phones= [] while(i<j): phones.append(s[i]) i+=1 #print phones wa = WhatsappEchoClient(phones, message, True) wa.login(login, password)