Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎁 NEW FEATURE: COMMENT POSTS #156

Merged
merged 78 commits into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f9741a3
Fix follow (#109)
mastrolube Dec 1, 2020
531dd7e
🎁 adding --debug flag (#105)
philip-ulrich Dec 2, 2020
292b2fa
🐈 pause option when quitting (#115)
Dec 2, 2020
48997e3
🐈 improvements for hashtag-likers on older devices and memu (#112)
mastrolube Dec 2, 2020
ee84ffb
following and follower filter (#106)
philip-ulrich Dec 3, 2020
bb34564
Fix crash stories and private profile (#117)
mastrolube Dec 6, 2020
71361b0
Fix --analytics Bugs with Missing Session Data (#103)
philip-ulrich Dec 6, 2020
360cad9
Changing to Pypi for Release (#118)
philip-ulrich Dec 6, 2020
92f754f
fixing bio expand (#120)
philip-ulrich Dec 7, 2020
4de2abf
noice (#121)
philip-ulrich Dec 7, 2020
c128d1d
:memo: typo
philip-ulrich Dec 7, 2020
9b7570e
speed multiplier and scrolls limit (#124)
philip-ulrich Dec 7, 2020
8eb84cc
Create interact_hashtag_posts.py
mastrolube Dec 5, 2020
2112923
resolving conflicts
mastrolube Dec 6, 2020
c63e5a7
resolving conflicts
mastrolube Dec 6, 2020
bdf42e7
forget to remove old codes
mastrolube Dec 6, 2020
a5062a4
small cleanups
philip-ulrich Dec 7, 2020
c9574e6
changing reference to old arguemnt name
philip-ulrich Dec 7, 2020
18b09a8
:rage: linting
philip-ulrich Dec 7, 2020
9057d3c
switching to get_value for session_state total_limits (#132)
philip-ulrich Dec 7, 2020
61983a6
bugfixes + hashtag-post improve
mastrolube Dec 7, 2020
30c24b9
Merge branch 'hashtag-post-recent' of https://github.com/GramAddict/b…
mastrolube Dec 7, 2020
1c5acd5
--hashtag-posts-top
mastrolube Dec 8, 2020
0ad50a4
black by hands
mastrolube Dec 8, 2020
d89826c
Update interact_hashtag_posts.py
mastrolube Dec 8, 2020
3eb8f1e
Update interaction.py
mastrolube Dec 8, 2020
81c6739
Merge branch 'develop' into hashtag-post-recent
philip-ulrich Dec 8, 2020
7b9997b
Update interact_hashtag_posts.py
mastrolube Dec 8, 2020
ca8d54c
Merge branch 'hashtag-post-recent' of https://github.com/GramAddict/b…
mastrolube Dec 8, 2020
7ddbaf1
Update interact_hashtag_posts.py
mastrolube Dec 8, 2020
29b7482
update readme (#125)
philip-ulrich Dec 8, 2020
9033c60
add logic to handle unfollowing any-non-followers (#133)
philip-ulrich Dec 8, 2020
7b3c487
fixes and improvements
mastrolube Dec 8, 2020
4738422
- fix another bug if recent and top are used toghetter
mastrolube Dec 8, 2020
85f822f
Update interact_hashtag_likers.py
mastrolube Dec 8, 2020
f161bfd
bugfixes and improvements
mastrolube Dec 9, 2020
33dc6a4
Update interaction.py
mastrolube Dec 9, 2020
6fd1b8e
fixs
mastrolube Dec 10, 2020
a7c661d
Merge branch 'develop' into hashtag-post-recent
mastrolube Dec 10, 2020
590849d
Get rid of possible inifinite loops (#135)
arthurspa Dec 11, 2020
f9abc4c
fixes
mastrolube Dec 11, 2020
f596fd6
Merge branch 'develop' into hashtag-post-recent
philip-ulrich Dec 11, 2020
d3dc232
config file update / uia1 support (#136)
philip-ulrich Dec 12, 2020
20d4e5a
Merge branch 'develop' into hashtag-post-recent
mastrolube Dec 12, 2020
c767155
merge things
mastrolube Dec 12, 2020
67d543c
porting missing resources
mastrolube Dec 12, 2020
4d6c767
Update action_unfollow_followers.py
mastrolube Dec 12, 2020
408c3b3
cleaning and fixing things
mastrolube Dec 13, 2020
6be2ecf
Update views.py
mastrolube Dec 13, 2020
ab2b2a3
Update session_state.py
mastrolube Dec 13, 2020
cfc901a
Hashtag post recent (#129)
philip-ulrich Dec 13, 2020
e6fc4bb
fixes (#143)
mastrolube Dec 13, 2020
c880fc3
minor fixes
philip-ulrich Dec 14, 2020
1998862
updating verbiage on fling
philip-ulrich Dec 14, 2020
d617e89
kill atx-agent and uia1
philip-ulrich Dec 14, 2020
b479c37
Create interact_usernames.py (#128)
philip-ulrich Dec 14, 2020
040d8fe
config updates (#145)
philip-ulrich Dec 14, 2020
1682af4
updating deployment info and file structure
philip-ulrich Dec 14, 2020
226589e
update varable name
philip-ulrich Dec 14, 2020
b2d47fb
Hashtag-likers improvement (#147)
mastrolube Dec 14, 2020
0b3b030
adding additional instructions for deployment
philip-ulrich Dec 15, 2020
fe561a7
fixing parameters and deployment files
philip-ulrich Dec 15, 2020
d4b7916
change username according to configuration file loaded (#149)
mastrolube Dec 15, 2020
b8d0955
updating version
philip-ulrich Dec 16, 2020
dcfe8d3
new core argument --delete-interacted-user (#150)
mastrolube Dec 17, 2020
1715b3e
:gift: NEW FEATURE: COMMENT POSTS
mastrolube Dec 19, 2020
8c3b466
Update all-parameters.yml
philip-ulrich Dec 21, 2020
d434b76
Update all-parameters.yml
philip-ulrich Dec 21, 2020
ce649ae
resolving conflicts
philip-ulrich Dec 22, 2020
e7defd5
Merge branch 'develop' into comment-posts
philip-ulrich Dec 22, 2020
375b675
revert a stupid change :)
mastrolube Dec 23, 2020
e84fdee
Merge pull request #168 from GramAddict/develop
philip-ulrich Jan 1, 2021
6199b24
Merge branch 'master' into comment-posts
mastrolube Jan 5, 2021
84905a6
typo
mastrolube Jan 5, 2021
d4b7fc2
fix merge error
mastrolube Jan 5, 2021
340d74a
Merge branch 'develop' into comment-posts
philip-ulrich Jan 17, 2021
1cf031a
removing unused variable
philip-ulrich Jan 17, 2021
678cc37
fixing lint
philip-ulrich Jan 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion GramAddict/core/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def check_profile(self, device, username):
field_max_followers
):
logger.info(
f"@{username} has has more than {field_max_followers} followers, skip.",
f"@{username} has more than {field_max_followers} followers, skip.",
extra={"color": f"{Fore.GREEN}"},
)
return self.return_check_profile(
Expand Down
96 changes: 92 additions & 4 deletions GramAddict/core/interaction.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging
from random import randint, shuffle
from random import randint, shuffle, choice
from typing import Tuple
from time import time
from os import path
from colorama import Fore
from GramAddict.core.navigation import switch_to_english
from GramAddict.core.report import print_short_report
Expand Down Expand Up @@ -43,6 +44,7 @@ def interact_with_user(
on_watch,
can_follow,
follow_percentage,
comment_percentage,
profile_filter,
args,
session_state,
Expand Down Expand Up @@ -124,6 +126,9 @@ def interact_with_user(
shuffle(photos_indices)
photos_indices = photos_indices[:likes_value]
photos_indices = sorted(photos_indices)
like_done = False
comment_done = False
interacted = False
for i in range(0, len(photos_indices)):
photo_index = photos_indices[i]
row = photo_index // 3
Expand All @@ -134,12 +139,31 @@ def interact_with_user(

like_succeed = False
if opened_post_view:
logger.info("Double click post.")

like_succeed = do_like(opened_post_view, device, on_like)
if not like_succeed:
logger.debug("Double click failed. Try the like button.")
like_succeed = opened_post_view.likePost(click_btn_like=True)

if like_succeed is True:
number_of_liked += 1
like_done = True
logger.debug("Like succeed. Check for block.")
detect_block(device)
on_like()
else:
logger.warning("Fail to like post. Let's continue...")

logger.info("Back to profile.")
device.back()
comment_done = _comment(
device, my_username, comment_percentage, args, session_state
)
logger.info("Back to profile.")
device.back()
if like_done or comment_done:
interacted = True
else:
interacted = False

if not opened_post_view or not like_succeed:
reason = "open" if not opened_post_view else "like"
Expand All @@ -160,7 +184,6 @@ def interact_with_user(
if not followed:
logger.info("Skip user.", extra={"color": f"{Fore.GREEN}"})
return False, followed, number_of_liked, number_of_watched

random_sleep()
if can_follow:
return (
Expand Down Expand Up @@ -243,6 +266,71 @@ def _on_interaction(
return can_continue


def _comment(device, my_username, comment_percentage, args, session_state):
if not session_state.check_limit(
args, limit_type=session_state.Limit.COMMENTS, output=False
):
comment_chance = randint(1, 100)
if comment_chance > comment_percentage:
return False
UniversalActions(device)._swipe_points(
direction=Direction.DOWN, delta_y=randint(150, 250)
)
for _ in range(2):
comment_button = device.find(
resourceId=ResourceID.ROW_FEED_BUTTON_COMMENT,
className=ClassName.IMAGE_VIEW,
)
if comment_button.exists(True):
logger.info("Open comments of post.")
comment_button.click()
random_sleep()
comment_box = device.find(
resourceId=ResourceID.LAYOUT_COMMENT_THREAD_EDITTEXT
)
comment = load_random_comment()
logger.info(
f"Write comment: {comment}", extra={"color": f"{Fore.CYAN}"}
)
comment_box.set_text(comment)
random_sleep()
post_button = device.find(
resourceId=ResourceID.LAYOUT_COMMENT_THREAD_POST_BUTTON_CLICK_AREA
)
post_button.click()
random_sleep()
detect_block(device)
device.back()
logger.debug("Close keyboard.")
just_post = device.find(
resourceId=ResourceID.ROW_COMMENT_TEXTVIEW_COMMENT,
textMatches=f"{my_username} {comment}",
)
if just_post.exists(True):
logger.info("Comment succeed.", extra={"color": f"{Fore.GREEN}"})
session_state.totalComments += 1
else:
logger.warning("Failed to check if comment succeed.")
random_sleep(1, 2)
logger.info("Go back to post view.")
device.back()
return True
else:
UniversalActions(device)._swipe_points(
direction=Direction.DOWN, delta_y=randint(150, 250)
)
continue
return False


def load_random_comment():
file_name = "comments_list.txt"
if path.isfile(file_name):
with open(file_name, "r") as f:
lines = f.read().splitlines()
return choice(lines)


def _follow(device, username, follow_percentage, args, session_state, swipe_amount):
if not session_state.check_limit(
args, limit_type=session_state.Limit.FOLLOWS, output=False
Expand Down
14 changes: 11 additions & 3 deletions GramAddict/core/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ def print_full_report(sessions):
f"Total likes: {session.totalLikes}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)
logger.info(
f"Total comments: {session.totalComments}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)
logger.info(
f"Total watched: {session.totalWatched}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
Expand Down Expand Up @@ -117,13 +121,16 @@ def print_full_report(sessions):
f"Total likes: {total_likes}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)

total_comments = sum(session.totalComments for session in sessions)
logger.info(
f"Total comments: {total_comments}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)
total_watched = sum(session.totalWatched for session in sessions)
logger.info(
f"Total watched: {total_watched}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)

total_unfollowed = sum(session.totalUnfollowed for session in sessions)
logger.info(
f"Total unfollowed: {total_unfollowed}",
Expand All @@ -133,11 +140,12 @@ def print_full_report(sessions):

def print_short_report(source, session_state):
total_likes = session_state.totalLikes
total_comments = session_state.totalComments
total_watched = session_state.totalWatched
total_followed = sum(session_state.totalFollowed.values())
interactions = session_state.successfulInteractions.get(source, 0)
logger.info(
f"Session progress: {total_likes} likes, {total_watched} watched, {total_followed} followed, {interactions} successful interaction(s) for {source}",
f"Session progress: {total_likes} likes, {total_comments} comments, {total_watched} watched, {total_followed} followed, {interactions} successful interaction(s) for {source}",
extra={"color": f"{Style.BRIGHT}{Fore.YELLOW}"},
)

Expand Down
7 changes: 7 additions & 0 deletions GramAddict/core/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def __init__(self, APP_ID):
)
self.IMAGE_BUTTON = f"{APP_ID}:id/image_button"
self.LANGUAGE_LIST_LOCALE = f"{APP_ID}:id/language_locale_list"
self.LAYOUT_COMMENT_THREAD_EDITTEXT = (
f"{APP_ID}:id/layout_comment_thread_edittext"
)
self.LAYOUT_COMMENT_THREAD_POST_BUTTON_CLICK_AREA = (
f"{APP_ID}:id/layout_comment_thread_post_button_click_area"
)
self.LIST = "android:id/list"
self.MEDIA_GROUP = f"{APP_ID}:id/media_group"
self.MENU_SETTINGS_ROW = f"{APP_ID}:id/menu_settings_row"
Expand All @@ -43,6 +49,7 @@ def __init__(self, APP_ID):
self.REEL_VIEWER_IMAGE_VIEW = f"{APP_ID}:id/reel_viewer_image_view"
self.REEL_VIEWER_TIMESTAMP = f"{APP_ID}:id/reel_viewer_timestamp"
self.REEL_VIEWER_TITLE = f"{APP_ID}:id/reel_viewer_title"
self.ROW_COMMENT_TEXTVIEW_COMMENT = f"{APP_ID}:id/row_comment_textview_comment"
self.ROW_FEED_BUTTON_COMMENT = f"{APP_ID}:id/row_feed_button_comment"
self.ROW_FEED_BUTTON_LIKE = f"{APP_ID}:id/row_feed_button_like"
self.ROW_FEED_COMMENT_TEXTVIEW_LAYOUT = (
Expand Down
28 changes: 21 additions & 7 deletions GramAddict/core/session_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SessionState:
successfulInteractions = {}
totalFollowed = {}
totalLikes = 0
totalComments = 0
totalWatched = 0
totalUnfollowed = 0
removedMassFollowers = []
Expand All @@ -34,6 +35,7 @@ def __init__(self, configs):
self.successfulInteractions = {}
self.totalFollowed = {}
self.totalLikes = 0
self.totalComments = 0
self.totalWatched = 0
self.totalUnfollowed = 0
self.removedMassFollowers = []
Expand Down Expand Up @@ -65,6 +67,8 @@ def check_limit(self, args, limit_type=None, output=False):
total_likes = self.totalLikes >= int(likes_limit)
follow_limit = get_value(args.total_follows_limit, None, 50)
total_followed = sum(self.totalFollowed.values()) >= int(follow_limit)
comments_limit = get_value(args.total_comments_limit, None, 50)
total_comments = self.totalComments >= int(comments_limit)
watch_limit = get_value(args.total_watches_limit, None, 50)
total_watched = self.totalWatched >= int(watch_limit)
success_limit = get_value(args.total_successful_interactions_limit, None, 100)
Expand All @@ -77,6 +81,7 @@ def check_limit(self, args, limit_type=None, output=False):
session_info = [
"Checking session limits:",
f"- Total Likes:\t\t\t\t{'Limit Reached' if total_likes else 'OK'} ({self.totalLikes}/{likes_limit})",
f"- Total Comments:\t\t\t\t{'Limit Reached' if total_likes else 'OK'} ({self.totalComments}/{comments_limit})",
f"- Total Followed:\t\t\t\t{'Limit Reached' if total_followed else 'OK'} ({sum(self.totalFollowed.values())}/{follow_limit})",
f"- Total Watched:\t\t\t\t{'Limit Reached' if total_watched else 'OK'} ({self.totalWatched}/{watch_limit})",
f"- Total Successful Interactions:\t\t{'Limit Reached' if total_successful else 'OK'} ({sum(self.successfulInteractions.values())}/{success_limit})",
Expand All @@ -102,32 +107,39 @@ def check_limit(self, args, limit_type=None, output=False):
logger.debug(session_info[1])
return total_likes or (total_interactions or total_successful)

elif limit_type == SessionState.Limit.FOLLOWS:
elif limit_type == SessionState.Limit.COMMENTS:
if output:
logger.info(session_info[2])
else:
logger.debug(session_info[2])
return total_followed or (total_interactions or total_successful)
return total_comments or (total_interactions or total_successful)

elif limit_type == SessionState.Limit.WATCHES:
elif limit_type == SessionState.Limit.FOLLOWS:
if output:
logger.info(session_info[3])
else:
logger.debug(session_info[3])
return total_watched or (total_interactions or total_successful)
return total_followed or (total_interactions or total_successful)

elif limit_type == SessionState.Limit.SUCCESS:
elif limit_type == SessionState.Limit.WATCHES:
if output:
logger.info(session_info[4])
else:
logger.debug(session_info[4])
return total_successful or total_interactions
return total_watched or (total_interactions or total_successful)

elif limit_type == SessionState.Limit.TOTAL:
elif limit_type == SessionState.Limit.SUCCESS:
if output:
logger.info(session_info[5])
else:
logger.debug(session_info[5])
return total_successful or total_interactions

elif limit_type == SessionState.Limit.TOTAL:
if output:
logger.info(session_info[6])
else:
logger.debug(session_info[6])
return total_interactions or total_successful

def is_finished(self):
Expand All @@ -136,6 +148,7 @@ def is_finished(self):
class Limit(Enum):
ALL = auto()
LIKES = auto()
COMMENTS = auto()
FOLLOWS = auto()
WATCHES = auto()
SUCCESS = auto()
Expand All @@ -152,6 +165,7 @@ def default(self, session_state: SessionState):
),
"total_followed": sum(session_state.totalFollowed.values()),
"total_likes": session_state.totalLikes,
"total_comments": session_state.totalComments,
"total_watched": session_state.totalWatched,
"total_unfollowed": session_state.totalUnfollowed,
"start_time": str(session_state.startTime),
Expand Down
14 changes: 14 additions & 0 deletions GramAddict/plugins/core_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,18 @@ def __init__(self):
"help": "delete the user from the file after processing it",
"action": "store_true",
},
{
"arg": "--comment-percentage",
"nargs": None,
"help": "comment given percentage of interacted users, 0 by default",
"metavar": "50",
"default": "0",
},
{
"arg": "--total-comments-limit",
"nargs": None,
"help": "limit on total comments per session, disabled by default",
"metavar": "10-90",
"default": "0",
},
]
3 changes: 3 additions & 0 deletions GramAddict/plugins/force_interact.dis
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class ForceIteract(Plugin):
stories_percentage,
int(args.follow_percentage),
int(args.follow_limit) if args.follow_limit else None,
int(self.args.comment_percentage),
plugin,
storage,
profile_filter,
Expand All @@ -151,6 +152,7 @@ class ForceIteract(Plugin):
stories_percentage,
follow_percentage,
follow_limit,
comment_percentage,
current_job,
storage,
profile_filter,
Expand All @@ -166,6 +168,7 @@ class ForceIteract(Plugin):
stories_count=stories_count,
stories_percentage=stories_percentage,
follow_percentage=follow_percentage,
comment_percentage=comment_percentage,
on_like=on_like,
on_watch=on_watch,
profile_filter=profile_filter,
Expand Down
3 changes: 3 additions & 0 deletions GramAddict/plugins/interact_blogger_followers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def job():
stories_percentage,
int(self.args.follow_percentage),
int(self.args.follow_limit) if self.args.follow_limit else None,
int(self.args.comment_percentage),
plugin,
storage,
profile_filter,
Expand Down Expand Up @@ -149,6 +150,7 @@ def handle_blogger(
stories_percentage,
follow_percentage,
follow_limit,
comment_percentage,
current_job,
storage,
profile_filter,
Expand All @@ -164,6 +166,7 @@ def handle_blogger(
stories_count=stories_count,
stories_percentage=stories_percentage,
follow_percentage=follow_percentage,
comment_percentage=comment_percentage,
on_like=on_like,
on_watch=on_watch,
profile_filter=profile_filter,
Expand Down
Loading