Skip to content

Commit

Permalink
Update to v3.7.20
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Jul 8, 2021
1 parent 303ac69 commit b436a0b
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions insomniac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
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.19'
__version__ = '3.7.20'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = '[email protected]'
Expand Down
4 changes: 2 additions & 2 deletions insomniac/action_runners/actions_runners_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
2 changes: 1 addition & 1 deletion insomniac/activation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions insomniac/database_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
Expand Down
3 changes: 2 additions & 1 deletion insomniac/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions insomniac/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@
is_ui_process = False
execution_id = ''
task_id = ''
db_name = 'insomniac.db'


def is_insomniac():
return execution_id == ''
12 changes: 7 additions & 5 deletions insomniac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 8 additions & 8 deletions insomniac/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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()
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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"
)

Expand Down

0 comments on commit b436a0b

Please sign in to comment.