def new_auto_mod_unlike(self): if time.time() > self.bot.next_iteration["Unlike"] and self.bot.unlike_per_day != 0: media = self.get_medias_to_unlike() if media: self.bot.logger.info("Trying to unlike media") self.auto_unlike() self.bot.next_iteration["Unlike"] = time.time() + add_time( self.bot.unfollow_delay )
def new_auto_mod_unfollow(self, test_run=False): if time.time() > self.bot.next_iteration[ "Unfollow"] and self.bot.configurations.unfollow_per_day != 0: if (time.time() - self.bot.bot_start_time) < 30 and not test_run: log = "let bot initialize" self.logger.warning(log) self.send_to_socket(log) return if InteractedUser.objects.all().count() < 20: log = ( f"> Waiting for database to populate before unfollowing (progress " f"{str(InteractedUser.objects.all().count())} /20)") self.logger.info(log) self.send_to_socket(log) if self.bot.configurations.unfollow_recent_feed is True: log = "Will try to populate using recent feed" self.logger.info(log) self.send_to_socket(log) self.populate_from_feed() self.bot.next_iteration["Unfollow"] = time.time() + ( add_time(self.bot.unfollow_delay) / 2) return # DB doesn't have enough followers yet if self.bot.bot_mode == 0 or self.bot.bot_mode == 3: try: if (time.time() > self.bot.next_iteration["Populate"] and self.bot.unfollow_recent_feed is True): self.populate_from_feed() self.bot.next_iteration["Populate"] = time.time() + ( add_time(360)) except: log = "Notice: Could not populate from recent feed right now" self.logger.warning(log) self.send_to_socket(log) log_string = f"Trying to unfollow #{self.bot.unfollow_counter + 1}:" self.logger.info(log_string) self.auto_unfollow() self.bot.next_iteration["Unfollow"] = time.time() + add_time( self.bot.unfollow_delay)
def new_auto_mod_comments(self): if (time.time() > self.bot.next_iteration["Comments"] and self.bot.configurations.comments_per_day != 0 and len(self.bot.media_by_tag) > 0 and self.check_exisiting_comment( self.bot.media_by_tag[0]["node"]["shortcode"]) is False): comment_text = self.generate_comment() log_string = f"Trying to comment: {self.bot.media_by_tag[0]['node']['id']}" self.logger.info(log_string) if (self.comment(self.bot.media_by_tag[0]["node"]["id"], comment_text) is not False): self.bot.next_iteration["Comments"] = time.time() + add_time( self.bot.comments_delay)
def new_auto_mod_like(self): if ( time.time() > self.bot.next_iteration["Like"] and self.bot.configurations.likes_per_day != 0 and len(self.bot.media_by_tag) > 0 ): # You have media_id to like: if self.like_all_exist_media(media_size=1, delay=False): # If like go to sleep: self.bot.next_iteration["Like"] = time.time() + add_time( self.bot.like_delay ) # Count this tag likes: self.bot.this_tag_like_count += 1 if self.bot.this_tag_like_count >= self.bot.max_tag_like_count: self.bot.media_by_tag = [0] # Del first media_id try: del self.bot.media_by_tag[0] except: self.bot.logger.exception("Could not remove media")
def new_auto_mod_follow(self): username = None if time.time() < self.bot.next_iteration["Follow"]: return if (time.time() > self.bot.next_iteration["Follow"] and self.bot.configurations.follow_per_day != 0 and len(self.bot.media_by_tag) > 0): if self.bot.media_by_tag[0]["node"]["owner"][ "id"] == self.bot.user_id: self.logger.warning("Keep calm - It's your own profile ;)") self.send_to_socket("Keep calm - It's your own profile ;)") return if self.bot.configurations.user_min_follow != 0 or self.bot.configurations.user_max_follow != 0: try: username = self.bot.insta_explorer.get_username_by_user_id( self.bot.media_by_tag[0]["node"]["owner"]["id"]) url = self.bot.url_user_detail % username r = self.bot.session_1.get(url) all_data = json.loads( re.search("window._sharedData = (.*?);</script>", r.text, re.DOTALL).group(1)) followers = all_data["entry_data"]["ProfilePage"][0][ "graphql"]["user"]["edge_followed_by"]["count"] if followers < self.bot.configurations.user_min_follow: self.logger.warning( f"Won't follow {username}: does not meet user_min_follow requirement" ) return if self.bot.configurations.user_max_follow != 0 and followers > self.bot.configurations.user_max_follow: self.logger.warning( f"Won't follow {username}: does not meet user_max_follow requirement" ) self.send_to_socket( f"Won't follow {username}: does not meet user_max_follow requirement" ) return except Exception: pass if (self.check_already_followed(user_id=self.bot.media_by_tag[0] ["node"]["owner"]["id"]) == 1): self.logger.warning( f"Already followed before {self.bot.media_by_tag[0]['node']['owner']['id']}" ) self.send_to_socket( f"Already followed before {self.bot.media_by_tag[0]['node']['owner']['id']}" ) self.bot.next_iteration["Follow"] = time.time() + add_time( self.bot.follow_delay / 2) return log_string = ( f"Trying to follow: {self.bot.media_by_tag[0]['node']['owner']['id']}" ) self.logger.info(log_string) self.send_to_socket(log_string) self.bot.next_iteration["Follow"] = time.time() + add_time( self.bot.follow_delay) if (self.follow( user_id=self.bot.media_by_tag[0]["node"]["owner"]["id"], username=username, ) is not False): self.bot.bot_follow_list.append([ self.bot.media_by_tag[0]["node"]["owner"]["id"], time.time() ]) self.bot.next_iteration["Follow"] = time.time() + add_time( self.bot.follow_delay)