Skip to content

Commit

Permalink
Merge pull request #241 from alexal1/beta
Browse files Browse the repository at this point in the history
Added v3.6.5
  • Loading branch information
Fadude committed Jan 10, 2021
2 parents 7ad27c8 + 3f54743 commit 69541c0
Show file tree
Hide file tree
Showing 15 changed files with 621 additions and 152 deletions.
302 changes: 302 additions & 0 deletions docs/README.md

Large diffs are not rendered by default.

86 changes: 86 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[< Back to the documentation](/#)

## Installation
If you prefer video lessons, welcome to the [Udemy Course](https://insomniac-bot.com/udemy_course/). We'll go through all installation steps together!

### Windows
1. Download and install python from [python.org](https://www.python.org/downloads/windows/). Better choose latest stable release.
2. Open Command Prompt.
3. Run `python -m pip install --upgrade pip` to make sure you've got the latest pip version.
4. Run `python -m pip install insomniac` to install insomniac package.
5. Download [start.py](https://raw.githubusercontent.com/alexal1/Insomniac/master/start.py) to a directory where you're going to launch the script from (right-click on the link, then Save As).
6. Download and unzip [Android platform tools](https://developer.android.com/studio/releases/platform-tools), move them to a folder where you won't delete them accidentally. Standard place is `C:\Users\<your username>\Android\sdk\platform-tools\`.
7. [Add platform-tools path to the PATH environment variable](https://github.com/alexal1/Insomniac/wiki/Adding-platform-tools-to-the-PATH-environment-variable). If you do it correctly, Command Prompt command `adb devices` will print `List of devices attached`.
8. Connect your Android phone via USB cable _or_ use [emulator](https://www.patreon.com/posts/how-to-install-43543116).
9. Enable [Developer options](https://developer.android.com/studio/debug/dev-options#enable) on the Android phone/emulator:
>On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times. You can find this option in one of the following locations, depending on your Android version:
>
> Android 9 (API level 28) and higher: Settings > About Phone > Build Number
>
> Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
>
> Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
10. Switch on **USB debugging** (and also **Install apps via USB** and **Allow ADB debugging in charge only mode** if there are such options) on the Developer options screen.
11. Android device will ask you to allow computer connection. Press "Connect".
12. Type `adb devices` in Command Prompt. It will display attached devices. There should be exactly one device.

### macOS
1. Download and install python from [python.org](https://www.python.org/downloads/mac-osx/). Better choose latest stable release.
2. Open Terminal.
3. Run `python3 -m pip install --upgrade pip` to make sure you've got the latest pip version.
4. Run `python3 -m pip install insomniac` to install insomniac package.
5. Download [start.py](https://raw.githubusercontent.com/alexal1/Insomniac/master/start.py) to a directory where you're going to launch the script from (right-click on the link, then Download Linked File As).
6. Download and unzip [Android platform tools](https://developer.android.com/studio/releases/platform-tools), move them to a folder where you won't delete them accidentally. Standard place is `~/Library/Android/sdk/platform-tools/`.
7. [Add platform-tools path to the PATH environment variable](https://github.com/alexal1/Insomniac/wiki/Adding-platform-tools-to-the-PATH-environment-variable). If you do it correctly, Terminal command `adb devices` will print `List of devices attached`.
8. Connect your Android phone via USB cable _or_ use [emulator](https://www.patreon.com/posts/how-to-install-43485861).
9. Enable [Developer options](https://developer.android.com/studio/debug/dev-options#enable) on the Android phone/emulator:
>On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times. You can find this option in one of the following locations, depending on your Android version:
>
> Android 9 (API level 28) and higher: Settings > About Phone > Build Number
>
> Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
>
> Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
10. Switch on **USB debugging** (and also **Install apps via USB** and **Allow ADB debugging in charge only mode** if there are such options) on the Developer options screen.
11. Android device will ask you to allow computer connection. Press "Connect".
12. Type `adb devices` in Terminal. It will display attached devices. There should be exactly one device.

### Ubuntu
1. Open Terminal.
2. Run `sudo apt-get update && sudo apt-get upgrade` to update & upgrade current packages.
3. Run `sudo apt install python3-pip` to install pip.
4. Run `python3 -m pip install insomniac` to install insomniac package.
5. Download [start.py](https://raw.githubusercontent.com/alexal1/Insomniac/master/start.py) to a directory where you're going to launch the script from (right-click on the link, then Save Link As).
6. Run `sudo apt-get install -y android-tools-adb android-tools-fastboot` to install Android platform tools.
7. Connect your Android phone via USB cable _or_ use [emulator](https://www.patreon.com/posts/how-to-install-43485861).
8. Enable [Developer options](https://developer.android.com/studio/debug/dev-options#enable) on the Android phone/emulator:
>On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times. You can find this option in one of the following locations, depending on your Android version:
>
> Android 9 (API level 28) and higher: Settings > About Phone > Build Number
>
> Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
>
> Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
9. Switch on **USB debugging** (and also **Install apps via USB** and **Allow ADB debugging in charge only mode** if there are such options) on the Developer options screen.
10. Android device will ask you to allow computer connection. Press "Connect".
11. Type `adb devices` in Terminal. It will display attached devices. There should be exactly one device.

### Raspberry Pi
1. Open Terminal.
2. Run `python3 -m pip install --upgrade pip` to make sure you've got the latest pip version.
3. Run `python3 -m pip install insomniac` to install insomniac package.
4. Download [start.py](https://raw.githubusercontent.com/alexal1/Insomniac/master/start.py) to a directory where you're going to launch the script from (right-click on the link, then Save link as).
5. Run `sudo apt-get update && sudo apt-get upgrade` to update & upgrade current packages.
6. Run `sudo apt-get install -y android-tools-adb android-tools-fastboot` to install Android platform tools.
7. Connect your Android phone via USB cable _or_ use [emulator](https://www.patreon.com/posts/how-to-install-43485861).
8. Enable [Developer options](https://developer.android.com/studio/debug/dev-options#enable) on the Android phone/emulator:
>On Android 4.1 and lower, the Developer options screen is available by default. On Android 4.2 and higher, you must enable this screen. To enable developer options, tap the Build Number option 7 times. You can find this option in one of the following locations, depending on your Android version:
>
> Android 9 (API level 28) and higher: Settings > About Phone > Build Number
>
> Android 8.0.0 (API level 26) and Android 8.1.0 (API level 26): Settings > System > About Phone > Build Number
>
> Android 7.1 (API level 25) and lower: Settings > About Phone > Build Number
9. Switch on **USB debugging** (and also **Install apps via USB** and **Allow ADB debugging in charge only mode** if there are such options) on the Developer options screen.
10. Android device will ask you to allow computer connection. Press "Connect".
11. Type `adb devices` in Terminal. It will display attached devices. There should be exactly one device.
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.6.0'
__version__ = '3.6.5'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = 'info@insomniac-bot.com'
Expand Down
13 changes: 7 additions & 6 deletions insomniac/action_runners/interact/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ class InteractBySourceActionRunner(CoreActionsRunner):
},
"interact": {
"nargs": '+',
"help": 'list of hashtags and usernames. Usernames should start with \"@\" symbol. '
'You can specify the way of interaction after a \"-\" sign: @username-followers, '
'@username-following, hashtag-top-likers, hashtag-recent-likers',
"help": 'list of hashtags, usernames, or places. Usernames should start with \"@\" symbol. Places should '
'start with \"P-\" symbols. You can specify the way of interaction after a \"-\" sign: '
'@natgeo-followers, @natgeo-following, amazingtrips-top-likers, amazingtrips-recent-likers, '
'P-Paris-top-likers, P-Paris-recent-likers',
"default": [],
"metavar": ('hashtag-top-likers', '@username-followers')
"metavar": ('amazingtrips-top-likers', '@natgeo-followers')
},
"interaction_users_amount": {
"help": 'add this argument to select an amount of users from the interact-list '
'(users are randomized). It can be a number (e.g. 4) or a range (e.g. 3-8)',
"help": 'add this argument to select an amount of sources from the interact-list '
'(sources are randomized). It can be a number (e.g. 4) or a range (e.g. 3-8)',
'metavar': '3-8'
},
"stories_count": {
Expand Down
30 changes: 20 additions & 10 deletions insomniac/action_runners/interact/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ def pre_conditions(follower_name, follower_name_view):
elif is_myself and storage.check_user_was_interacted_recently(follower_name):
print("@" + follower_name + ": already interacted in the last week. Skip.")
return False
elif is_passed_filters is not None:
if not is_passed_filters(device, follower_name, reset=True, filters_tags=['BEFORE_PROFILE_CLICK']):
storage.add_filtered_user(follower_name)
return False

return True

Expand All @@ -116,6 +112,18 @@ def interact_with_follower(follower_name, follower_name_view):
get_profile_reached_source_limit, action_status, "Get-Profile"):
return False

is_all_filters_satisfied = False
if is_passed_filters is not None:
print_debug(f"Running filter-ahead on @{follower_name}")
should_continue, is_all_filters_satisfied = is_passed_filters(device, follower_name, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
storage.add_filtered_user(follower_name)
return True

if not is_all_filters_satisfied:
print_debug("Not all filters are satisfied with filter-ahead, continue filtering inside the profile-page")

print("@" + follower_name + ": interact")
follower_name_view.click()
on_action(GetProfileAction(user=follower_name))
Expand All @@ -131,12 +139,14 @@ def interact_with_follower(follower_name, follower_name_view):
follower_profile_view = ProfileView(device, follower_name == session_state.my_username)

if is_passed_filters is not None:
if not is_passed_filters(device, follower_name, reset=False):
storage.add_filtered_user(follower_name)
# Continue to next follower
print("Back to profiles list")
device.back()
return True
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, follower_name, reset=False)
if not should_continue:
storage.add_filtered_user(follower_name)
# Continue to next follower
print("Back to profiles list")
device.back()
return True

is_like_limit_reached, like_reached_source_limit, like_reached_session_limit = \
is_limit_reached(LikeAction(source=username, user=follower_name), session_state)
Expand Down
54 changes: 38 additions & 16 deletions insomniac/action_runners/interact/action_handle_hashtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def pre_conditions(liker_username, liker_username_view):
elif storage.check_user_was_interacted(liker_username):
print("@" + liker_username + ": already interacted. Skip.")
return False
elif is_passed_filters is not None:
if not is_passed_filters(device, liker_username, reset=True, filters_tags=['BEFORE_PROFILE_CLICK']):
storage.add_filtered_user(liker_username)
return False

return True

Expand All @@ -93,6 +89,18 @@ def interact_with_profile(liker_username, liker_username_view):
get_profile_reached_source_limit, action_status, "Get-Profile"):
return False

is_all_filters_satisfied = False
if is_passed_filters is not None:
print_debug(f"Running filter-ahead on @{liker_username}")
should_continue, is_all_filters_satisfied = is_passed_filters(device, liker_username, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
storage.add_filtered_user(liker_username)
return True

if not is_all_filters_satisfied:
print_debug("Not all filters are satisfied with filter-ahead, continue filtering inside the profile-page")

print("@" + liker_username + ": interact")
liker_username_view.click()
on_action(GetProfileAction(user=liker_username))
Expand All @@ -106,12 +114,14 @@ def interact_with_profile(liker_username, liker_username_view):
return True

if is_passed_filters is not None:
if not is_passed_filters(device, liker_username, reset=False):
storage.add_filtered_user(liker_username)
# Continue to next follower
print("Back to likers list")
device.back()
return True
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, liker_username, reset=False)
if not should_continue:
storage.add_filtered_user(liker_username)
# Continue to next follower
print("Back to likers list")
device.back()
return True

is_like_limit_reached, like_reached_source_limit, like_reached_session_limit = \
is_limit_reached(LikeAction(source=interaction_source, user=liker_username), session_state)
Expand Down Expand Up @@ -239,14 +249,26 @@ def extract_hashtag_profiles_and_interact(device,

sleeper.random_sleep()

# Open first post
print("Opening the first post")
# Open post
# Index 1 is reserved for hot Reels by this tag
first_post_index = 2 if instructions == HashtagInteractionType.TOP_LIKERS else 1
first_post_view = device.find(resourceId=f'{device.app_id}:id/image_button',
className='android.widget.ImageView',
index=first_post_index)
first_post_view.click()
post_num = randint(first_post_index, 20)
print(f"Opening post #{post_num}")
post_view = device.find(resourceId=f'{device.app_id}:id/image_button',
className='android.widget.ImageView',
index=post_num)

for _ in range(0, 10):
if post_view.exists(quick=True):
break

print(f"Cannot find post #{post_num}. Swiping down a bit.")
device.swipe(DeviceFacade.Direction.TOP)

if not post_view.exists(quick=True):
print(f"Cannot find post #{post_num} after 10 swipes. Aborting.")

post_view.click()
sleeper.random_sleep()

posts_list_view = device.find(resourceId='android:id/list',
Expand Down
54 changes: 38 additions & 16 deletions insomniac/action_runners/interact/action_handle_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,6 @@ def pre_conditions(liker_username, liker_username_view):
elif storage.check_user_was_interacted(liker_username):
print("@" + liker_username + ": already interacted. Skip.")
return False
elif is_passed_filters is not None:
if not is_passed_filters(device, liker_username, reset=True, filters_tags=['BEFORE_PROFILE_CLICK']):
storage.add_filtered_user(liker_username)
return False

return True

Expand All @@ -93,6 +89,18 @@ def interact_with_profile(liker_username, liker_username_view):
get_profile_reached_source_limit, action_status, "Get-Profile"):
return False

is_all_filters_satisfied = False
if is_passed_filters is not None:
print_debug(f"Running filter-ahead on @{liker_username}")
should_continue, is_all_filters_satisfied = is_passed_filters(device, liker_username, reset=True,
filters_tags=['BEFORE_PROFILE_CLICK'])
if not should_continue:
storage.add_filtered_user(liker_username)
return True

if not is_all_filters_satisfied:
print_debug("Not all filters are satisfied with filter-ahead, continue filtering inside the profile-page")

print("@" + liker_username + ": interact")
liker_username_view.click()
on_action(GetProfileAction(user=liker_username))
Expand All @@ -106,12 +114,14 @@ def interact_with_profile(liker_username, liker_username_view):
return True

if is_passed_filters is not None:
if not is_passed_filters(device, liker_username, reset=False):
storage.add_filtered_user(liker_username)
# Continue to next follower
print("Back to likers list")
device.back()
return True
if not is_all_filters_satisfied:
should_continue, _ = is_passed_filters(device, liker_username, reset=False)
if not should_continue:
storage.add_filtered_user(liker_username)
# Continue to next follower
print("Back to likers list")
device.back()
return True

is_like_limit_reached, like_reached_source_limit, like_reached_session_limit = \
is_limit_reached(LikeAction(source=interaction_source, user=liker_username), session_state)
Expand Down Expand Up @@ -239,13 +249,25 @@ def extract_place_profiles_and_interact(device,

sleeper.random_sleep()

# Open first post
print("Opening the first post")
# Open post
first_post_index = 2
first_post_view = device.find(resourceId=f'{device.app_id}:id/image_button',
className='android.widget.ImageView',
index=first_post_index)
first_post_view.click()
post_num = randint(first_post_index, 20)
print(f"Opening post #{post_num}")
post_view = device.find(resourceId=f'{device.app_id}:id/image_button',
className='android.widget.ImageView',
index=post_num)

for _ in range(0, 10):
if post_view.exists(quick=True):
break

print(f"Cannot find post #{post_num}. Swiping down a bit.")
device.swipe(DeviceFacade.Direction.TOP)

if not post_view.exists(quick=True):
print(f"Cannot find post #{post_num} after 10 swipes. Aborting.")

post_view.click()
sleeper.random_sleep()

posts_list_view = device.find(resourceId='android:id/list',
Expand Down
Loading

0 comments on commit 69541c0

Please sign in to comment.