Skip to content
This repository has been archived by the owner on Jan 27, 2025. It is now read-only.

Commit

Permalink
Update to v3.6.10
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Mishchenko committed Feb 23, 2021
1 parent 7687c2b commit 18bae3a
Show file tree
Hide file tree
Showing 23 changed files with 403 additions and 164 deletions.
21 changes: 21 additions & 0 deletions config-examples-extra/all-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"value": "True",
"description" : "skip internet speed check at start"
},
{
"parameter-name": "db_directory_path",
"enabled": false,
"value": "main-db-directory-name",
"description" : "when using this parameter the bot will use a database file located under the provided directory. By default account directory is used to store the bot history"
},
{
"parameter-name": "next_config_file",
"enabled": false,
Expand Down Expand Up @@ -71,6 +77,12 @@
"value": "8-21",
"description" : "set working hours to the script, disabled by default. It can be a number presenting specific hour (e.g. 13) or a range (e.g. 9-21)"
},
{
"parameter-name": "working_hours_without_sleep",
"enabled": false,
"value": "8-21",
"description" : "if you use flow, you maybe dont want to wait for working-hours on a specific session, because the following session in the flow might be in the working hours and you dont want to stop the flow. If that's the case, use this parameter"
},
{
"parameter-name": "recheck_follow_status_after",
"enabled": false,
Expand Down Expand Up @@ -138,6 +150,15 @@
"value": "True",
"description" : "use this argument in order to interact with profiles from targets.txt / scrapped profiles"
},
{
"parameter-name": "targets_list",
"enabled": false,
"value": [
"profile-A",
"profile-B"
],
"description" : "list of target-profiles you wish to interact with (in case you want to use parameter and not targets.txt file)"
},
{
"parameter-name": "reinteract_after",
"enabled": false,
Expand Down
15 changes: 15 additions & 0 deletions config-examples/all-params.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
"value": "True",
"description" : "skip internet speed check at start"
},
{
"parameter-name": "db_directory_path",
"enabled": false,
"value": "main-db-directory-name",
"description" : "when using this parameter the bot will use a database file located under the provided directory. By default account directory is used to store the bot history"
},
{
"parameter-name": "next_config_file",
"enabled": false,
Expand Down Expand Up @@ -120,6 +126,15 @@
"value": "True",
"description" : "use this argument in order to interact with profiles from targets.txt / scrapped profiles"
},
{
"parameter-name": "targets_list",
"enabled": false,
"value": [
"profile-A",
"profile-B"
],
"description" : "list of target-profiles you wish to interact with (in case you want to use parameter and not targets.txt file)"
},
{
"parameter-name": "reinteract_after",
"enabled": false,
Expand Down
39 changes: 36 additions & 3 deletions insomniac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import argparse
import json

import insomniac.__version__ as __version__
from insomniac import network
from insomniac.activation import activation_controller
from insomniac.network import HTTP_OK
from insomniac.params import parse_arguments
from insomniac.utils import *


def run(activation_code=""):
def run(activation_code="", starter_conf_file_path=None):
if not __version__.__debug_mode__:
print_timeless(COLOR_OKGREEN + __version__.__logo__ + COLOR_ENDC)
print_version()
Expand All @@ -19,14 +22,44 @@ def run(activation_code=""):
if not activation_controller.is_activated:
from insomniac.session import InsomniacSession
print_timeless("Using insomniac session-manager without extra-features")
insomniac_session = InsomniacSession()
insomniac_session = InsomniacSession(starter_conf_file_path)
else:
from insomniac.extra_features.session import ExtendedInsomniacSession
insomniac_session = ExtendedInsomniacSession()
insomniac_session = ExtendedInsomniacSession(starter_conf_file_path)

insomniac_session.run()


def is_newer_version_available():
def versiontuple(v):
return tuple(map(int, (v.split("."))))

current_version = __version__.__version__
latest_version = _get_latest_version('insomniac')
if latest_version is not None and versiontuple(latest_version) > versiontuple(current_version):
return True, latest_version

return False, None


def print_version():
print_timeless_ui(COLOR_HEADER + f"Insomniac v{__version__.__version__}" + COLOR_ENDC)
is_new_version_available, latest_version = is_newer_version_available()
if is_new_version_available:
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("")


def _get_latest_version(package):
latest_version = None
code, body, _ = network.get(f"https://pypi.python.org/pypi/{package}/json")
if code == HTTP_OK and body is not None:
json_package = json.loads(body)
latest_version = json_package['info']['version']
return latest_version


def _get_activation_code_from_args():
parser = ArgumentParser(add_help=False)
parser.add_argument('--activation-code')
Expand Down
3 changes: 3 additions & 0 deletions insomniac/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import insomniac

insomniac.run()
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.8'
__version__ = '3.6.10'
__debug_mode__ = False
__author__ = 'Insomniac Team'
__author_email__ = 'info@insomniac-bot.com'
Expand Down
19 changes: 13 additions & 6 deletions insomniac/action_runners/interact/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class InteractBySourceActionRunner(CoreActionsRunner):
'metavar': '2-4',
"default": '2'
},
"like_percentage": {
"likes_percentage": {
"help": "likes given percentage of interacted users, 100 by default",
"metavar": '50',
"default": '100'
Expand Down Expand Up @@ -96,8 +96,8 @@ def is_source_hashtag(source):
if args.follow_percentage is not None:
self.follow_percentage = int(args.follow_percentage)

if args.like_percentage is not None:
self.like_percentage = int(args.like_percentage)
if args.likes_percentage is not None:
self.like_percentage = int(args.likes_percentage)

if args.comment_percentage is not None:
self.comment_percentage = int(args.comment_percentage)
Expand Down Expand Up @@ -214,6 +214,13 @@ class InteractByTargetsActionRunner(CoreActionsRunner):
"help": "use this argument in order to interact with profiles from targets.txt",
'metavar': 'True / False'
},
"targets_list": {
"nargs": '+',
"help": 'list of target-profiles you wish to interact with (in case you want to use parameter '
'and not targets.txt file)',
"default": [],
"metavar": ('profile-A', 'profile-B')
},
"likes_count": {
"help": "number of likes for each interacted user, 2 by default. "
"It can be a number (e.g. 2) or a range (e.g. 2-4)",
Expand All @@ -225,7 +232,7 @@ class InteractByTargetsActionRunner(CoreActionsRunner):
"metavar": '50',
"default": '0'
},
"like_percentage": {
"likes_percentage": {
"help": "likes given percentage of interacted users, 100 by default",
"metavar": '50',
"default": '100'
Expand Down Expand Up @@ -278,8 +285,8 @@ def set_params(self, args):
if args.follow_percentage is not None:
self.follow_percentage = int(args.follow_percentage)

if args.like_percentage is not None:
self.like_percentage = int(args.like_percentage)
if args.likes_percentage is not None:
self.like_percentage = int(args.likes_percentage)

if args.comment_percentage is not None:
self.comment_percentage = int(args.comment_percentage)
Expand Down
8 changes: 8 additions & 0 deletions insomniac/action_runners/interact/action_handle_blogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def pre_conditions(follower_name, follower_name_view):
return True

def interact_with_follower(follower_name, follower_name_view):
"""
:return: whether we should continue interaction with other users after this one
"""
is_interact_limit_reached, interact_reached_source_limit, interact_reached_session_limit = \
is_limit_reached(InteractAction(source=username, user=follower_name, succeed=True), session_state)

Expand Down Expand Up @@ -162,6 +165,11 @@ def interact_with_follower(follower_name, follower_name_view):

is_private = follower_profile_view.is_private_account()
if is_private:
if is_passed_filters is None:
print(COLOR_OKGREEN + "@" + follower_name + " has private account, won't interact." + COLOR_ENDC)
print("Back to profiles list")
device.back()
return True
print("@" + follower_name + ": Private account - images wont be liked.")

do_have_stories = follower_profile_view.is_story_available()
Expand Down
8 changes: 8 additions & 0 deletions insomniac/action_runners/interact/action_handle_hashtag.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def pre_conditions(liker_username, liker_username_view):
return True

def interact_with_profile(liker_username, liker_username_view):
"""
:return: whether we should continue interaction with other users after this one
"""
is_interact_limit_reached, interact_reached_source_limit, interact_reached_session_limit = \
is_limit_reached(InteractAction(source=interaction_source, user=liker_username, succeed=True), session_state)

Expand Down Expand Up @@ -137,6 +140,11 @@ def interact_with_profile(liker_username, liker_username_view):

is_private = is_private_account(device)
if is_private:
if is_passed_filters is None:
print(COLOR_OKGREEN + "@" + liker_username + " has private account, won't interact." + COLOR_ENDC)
print("Back to likers list")
device.back()
return True
print("@" + liker_username + ": Private account - images wont be liked.")

do_have_stories = do_have_story(device)
Expand Down
8 changes: 8 additions & 0 deletions insomniac/action_runners/interact/action_handle_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ def pre_conditions(liker_username, liker_username_view):
return True

def interact_with_profile(liker_username, liker_username_view):
"""
:return: whether we should continue interaction with other users after this one
"""
is_interact_limit_reached, interact_reached_source_limit, interact_reached_session_limit = \
is_limit_reached(InteractAction(source=interaction_source, user=liker_username, succeed=True), session_state)

Expand Down Expand Up @@ -137,6 +140,11 @@ def interact_with_profile(liker_username, liker_username_view):

is_private = is_private_account(device)
if is_private:
if is_passed_filters is None:
print(COLOR_OKGREEN + "@" + liker_username + " has private account, won't interact." + COLOR_ENDC)
print("Back to likers list")
device.back()
return True
print("@" + liker_username + ": Private account - images wont be liked.")

do_have_stories = do_have_story(device)
Expand Down
4 changes: 4 additions & 0 deletions insomniac/action_runners/interact/action_handle_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def interact_with_target(target_name, target_name_view):

is_private = is_private_account(device)
if is_private:
if is_passed_filters is None:
print(COLOR_OKGREEN + "@" + target_name + " has private account, won't interact." + COLOR_ENDC)
print("Moving to next target")
return
print("@" + target_name + ": Private account - images wont be liked.")

do_have_stories = do_have_story(device)
Expand Down
30 changes: 18 additions & 12 deletions insomniac/actions_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,12 @@ def open_photo():
if to_like:
print("Double click!")

def find_post_view():
return device.find(resourceIdMatches=POST_VIEW_ID_REGEX.format(device.app_id, device.app_id),
className='android.widget.FrameLayout')

post_view = find_post_view()
post_view = device.find(resourceIdMatches=POST_VIEW_ID_REGEX.format(device.app_id, device.app_id),
className='android.widget.FrameLayout')
if post_view.exists:
post_view.double_click()
sleeper.random_sleep()
if not find_post_view().exists(quick=True):
if not post_view.exists(quick=True):
print(COLOR_OKGREEN + "Accidentally went out of the post page, going back..." + COLOR_ENDC)
device.back()
else:
Expand All @@ -391,6 +388,13 @@ def find_post_view():
post_view.double_click()
sleeper.random_sleep()

# If like button is not visible, scroll down
like_button = device.find(resourceId=f'{device.app_id}:id/row_feed_button_like',
className='android.widget.ImageView')
if not like_button.exists(quick=True) or not ActionBarView.is_in_interaction_rect(like_button):
print("Swiping down a bit to see if is liked")
device.swipe(DeviceFacade.Direction.TOP)

# If double click didn't work, set like by icon click
try:
# Click only button which is under the action bar and above the tab bar.
Expand Down Expand Up @@ -418,12 +422,14 @@ def find_post_view():


def _comment(device, my_username, comments_list, on_comment):
comment_button = device.find(
resourceId=f'{device.app_id}:id/row_feed_button_comment',
className="android.widget.ImageView",
)
comment_button = device.find(resourceId=f'{device.app_id}:id/row_feed_button_comment',
className="android.widget.ImageView")
if not comment_button.exists(quick=True) or not ActionBarView.is_in_interaction_rect(comment_button):
print("Cannot find comment button – will try to swipe down a bit")
device.swipe(DeviceFacade.Direction.TOP)
if not comment_button.exists(quick=True):
print("Couldn't find comment button - not commenting...")
print("Still cannot find comment button – won't comment")
return

comment_box_exists = False
comment_box = None
Expand Down Expand Up @@ -465,7 +471,7 @@ def _comment(device, my_username, comments_list, on_comment):
print("Comment succeed.")
on_comment(comment)
else:
print("Failed to check if comment succeed.")
print(COLOR_FAIL + "Failed to check if comment succeed." + COLOR_ENDC)

sleeper.random_sleep()
print("Go back to post view.")
Expand Down
Loading

0 comments on commit 18bae3a

Please sign in to comment.