Skip to content

Commit

Permalink
Update to v3.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Mar 13, 2022
1 parent 1a8016b commit 7bb4c55
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 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.8.0'
__version__ = '3.8.1'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = 'info@insomniac-bot.com'
Expand Down
Binary file added insomniac/assets/ADBKeyboard-nomix.apk
Binary file not shown.
7 changes: 6 additions & 1 deletion insomniac/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ def open_instagram_with_network_check(device) -> bool:
sleep(5)
attempt += 1
resumed_activity_output = execute_command("adb" + ("" if device_id is None else " -s " + device_id) +
f" shell dumpsys activity | grep 'mResumedActivity'")
f" shell dumpsys activity | grep 'mResumedActivity'",
error_allowed=False)
if resumed_activity_output is None:
# Fallback to standard way
print(COLOR_FAIL + "Didn't work :(" + COLOR_ENDC)
return open_instagram(device_id, app_id)
if app_id in resumed_activity_output:
break

Expand Down
5 changes: 4 additions & 1 deletion insomniac/typewriter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import insomniac
from insomniac.globals import is_insomniac
from insomniac.utils import *

# Typewriter uses Android application (apk file) built from this repo: https://github.com/alexal1/InsomniacAutomator
Expand All @@ -7,6 +8,7 @@
ADB_KEYBOARD_PKG = "com.alexal1.adbkeyboard"
ADB_KEYBOARD_IME = "com.alexal1.adbkeyboard/.AdbIME"
ADB_KEYBOARD_APK = "ADBKeyboard.apk"
ADB_KEYBOARD_APK_NOMIX = "ADBKeyboard-nomix.apk"
ADB_KEYBOARD_VERSION = versiontuple("3.0.1")
DELAY_MEAN = 200
DELAY_DEVIATION = 100
Expand Down Expand Up @@ -43,7 +45,8 @@ def set_adb_keyboard(self):

if need_to_install_apk:
print("Installing ADB Keyboard to enable typewriting...")
apk_path = os.path.join(os.path.dirname(os.path.abspath(insomniac.__file__)), "assets", ADB_KEYBOARD_APK)
adb_keybpard_apk = ADB_KEYBOARD_APK if is_insomniac() else ADB_KEYBOARD_APK_NOMIX
apk_path = os.path.join(os.path.dirname(os.path.abspath(insomniac.__file__)), "assets", adb_keybpard_apk)
os.popen("adb" + ("" if self.device_id is None else " -s " + self.device_id)
+ f" install {apk_path}").close()
self.is_adb_keyboard_set = self._set_adb_ime()
Expand Down
4 changes: 3 additions & 1 deletion insomniac/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def clear_instagram_data(device_id, app_id):
f" shell pm clear {app_id}").close()


def execute_command(cmd) -> Optional[str]:
def execute_command(cmd, error_allowed=True) -> Optional[str]:
try:
cmd_res = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True, encoding="utf8")
except IndexError:
Expand All @@ -181,6 +181,8 @@ def execute_command(cmd) -> Optional[str]:
err = err.strip()
if len(err) > 0:
print(COLOR_FAIL + err.strip() + COLOR_ENDC)
if not error_allowed:
return None
if out is not None:
return out.strip()
return None
Expand Down

0 comments on commit 7bb4c55

Please sign in to comment.