Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Update to v3.7.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed May 15, 2021
1 parent 2c71d52 commit 8bdc204
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 359 deletions.
2 changes: 1 addition & 1 deletion insomniac/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
__title__ = 'insomniac'
__description__ = 'Simple Instagram bot for automated Instagram interaction using Android.'
__url__ = 'https://github.com/alexal1/Insomniac/'
__version__ = '3.7.11'
__version__ = '3.7.12'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = 'info@insomniac-bot.com'
Expand Down
24 changes: 9 additions & 15 deletions insomniac/action_runners/interact/action_handle_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,20 @@


def extract_place_instructions(source):
split_idx = source.find('-')
if split_idx == -1:
print("There is no special interaction-instructions for " + source + ". Working with " + source + " recent-likers.")
return source, PlaceInteractionType.RECENT_LIKERS

source = source.replace('_', ' ')
selected_instruction = None
source_profile_name = source[:split_idx]
interaction_instructions_str = source[split_idx+1:]

for hashtag_instruction in PlaceInteractionType:
if hashtag_instruction.value == interaction_instructions_str:
selected_instruction = hashtag_instruction
source_place_name = None
for place_instruction in PlaceInteractionType:
if source.endswith(f'-{place_instruction.value}'):
selected_instruction = place_instruction
source_place_name = source[:len(source) - len(place_instruction.value) - 1]
break

if selected_instruction is None:
print("Couldn't use interaction-instructions " + interaction_instructions_str +
". Working with " + source + " recent-likers.")
selected_instruction = PlaceInteractionType.RECENT_LIKERS
print("There is no special interaction-instructions for " + source + ". Working with " + source + " recent-likers.")
return source, PlaceInteractionType.RECENT_LIKERS

return source_profile_name, selected_instruction
return source_place_name, selected_instruction


def handle_place(device,
Expand Down
25 changes: 22 additions & 3 deletions insomniac/actions_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,13 +665,32 @@ def _open_profile_using_deeplink(device, profile_name):
return should_continue, is_profile_opened


def iterate_over_my_followers(device, iteration_callback, iteration_callback_pre_conditions):
_iterate_over_my_followers_or_followings(device,
iteration_callback,
iteration_callback_pre_conditions,
is_followers=True)


def iterate_over_my_followings(device, iteration_callback, iteration_callback_pre_conditions):
_iterate_over_my_followers_or_followings(device,
iteration_callback,
iteration_callback_pre_conditions,
is_followers=False)


def _iterate_over_my_followers_or_followings(device,
iteration_callback,
iteration_callback_pre_conditions,
is_followers):
entities_name = "followers" if is_followers else "followings"

# Wait until list is rendered
device.find(resourceId=f'{device.app_id}:id/follow_list_container',
className='android.widget.LinearLayout').wait()

while True:
print("Iterate over visible followings")
print(f"Iterate over visible {entities_name}")
sleeper.random_sleep()
screen_iterated_followings = 0

Expand All @@ -697,7 +716,7 @@ def iterate_over_my_followings(device, iteration_callback, iteration_callback_pr
if to_continue:
sleeper.random_sleep()
else:
print(COLOR_OKBLUE + "Stopping iteration over followings" + COLOR_ENDC)
print(COLOR_OKBLUE + f"Stopping iteration over {entities_name}" + COLOR_ENDC)
return

if screen_iterated_followings > 0:
Expand All @@ -706,7 +725,7 @@ def iterate_over_my_followings(device, iteration_callback, iteration_callback_pr
className='android.widget.ListView')
list_view.scroll(DeviceFacade.Direction.BOTTOM)
else:
print(COLOR_OKGREEN + "No followings were iterated, finish." + COLOR_ENDC)
print(COLOR_OKGREEN + f"No {entities_name} were iterated, finish." + COLOR_ENDC)
return


Expand Down
20 changes: 7 additions & 13 deletions insomniac/counters_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from insomniac.navigation import switch_to_english, LanguageChangedException
from insomniac.utils import *
def parse(text) -> int:
"""
Parses given text.

def parse(device, text):
:return: parsed value or ValueError if couldn't parse
"""
multiplier = 1
text = text.replace(",", "")
is_dot_in_text = False
Expand All @@ -22,12 +23,5 @@ def parse(device, text):

if is_dot_in_text:
multiplier = 100000
try:
count = int(float(text) * multiplier)
except ValueError as ex:
print_timeless(COLOR_FAIL + "Cannot parse \"" + text + "\". Probably wrong language, will set English now." +
COLOR_ENDC)
save_crash(device, ex)
switch_to_english(device)
raise LanguageChangedException()
return count

return int(float(text) * multiplier)
3 changes: 3 additions & 0 deletions insomniac/extra_features/action_dm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from insomniac import activation_controller

exec(activation_controller.get_extra_feature('action_dm'))
3 changes: 3 additions & 0 deletions insomniac/extra_features/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from insomniac import activation_controller

exec(activation_controller.get_extra_feature('views'))
2 changes: 1 addition & 1 deletion insomniac/softban_indicator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def detect_empty_list(self, device):
@check_softban_feature_flag
def detect_empty_profile(self, device):
profile_view = ProfileView(device)
followers_count = profile_view.get_followers_count(should_parse=False)
followers_count = profile_view.get_followers_count()
is_profile_empty = followers_count is None
if is_profile_empty:
print(COLOR_FAIL + "A profile-page seems to be empty. "
Expand Down
4 changes: 4 additions & 0 deletions insomniac/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def is_profile_follows_me_by_cache(self, username):
return False
return self.profile.is_follow_me(username, hours=self.recheck_follow_status_after) is True

@database_api
def is_new_follower(self, username):
return self.profile.is_follow_me(username) is None

@database_api
def update_follow_status(self, username, is_follow_me=None, do_i_follow_him=None):
if is_follow_me is None and do_i_follow_him is None:
Expand Down
Loading

0 comments on commit 8bdc204

Please sign in to comment.