From b436a0b1fcd1f54acda0e5b57f561cfbaa490f59 Mon Sep 17 00:00:00 2001 From: Alexander Mishchenko Date: Thu, 8 Jul 2021 12:16:20 +0300 Subject: [PATCH] Update to v3.7.20 --- insomniac/__init__.py | 4 ++-- insomniac/__version__.py | 2 +- .../action_runners/actions_runners_manager.py | 4 ++-- insomniac/activation.py | 2 +- insomniac/database_engine.py | 4 ++-- insomniac/db_models.py | 3 ++- insomniac/globals.py | 5 +++++ insomniac/utils.py | 12 +++++++----- insomniac/views.py | 16 ++++++++-------- 9 files changed, 30 insertions(+), 22 deletions(-) diff --git a/insomniac/__init__.py b/insomniac/__init__.py index 4afb084..790510f 100644 --- a/insomniac/__init__.py +++ b/insomniac/__init__.py @@ -43,9 +43,9 @@ def versiontuple(v): def print_version(): - print_timeless_ui(COLOR_HEADER + f"Insomniac v{__version__.__version__}" + COLOR_ENDC) + print_timeless_ui(COLOR_HEADER + f"Engine v{__version__.__version__}" + COLOR_ENDC) is_new_version_available, latest_version = is_newer_version_available() - if is_new_version_available: + if is_new_version_available and insomniac_globals.is_insomniac(): print_timeless(COLOR_HEADER + f"Newer version is available (v{latest_version}). Please run" + COLOR_ENDC) print_timeless(COLOR_HEADER + COLOR_BOLD + "python3 -m pip install insomniac --upgrade" + COLOR_ENDC) print_timeless("") diff --git a/insomniac/__version__.py b/insomniac/__version__.py index 39008d6..7db359d 100644 --- a/insomniac/__version__.py +++ b/insomniac/__version__.py @@ -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.19' +__version__ = '3.7.20' __debug_mode__ = False __author__ = 'Insomniac Team' __author_email__ = 'info@insomniac-bot.com' diff --git a/insomniac/action_runners/actions_runners_manager.py b/insomniac/action_runners/actions_runners_manager.py index d0f54b5..3b79cf5 100644 --- a/insomniac/action_runners/actions_runners_manager.py +++ b/insomniac/action_runners/actions_runners_manager.py @@ -31,11 +31,11 @@ def select_action_runner(self, args): return None if len(selected_action_runners) > 1: - print_timeless(COLOR_FAIL + "Running Insomniac with two or more actions is not supported yet." + COLOR_ENDC) + print_timeless(COLOR_FAIL + "Executing two or more actions is not supported yet." + COLOR_ENDC) return None print(COLOR_BOLD + - "Running Insomniac with the \"{0}\" action.".format(selected_action_runners[0].ACTION_ID) + + "Executing \"{0}\" action.".format(selected_action_runners[0].ACTION_ID) + COLOR_ENDC) return selected_action_runners[0] diff --git a/insomniac/activation.py b/insomniac/activation.py index 2c62fa7..ea76f7b 100644 --- a/insomniac/activation.py +++ b/insomniac/activation.py @@ -33,7 +33,7 @@ def validate(self, activation_code, ui=False): f"before session to behave more like a human" f"{dot}{COLOR_BOLD}Working hours{COLOR_ENDC} - the script will wait till specified hours " f"before each session" - f"{dot}{COLOR_BOLD}Removing mass followers{COLOR_ENDC} - automate \"cleaning\" you account" + f"{dot}{COLOR_BOLD}Removing mass followers{COLOR_ENDC} - automate \"cleaning\" your account\n" f"Activate by supporting our small team: {COLOR_BOLD}{HOST}{PATH_ACTIVATE}{COLOR_ENDC}\n") def get_extra_feature(self, module, ui=False): diff --git a/insomniac/database_engine.py b/insomniac/database_engine.py index 592c33e..daf04f2 100644 --- a/insomniac/database_engine.py +++ b/insomniac/database_engine.py @@ -620,8 +620,8 @@ def _run_migrations(cursor): return if current_version > latest_version: - raise Exception(f"[Database] Current DB version (v{current_version}) is newer from your Insomniac version and " - f"not supported. Please update Insomniac.") + raise Exception(f"[Database] Current DB version (v{current_version}) is newer from your version and " + f"not supported. Please update version.") if current_version < latest_version: print(f"[Database] Going to migrate database to a newer version...") diff --git a/insomniac/db_models.py b/insomniac/db_models.py index db01874..64ffe47 100644 --- a/insomniac/db_models.py +++ b/insomniac/db_models.py @@ -8,8 +8,9 @@ from playhouse.migrate import SqliteMigrator, migrate from insomniac.utils import * +from insomniac.globals import db_name -DATABASE_NAME = 'insomniac.db' +DATABASE_NAME = db_name DATABASE_VERSION = 2 db = SqliteDatabase(DATABASE_NAME, autoconnect=False) diff --git a/insomniac/globals.py b/insomniac/globals.py index 6f77849..5d62b9e 100644 --- a/insomniac/globals.py +++ b/insomniac/globals.py @@ -2,3 +2,8 @@ is_ui_process = False execution_id = '' task_id = '' +db_name = 'insomniac.db' + + +def is_insomniac(): + return execution_id == '' diff --git a/insomniac/utils.py b/insomniac/utils.py index a8d817a..df117de 100644 --- a/insomniac/utils.py +++ b/insomniac/utils.py @@ -191,17 +191,19 @@ def save_crash(device, ex=None): shutil.make_archive(os.path.join("crashes", directory_name), 'zip', os.path.join("crashes", directory_name)) shutil.rmtree(os.path.join("crashes", directory_name)) - print(COLOR_OKGREEN + "Crash saved as \"crashes/" + directory_name + ".zip\"." + COLOR_ENDC) - print(COLOR_OKGREEN + "Please attach this file if you gonna report the crash at" + COLOR_ENDC) - print(COLOR_OKGREEN + "https://github.com/alexal1/Insomniac/issues\n" + COLOR_ENDC) + if insomniac_globals.is_insomniac(): + print(COLOR_OKGREEN + "Crash saved as \"crashes/" + directory_name + ".zip\"." + COLOR_ENDC) + print(COLOR_OKGREEN + "Please attach this file if you gonna report the crash at" + COLOR_ENDC) + print(COLOR_OKGREEN + "https://github.com/alexal1/Insomniac/issues\n" + COLOR_ENDC) except Exception as e: print(COLOR_FAIL + f"Could not save crash after an error. Crash-save-error: {str(e)}" + COLOR_ENDC) print(COLOR_FAIL + describe_exception(e) + COLOR_ENDC) def print_copyright(): - print_timeless("\nIf you like this bot, please " + COLOR_BOLD + "give us a star" + COLOR_ENDC + ":") - print_timeless(COLOR_BOLD + "https://github.com/alexal1/Insomniac\n" + COLOR_ENDC) + if insomniac_globals.is_insomniac(): + print_timeless("\nIf you like this bot, please " + COLOR_BOLD + "give us a star" + COLOR_ENDC + ":") + print_timeless(COLOR_BOLD + "https://github.com/alexal1/Insomniac\n" + COLOR_ENDC) def _print_with_time_decorator(standard_print, print_time, debug, ui_log): diff --git a/insomniac/views.py b/insomniac/views.py index 40ec203..8450a17 100644 --- a/insomniac/views.py +++ b/insomniac/views.py @@ -262,6 +262,9 @@ def get_tab_bar_top(self): self.tab_bar_top = TabBarView(self.device).get_top() return self.tab_bar_top + def get_child(self, *args, **kwargs): + return self.action_bar.child(*args, **kwargs) + def _get_action_bar(self): tab_bar = self.device.find( resourceIdMatches=case_insensitive_re(f"{self.device.app_id}:id/action_bar_container"), @@ -284,20 +287,17 @@ def create_instance(device): return ActionBarView.INSTANCE -class HomeView(ActionBarView): +class HomeView(InstagramView): LOGO_ID = '{0}:id/action_bar_textview_custom_title_container' LOGO_CLASS_NAME = 'android.widget.FrameLayout' - def __init__(self, device: DeviceFacade): - super().__init__(device) - def is_visible(self) -> bool: return self.device.find(resourceId=self.LOGO_ID.format(self.device.app_id), className=self.LOGO_CLASS_NAME).exists() def navigate_to_search(self): print_debug("Navigate to Search") - search_btn = self.action_bar.child( + search_btn = ActionBarView.INSTANCE.get_child( descriptionMatches=case_insensitive_re(TabBarView.SEARCH_CONTENT_DESC) ) search_btn.click() @@ -878,7 +878,7 @@ def open_random_post(self) -> Optional['PostsViewList']: return None -class ProfileView(ActionBarView): +class ProfileView(InstagramView): FOLLOWERS_BUTTON_ID_REGEX = '{0}:id/row_profile_header_followers_container|{1}:id/row_profile_header_container_followers' FOLLOWING_BUTTON_ID_REGEX = '{0}:id/row_profile_header_following_container|{1}:id/row_profile_header_container_following' @@ -912,7 +912,7 @@ def navigate_to_options(self): print_debug("Navigate to Options") # We wanna pick last view in the action bar options_view = None - for options_view in self.action_bar.child(clickable=True): + for options_view in ActionBarView.INSTANCE.get_child(clickable=True): pass if options_view is None or not options_view.exists(): print(COLOR_FAIL + "No idea how to open menu..." + COLOR_ENDC) @@ -965,7 +965,7 @@ def _get_action_bar_title_btn(self): f"{self.device.app_id}:id/action_bar_large_title_auto_size" ] ) - return self.action_bar.child( + return ActionBarView.INSTANCE.get_child( resourceIdMatches=re_case_insensitive, className="android.widget.TextView" )