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.25
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Aug 24, 2021
1 parent d52a09a commit 1d5f0e8
Show file tree
Hide file tree
Showing 31 changed files with 937 additions and 425 deletions.
22 changes: 11 additions & 11 deletions insomniac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@
from insomniac.utils import *


ACTIVATION_CODE_ARG_NAME = 'activation_code'


def run(activation_code="", starter_conf_file_path=None):
if not __version__.__debug_mode__:
print_timeless(COLOR_OKGREEN + __version__.__logo__ + COLOR_ENDC)
print_version()

activation_code_from_args = _get_activation_code_from_args()
activation_code_from_args = get_arg_value(ACTIVATION_CODE_ARG_NAME)
if activation_code_from_args is not None:
activation_code = activation_code_from_args

activation_controller.validate(activation_code)
if not activation_controller.is_activated:
from insomniac.session import InsomniacSession
from insomniac.session import get_insomniac_session
print_timeless("Using insomniac session-manager without extra-features")
insomniac_session = InsomniacSession(starter_conf_file_path)
insomniac_session = get_insomniac_session(starter_conf_file_path)
else:
from insomniac.extra_features.session import ExtendedInsomniacSession
insomniac_session = ExtendedInsomniacSession(starter_conf_file_path)
from insomniac.extra_features.session import get_insomniac_extended_features_session
insomniac_session = get_insomniac_extended_features_session(starter_conf_file_path)

insomniac_session.run()


def is_newer_version_available():
def versiontuple(v):
return tuple(map(int, (v.split("."))))

current_version = __version__.__version__
latest_version = _get_latest_version('insomniac')
if latest_version is not None and versiontuple(latest_version) > versiontuple(current_version):
Expand All @@ -60,14 +60,14 @@ def _get_latest_version(package):
return latest_version


def _get_activation_code_from_args():
def get_arg_value(arg_name):
parser = ArgumentParser(add_help=False)
parser.add_argument('--activation-code')
parser.add_argument(f'--{arg_name.replace("_", "-")}')
try:
args, _ = parser.parse_known_args()
except (argparse.ArgumentError, TypeError):
return None
return args.activation_code
return getattr(args, arg_name)


class ArgumentParser(argparse.ArgumentParser):
Expand Down
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.21'
__version__ = '3.7.25'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = 'info@insomniac-bot.com'
Expand Down
2 changes: 1 addition & 1 deletion insomniac/action_get_my_profile_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_my_profile_info(device, username):
except UserSwitchFailedException as e:
raise e
except Exception as e:
print(COLOR_FAIL + f"Exception: {e}" + COLOR_ENDC)
print(COLOR_FAIL + describe_exception(e) + COLOR_ENDC)
save_crash(device, e)
switch_to_english(device)

Expand Down
19 changes: 13 additions & 6 deletions insomniac/action_runners/actions_runners_manager.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from abc import ABC

from insomniac.action_runners import *
from insomniac.utils import *


class ActionRunnersManager(object):
action_runners = {}

class ActionRunnersManager(ABC):
def __init__(self):
for clazz in get_core_action_runners_classes():
instance = clazz()
self.action_runners[instance.ACTION_ID] = instance
self.action_runners = {}

def get_actions_args(self):
actions_args = {}
Expand Down Expand Up @@ -39,3 +37,12 @@ def select_action_runner(self, args):
COLOR_ENDC)

return selected_action_runners[0]


class CoreActionRunnersManager(ActionRunnersManager):
def __init__(self):
super().__init__()

for clazz in get_core_action_runners_classes():
instance = clazz()
self.action_runners[instance.ACTION_ID] = instance
7 changes: 3 additions & 4 deletions insomniac/action_runners/interact/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from insomniac.action_runners import *
from insomniac.actions_types import TargetType
from insomniac.navigation import navigate
from insomniac.safely_runner import run_safely
from insomniac.utils import *
from insomniac.views import TabBarTabs


class InteractBySourceActionRunner(CoreActionsRunner):
Expand Down Expand Up @@ -80,8 +82,6 @@ def reset_params(self):
self.comments_list = []

def set_params(self, args):
self.reset_params()

if args.likes_count is not None:
self.likes_count = args.likes_count

