From a33cdea15e5eb9e178bc63991418bdf847d521cd Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 12 Jan 2024 23:26:38 +0100 Subject: [PATCH 1/7] fix: caseless comparison for app language checking Also removed the automatic language change. That menu keeps changing, better to let the user change the language --- GramAddict/core/navigation.py | 20 +++----------------- GramAddict/core/views.py | 5 +++-- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/GramAddict/core/navigation.py b/GramAddict/core/navigation.py index 091b4022..690c0a58 100644 --- a/GramAddict/core/navigation.py +++ b/GramAddict/core/navigation.py @@ -32,25 +32,11 @@ def check_if_english(device): logger.warning( "Failed to check your Instagram language. Be sure to set it to English or the bot won't work!" ) - elif post == "Posts" and follower == "Followers" and following == "Following": + elif post == "posts" and follower == "followers" and following == "following": logger.debug("Instagram in English.") else: - logger.info("Switching to English locale.", extra={"color": f"{Fore.GREEN}"}) - try: - ProfileView(device).navigateToOptions() - OptionsView(device).navigateToSettings() - SettingsView(device).navigateToAccount() - AccountView(device).navigateToLanguage() - LanguageView(device).setLanguage("english") - logger.debug( - "After changing language, IG goes to feed. Let's go to profile view again." - ) - ProfileView(device).click_on_avatar() - except Exception as ex: - logger.error(f"Please change the language manually to English! Error: {ex}") - sys.exit(1) - if ProfileView(device).getFollowingCount() is None: - ProfileView(device).click_on_avatar() + logger.error(f"Please change the language manually to English! Error: {ex}") + sys.exit(1) return ProfileView(device, is_own_profile=True) diff --git a/GramAddict/core/views.py b/GramAddict/core/views.py index 699d9d8b..24c0a9f2 100644 --- a/GramAddict/core/views.py +++ b/GramAddict/core/views.py @@ -1449,7 +1449,8 @@ def _getActionBarTitleBtn(self, watching_stories=False): ) return None - def _getSomeText(self): + def _getSomeText(self) -> Tuple[Optional[str], Optional[str], Optional[str]]: + """Get some text from the profile to check the language""" obj = self.device.find( resourceIdMatches=ResourceID.ROW_PROFILE_HEADER_TEXTVIEW_POST_CONTAINER ) @@ -1477,7 +1478,7 @@ def _getSomeText(self): .child(index=1) .get_text() ) - return post, followers, following + return post.casefold(), followers.casefold(), following.casefold() except Exception as e: logger.debug(f"Exception: {e}") logger.warning( From 91826523e90d6b9015c564939224a9748ec3fcf7 Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 12 Jan 2024 23:46:13 +0100 Subject: [PATCH 2/7] docs: more details on how to open a ticket --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index ec17341f..c2c13176 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,7 +24,7 @@ labels: kind/bug Relevant Logs: - +- activate debug mode in confing.yml if you want to paste from the console, otherwise attach the log file from the logs folder From f0038164542fdd3538762d37eded30742820cc84 Mon Sep 17 00:00:00 2001 From: Dennis Date: Fri, 12 Jan 2024 23:51:02 +0100 Subject: [PATCH 3/7] bump: update ig version --- GramAddict/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GramAddict/__init__.py b/GramAddict/__init__.py index 807220db..d2fb740f 100644 --- a/GramAddict/__init__.py +++ b/GramAddict/__init__.py @@ -1,6 +1,6 @@ """Human-like Instagram bot powered by UIAutomator2""" -__version__ = "3.2.7" -__tested_ig_version__ = "226.1.0.16.117" +__version__ = "3.2.8b0" +__tested_ig_version__ = "263.2.0.19.104" from GramAddict.core.bot_flow import start_bot From 245e23e6f6d48d46fc6453d9327aa4f6e77e6524 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 24 Jan 2024 00:18:25 +0100 Subject: [PATCH 4/7] fix: forgot to remove unused var --- GramAddict/core/navigation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GramAddict/core/navigation.py b/GramAddict/core/navigation.py index 690c0a58..d0187f78 100644 --- a/GramAddict/core/navigation.py +++ b/GramAddict/core/navigation.py @@ -35,7 +35,7 @@ def check_if_english(device): elif post == "posts" and follower == "followers" and following == "following": logger.debug("Instagram in English.") else: - logger.error(f"Please change the language manually to English! Error: {ex}") + logger.error("Please change the language manually to English!") sys.exit(1) return ProfileView(device, is_own_profile=True) From ac5e9117e8ced72d7c6cb48943f7722f95536a06 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 24 Jan 2024 07:45:29 +0100 Subject: [PATCH 5/7] fix: remove unused imports --- GramAddict/core/navigation.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/GramAddict/core/navigation.py b/GramAddict/core/navigation.py index d0187f78..1608bb78 100644 --- a/GramAddict/core/navigation.py +++ b/GramAddict/core/navigation.py @@ -5,14 +5,10 @@ from GramAddict.core.device_facade import Timeout from GramAddict.core.views import ( - AccountView, HashTagView, - LanguageView, - OptionsView, PlacesView, PostsGridView, ProfileView, - SettingsView, TabBarView, UniversalActions, ) From bfe34f8f778d4d57ac968e01760a77fe3b5673f5 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 24 Jan 2024 07:47:11 +0100 Subject: [PATCH 6/7] fix: extract navigate to main account from check language function --- GramAddict/core/bot_flow.py | 1 + GramAddict/core/navigation.py | 6 +----- GramAddict/core/views.py | 7 +++++++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/GramAddict/core/bot_flow.py b/GramAddict/core/bot_flow.py index 85a06bdd..3cab4c4b 100644 --- a/GramAddict/core/bot_flow.py +++ b/GramAddict/core/bot_flow.py @@ -174,6 +174,7 @@ def start_bot(**kwargs): account_view = AccountView(device) tab_bar_view = TabBarView(device) try: + account_view.navigate_to_main_account() check_if_english(device) if configs.args.username is not None: success = account_view.changeToUsername(configs.args.username) diff --git a/GramAddict/core/navigation.py b/GramAddict/core/navigation.py index 1608bb78..49fa76e5 100644 --- a/GramAddict/core/navigation.py +++ b/GramAddict/core/navigation.py @@ -17,11 +17,7 @@ def check_if_english(device): - logger.debug("Navigate to PROFILE.") - UniversalActions.close_keyboard(device) - ProfileView(device).click_on_avatar() - if ProfileView(device).getFollowingCount() is None: - ProfileView(device).click_on_avatar() + """check if app is in English""" logger.debug("Checking if app is in English..") post, follower, following = ProfileView(device)._getSomeText() if None in {post, follower, following}: diff --git a/GramAddict/core/views.py b/GramAddict/core/views.py index 24c0a9f2..d389950a 100644 --- a/GramAddict/core/views.py +++ b/GramAddict/core/views.py @@ -1045,6 +1045,13 @@ def navigateToLanguage(self): logger.error("Not able to set your app in English! Do it by yourself!") exit(0) + def navigate_to_main_account(self): + logger.debug("Navigating to main account...") + profile_view = ProfileView(self.device) + profile_view.click_on_avatar() + if profile_view.getFollowingCount() is None: + profile_view.click_on_avatar() + def changeToUsername(self, username: str): action_bar = ProfileView._getActionBarTitleBtn(self) if action_bar is not None: From 92e3453adc5ed900e6de410f21b7a46ca23176f8 Mon Sep 17 00:00:00 2001 From: Dennis Date: Wed, 24 Jan 2024 07:48:27 +0100 Subject: [PATCH 7/7] bump: update version --- GramAddict/__init__.py | 2 +- GramAddict/version.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/GramAddict/__init__.py b/GramAddict/__init__.py index d2fb740f..290c496d 100644 --- a/GramAddict/__init__.py +++ b/GramAddict/__init__.py @@ -1,5 +1,5 @@ """Human-like Instagram bot powered by UIAutomator2""" -__version__ = "3.2.8b0" +__version__ = "3.2.8" __tested_ig_version__ = "263.2.0.19.104" from GramAddict.core.bot_flow import start_bot diff --git a/GramAddict/version.py b/GramAddict/version.py index 7d39b6b2..74f5cd13 100644 --- a/GramAddict/version.py +++ b/GramAddict/version.py @@ -1,2 +1,2 @@ # that file is deprecated, current version is now stored in GramAddict/__init__.py -__version__ = "3.2.7" +__version__ = "3.2.8"