Expand Down Expand Up @@ -144,6 +144,7 @@ def run(self, device_wrapper, storage, session_state, on_action, is_limit_reache
@run_safely(device_wrapper=device_wrapper)
def job():
self.action_status.set(ActionState.RUNNING)
navigate(device_wrapper.get(), TabBarTabs.PROFILE)
if source[0] == '@':
source_name, instructions = extract_blogger_instructions(source)
handle_blogger(device_wrapper.get(),
Expand Down Expand Up @@ -288,8 +289,6 @@ def reset_params(self):
self.comments_list = []

def set_params(self, args):
self.reset_params()

if args.likes_count is not None:
self.likes_count = args.likes_count

Expand Down
2 changes: 0 additions & 2 deletions insomniac/action_runners/interact/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def interact_with_follower(follower_name, follower_name_view):
should_continue, is_all_filters_satisfied = is_passed_filters(device, follower_name, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
on_action(FilterAction(user=follower_name))
return True

if not is_all_filters_satisfied:
Expand All @@ -146,7 +145,6 @@ def interact_with_follower(follower_name, follower_name_view):
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, follower_name, reset=False)
if not should_continue:
on_action(FilterAction(user=follower_name))
# Continue to next follower
print("Back to profiles list")
device.back()
Expand Down
2 changes: 0 additions & 2 deletions insomniac/action_runners/interact/action_handle_hashtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def interact_with_profile(liker_username, liker_username_view):
should_continue, is_all_filters_satisfied = is_passed_filters(device, liker_username, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
on_action(FilterAction(user=liker_username))
return True

if not is_all_filters_satisfied:
Expand All @@ -121,7 +120,6 @@ def interact_with_profile(liker_username, liker_username_view):
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, liker_username, reset=False)
if not should_continue:
on_action(FilterAction(user=liker_username))
# Continue to next follower
print("Back to likers list")
device.back()
Expand Down
2 changes: 0 additions & 2 deletions insomniac/action_runners/interact/action_handle_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def interact_with_profile(liker_username, liker_username_view):
should_continue, is_all_filters_satisfied = is_passed_filters(device, liker_username, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
on_action(FilterAction(liker_username))
return True

if not is_all_filters_satisfied:
Expand All @@ -132,7 +131,6 @@ def interact_with_profile(liker_username, liker_username_view):
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, liker_username, reset=False)
if not should_continue:
on_action(FilterAction(liker_username))
# Continue to next follower
print("Back to likers list")
device.back()
Expand Down
2 changes: 0 additions & 2 deletions insomniac/action_runners/interact/action_handle_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def pre_conditions(target_name, target_name_view):
should_continue, is_all_filters_satisfied = is_passed_filters(device, target_name, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
on_action(FilterAction(user=target_name))
return False

if not is_all_filters_satisfied:
Expand Down Expand Up @@ -74,7 +73,6 @@ def interact_with_username_target(target_name, target_name_view):
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, target_name, reset=False)
if not should_continue:
on_action(FilterAction(user=target_name))
print("Moving to next target")
return

Expand Down
5 changes: 3 additions & 2 deletions insomniac/action_runners/unfollow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from insomniac.action_runners import *
from insomniac.actions_impl import FollowingsSortOrder
from insomniac.navigation import navigate
from insomniac.safely_runner import run_safely
from insomniac.utils import *
from insomniac.views import TabBarTabs


class UnfollowActionRunner(CoreActionsRunner):
Expand Down Expand Up @@ -49,8 +51,6 @@ def reset_params(self):
self.followings_sort_order = FollowingsSortOrder.EARLIEST

def set_params(self, args):
self.reset_params()

if args.unfollow_followed_by_anyone is not None:
self.unfollow_followed_by_anyone = True

Expand All @@ -75,6 +75,7 @@ def run(self, device_wrapper, storage, session_state, on_action, is_limit_reache
@run_safely(device_wrapper=device_wrapper)
def job():
self.action_status.set(ActionState.RUNNING)
navigate(device_wrapper.get(), TabBarTabs.PROFILE)
unfollow(device=device_wrapper.get(),
on_action=on_action,
storage=storage,
Expand Down
6 changes: 0 additions & 6 deletions insomniac/actions_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,13 +807,7 @@ def do_unfollow(device, my_username, username, storage, check_if_is_follower, us
if dialog_view.is_visible():
print("Confirming unfollow...")
unfollow_confirmed = dialog_view.click_unfollow()
sleeper.random_sleep()

confirmation_dialog_view = DialogView(device)
if confirmation_dialog_view.is_visible():
print("Confirming unfollowing...")
unfollow_confirmed = confirmation_dialog_view.click_unfollow()
sleeper.random_sleep()
if unfollow_confirmed:
sleeper.random_sleep()
else:
Expand Down
1 change: 1 addition & 0 deletions insomniac/actions_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
FilterAction = namedtuple('FilterAction', 'user')
InteractAction = namedtuple('InteractAction', 'source_name source_type user succeed')
RemoveMassFollowerAction = namedtuple('RemoveMassFollowerAction', 'user')
StartSessionAction = namedtuple('StartSessionAction', '')


@unique
Expand Down
Loading

0 comments on commit 1d5f0e8

Please sign in to comment.