Closed Abdulsamipy closed 4 years ago
Hey @Abdulsamipy,
We did a quick check and this issue looks very darn similar to
This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:
If not, the maintainers will get to this issue shortly.
Cheers, Your Friendly Neighborhood ProBot
https://github.com/instagrambot/instabot/blob/master/instabot/bot/bot.py#L127 Have you overwritten any of these perimeters?
so the bot ask to set these parameters in the starting but it looks like it's not overwriting it in the script i guess
Is that a yes or a no? You can overwrite it. did you do that?
yes i did overwrite the parameters when bot start ... but didn't edit that inside the script
pardon me im a newbie .. so i tried to run the script you provided edit the parameters inside the script and when i run it ..it's saying
from .. import utils
ImportError: attempted relative import with no known parent package
It a simple yes or no awnser. you cannot run the bot script it self. you should check in the example directory how this bot works
so these are the parameter i added ... and the bot is not following it the bot is following and commenting that all fine .. but it's skipping the private users and it is not following the provided parameters ..
once again pardon me if im being annoying
Alright lets restart. What is the command line that you are running?
currently follow command and follow by target user ..
is there's any solution for it?
as you can see so .. the bot started 1 min a go it skipped few private users and followed 8 users who meet the requirements in just 1 min .. and the delay was to wait 60 sec before each follow
None of these users in the screenshot were followed. All of them were skipped by filtering criteria.
Use bot = Bot(filter_private_users=False)
to follow private users.
bot = Bot(filter_private_users=False)
****thanks for your kind reply .. the bot actually went through 126 followers of targeted user and followed 28 people of total who meet the requirement and did all of it within max 5.-6 mins
whereas in settings i have edit the delay between each follow to 60 sec
can you kindly tell me where to add this code you provided****
`import getpass import os import random import sys import time
from tqdm import tqdm
sys.path.append(os.path.join(sys.path[0], "../")) from instabot import Bot # noqa: E402
def initial_checker(): files = [hashtag_file, users_file, whitelist, blacklist, comment, setting] try: for f in files: with open(f, "r") as f: pass except BaseException: for f in files: with open(f, "w") as f: pass print( """ Welcome to instabot, it seems this is your first time. Before starting, let's setup the basics. So the bot functions the way you want. """ ) setting_input() print( """ You can add hashtag database, competitor database, whitelists, blacklists and also add users in setting menu. Have fun with the bot! """ ) time.sleep(5) os.system("cls")
def read_input(f, msg, n=None): if n: msg += " (enter to use default number: {})".format(n) entered = str(stripped_input(msg)) if len(entered) == 0: entered = n f.write(f"{entered}\n")
def setting_input(): inputs = [ ("How many likes do you want to do in a day?", 300), ("How about unlike? ", 250), ("How many follows do you want to do in a day? ", 83), ("How about unfollow? ", 100), ("How many comments do you want to do in a day? ", 30), ( ( "Maximal likes in media you will like?\n" "We will skip media that have greater like than this value " ), 100, ), ( ( "Maximal followers of account you want to follow?\n" "We will skip media that have greater followers than " + "this value " ), 2000, ), ( ( "Minimum followers a account should have before we follow?\n" "We will skip media that have lesser followers than " + "this value " ), 10, ), ( ( "Maximum following of account you want to follow?\n" "We will skip media that have a greater following " + "than this value " ), 7500, ), ( ( "Minimum following of account you want to follow?\n" "We will skip media that have lesser following " + "from this value " ), 10, ), ("Maximal followers to following_ratio ", 1), ("Maximal following to followers_ratio ", 2), ( ( "Minimal media the account you will follow have.\n" "We will skip media that have lesser media from this value " ), 3, ), ("Delay from one like to another like you will perform ", 60), ("Delay from one unlike to another unlike you will perform ", 60), ("Delay from one follow to another follow you will perform ", 60), ("Delay from one unfollow to another unfollow you will perform ", 60), ("Delay from one comment to another comment you will perform ", 60), ( "Want to use proxy? insert your proxy or leave it blank "
"if no. (just enter", "None", ), ]
with open(setting, "w") as f: while True: for msg, n in inputs: read_input(f, msg, n) break print("Done with all settings!")
def parameter_setting(): settings = [ "Max likes per day: ", "Max unlikes per day: ", "Max follows per day: ", "Max unfollows per day: ", "Max comments per day: ", "Max likes to like: ", "Max followers to follow: ", "Min followers to follow: ", "Max following to follow: ", "Min following to follow: ", "Max followers to following_ratio: ", "Max following to followers_ratio: ", "Min media_count to follow:", "Like delay: ", "Unlike delay: ", "Follow delay: ", "Unfollow delay: ", "Comment delay: ", "Proxy: ", ]
with open(setting) as f:
data = f.readlines()
print("Current parameters\n")
for s, d in zip(settings, data):
print(s + d)
def username_adder(): with open(SECRET_FILE, "a") as f: print("We will add your instagram account.") print("Don't worry. It will be stored locally.") while True: f.write(stripped_input("Enter your login: ")) print( "Enter your password: (it will not be shown due to security " "reasons - just start typing and press Enter)" ) f.write(getpass.getpass() + "\n") if input("Do you want to add another account? (y/n)").lower() != "y": break
def get_adder(name, fname): def _adder(): print("Current Database:") print(bot.read_list_from_file(fname)) with open(fname, "a") as f: print(f"Add {name} to database") while True: f.write(input(f"Enter {name}: \n")) if input(f"Do you want to add another {name}? (y/n)\n").lower() != "y": print(f"Done adding {name}s to database") break
return _adder()
def hashtag_adder(): return get_adder("hashtag", fname=hashtag_file)
def competitor_adder(): return get_adder("username", fname=users_file)
def blacklist_adder(): return get_adder("username", fname=blacklist)
def whitelist_adder(): return get_adder("username", fname=whitelist)
def comment_adder(): return get_adder("comment", fname=comment)
def userlist_maker(): return get_adder("username", userlist)
def menu(): ans = True while ans: print( """ 1.Follow 2.Like 3.Comment 4.Unfollow 5.Block 6.Setting 7.Exit """ ) ans = input("What would you like to do?\n").strip() if ans == "1": menu_follow() elif ans == "2": menu_like() elif ans == "3": menu_comment() elif ans == "4": menu_unfollow() elif ans == "5": menu_block() elif ans == "6": menu_setting() elif ans == "7": bot.logout() sys.exit() else: print("\n Not A Valid Choice, Try again")
def menu_follow(): ans = True while ans: print( """
Main menu """ ) ans = input("How do you want to follow?\n").strip()
if ans == "1":
print(
"""
1.Insert hashtag
2.Use hashtag database
"""
)
hashtags = []
if stripped_input() == "1":
hashtags = (
input(
"Insert hashtags separated by spaces\n"
"Example: cat dog\nwhat hashtags?\n"
)
.strip()
.split(" ")
)
else:
hashtags = bot.read_list_from_file(hashtag_file)
for hashtag in hashtags:
print("Begin following: " + hashtag)
users = bot.get_hashtag_users(hashtag)
bot.follow_users(users)
menu_follow()
elif ans == "2":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
bot.follow_followers(user_id)
menu_follow()
elif ans == "3":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
bot.follow_following(user_id)
menu_follow()
elif ans == "4":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
medias = bot.get_user_medias(user_id, filtration=False)
if len(medias):
likers = bot.get_media_likers(medias[0])
for liker in tqdm(likers):
bot.follow(liker)
elif ans == "5":
menu()
else:
print("This number is not in the list?")
menu_follow()
def menu_like(): ans = True while ans: print( """
Main menu """ ) ans = input("How do you want to like?\n").strip()
if ans == "1":
print(
"""
1.Insert hashtag(s)
2.Use hashtag database
"""
)
hashtags = []
if stripped_input() == "1":
hashtags = (
input(
"Insert hashtags separated by spaces\n"
"Example: cat dog\nwhat hashtags?\n"
)
.strip()
.split(" ")
)
else:
hashtags.append(random.choice(bot.read_list_from_file(hashtag_file)))
for hashtag in hashtags:
bot.like_hashtag(hashtag)
elif ans == "2":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
bot.like_followers(user_id)
elif ans == "3":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
bot.like_following(user_id)
elif ans == "4":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
medias = bot.get_user_medias(user_id, filtration=False)
if len(medias):
likers = bot.get_media_likers(medias[0])
for liker in tqdm(likers):
bot.like_user(liker, amount=2, filtration=False)
elif ans == "5":
bot.like_timeline()
elif ans == "6":
menu()
else:
print("This number is not in the list?")
menu_like()
def menu_comment(): ans = True while ans: print( """
Main menu """ ) ans = input("How do you want to comment?\n").strip()
if ans == "1":
print(
"""
1.Insert hashtag
2.Use hashtag database
"""
)
if stripped_input() == "1":
hashtag = input("what?").strip()
else:
hashtag = random.choice(bot.read_list_from_file(hashtag_file))
bot.comment_hashtag(hashtag)
elif ans == "2":
print(
"""
1.Insert username
2.Use username database
"""
)
if stripped_input() == "1":
user_id = input("who?\n").strip()
else:
user_id = random.choice(bot.read_list_from_file(users_file))
bot.comment_medias(bot.get_user_medias(user_id, filtration=False))
elif ans == "3":
print(
"""
1.Make a list
2.Use existing list
"""
)
if stripped_input() == "1":
userlist_maker()
if stripped_input() == "2":
print(userlist)
users = bot.read_list_from_file(userlist)
for user_id in users:
bot.comment_medias(bot.get_user_medias(user_id, filtration=True))
elif ans == "4":
bot.comment_medias(bot.get_timeline_medias())
elif ans == "5":
menu()
else:
print("This number is not in the list?")
menu_comment()
def menu_unfollow(): ans = True while ans: print( """
Main menu """ ) ans = input("How do you want to unfollow?\n").strip()
if ans == "1":
bot.unfollow_non_followers()
menu_unfollow()
elif ans == "2":
bot.unfollow_everyone()
menu_unfollow()
elif ans == "3":
menu()
else:
print("This number is not in the list?")
menu_unfollow()
def menu_block(): ans = True while ans: print( """
Main menu """ ) ans = input("how do you want to block?\n").strip() if ans == "1": bot.block_bots() menu_block()
elif ans == "2":
menu()
else:
print("This number is not in the list?")
menu_block()
def menu_setting(): ans = True while ans: print( """
Main menu """ ) ans = input("What setting do you need?\n").strip()
if ans == "1":
parameter_setting()
change = input("Want to change it? y/n\n").strip()
if change == "y" or change == "Y":
setting_input()
else:
menu_setting()
elif ans == "2":
username_adder()
elif ans == "3":
competitor_adder()
elif ans == "4":
hashtag_adder()
elif ans == "5":
comment_adder()
elif ans == "6":
blacklist_adder()
elif ans == "7":
whitelist_adder()
elif ans == "8":
print(
"Whis will clear all database except your "
"user accounts and paramater settings"
)
time.sleep(5)
open(hashtag_file, "w")
open(users_file, "w")
open(whitelist, "w")
open(blacklist, "w")
open(comment, "w")
print("Done, you can add new one!")
elif ans == "9":
menu()
else:
print("This number is not in the list?")
menu_setting()
def stripped_input(param=None): if param: result = input(param) else: result = input() return result.strip()
hashtag_file = "hashtagsdb.txt" users_file = "usersdb.txt" whitelist = "whitelist.txt" blacklist = "blacklist.txt" userlist = "userlist.txt" comment = "comment.txt" setting = "setting.txt" SECRET_FILE = "secret.txt"
initial_checker()
if os.stat(setting).st_size == 0: print("Looks like setting are broken") print("Let's make new one") setting_input()
f = open(setting) lines = f.readlines() setting_0 = int(lines[0].strip()) setting_1 = int(lines[1].strip()) setting_2 = int(lines[2].strip()) setting_3 = int(lines[3].strip()) setting_4 = int(lines[4].strip()) setting_5 = int(lines[5].strip()) setting_6 = int(lines[6].strip()) setting_7 = int(lines[7].strip()) setting_8 = int(lines[8].strip()) setting_9 = int(lines[9].strip()) setting_10 = int(lines[10].strip()) setting_11 = int(lines[11].strip()) setting_12 = int(lines[12].strip()) setting_13 = int(lines[13].strip()) setting_14 = int(lines[14].strip()) setting_15 = int(lines[15].strip()) setting_16 = int(lines[16].strip()) setting_17 = int(lines[17].strip()) setting_18 = lines[18].strip()
bot = Bot( max_likes_per_day=setting_0, max_unlikes_per_day=setting_1, max_follows_per_day=setting_2, max_unfollows_per_day=setting_3, max_comments_per_day=setting_4, max_likes_to_like=setting_5, max_followers_to_follow=setting_6, min_followers_to_follow=setting_7, max_following_to_follow=setting_8, min_following_to_follow=setting_9, max_followers_to_following_ratio=setting_10, max_following_to_followers_ratio=setting_11, min_media_count_to_follow=setting_12, like_delay=setting_13, unlike_delay=setting_14, follow_delay=setting_15, unfollow_delay=setting_16, comment_delay=setting_17, whitelist_file=whitelist, blacklist_file=blacklist, comments_file=comment, stop_words=[ "order", "shop", "store", "free", "doodleartindonesia", "doodle art indonesia", "fullofdoodleart", "commission", "vector", "karikatur", "jasa", "open", ], )
bot.login()
while True: try: menu() except Exception as e: bot.logger.info("error, read exception bellow") bot.logger.info(str(e)) time.sleep(1) `
bot = Bot(filter_private_users=False)
so i tried to edit it and it saying
INFO - error, read exception bellow INFO - local variable 'bot' referenced before assignment
Pardon me... i am a newbie
hi, any expert kindly help me with this error?
You should read the example files and use them. The errors you're posting are not errors in the blue itself. Also please take a bit more time to read on code formatting on GitHub. I'm on my mobile and it's really hard to read your code. If you reformat it I might be understand what you're doing.
thanks for your kind reply
https://github.com/instagrambot/instabot/blob/master/examples/multi_script_CLI.py
here this the bot im trying to run the only problem im facing is it's skipping private users
i also tried adding the code
bot = Bot(filter_private_users=False)
but it's giving me error
INFO - error, read exception bellow INFO - local variable 'bot' referenced before assignment
can you kindly guide me where i can add the code?
thanks :)
Again this is part of your code. Which example file are you running ?
im running multi_script_CLI.py , the code was given to me by a github user he said try to add this code to get rid of skip private user error
here is the link of the file https://github.com/instagrambot/instabot/blob/master/examples/multi_script_CLI.py
hi, can any expert help me how i can disable the "skip private user option" in this example bot? "multi_script_CLI.py "
Please follow the guide below
x
into all the boxes [ ] relevant to your issue (like so [x]).Before submitting an issue, make sure you have:
Purpose of your issue?
The following sections requests more details for particular types of issues, you can remove any section (the contents between the triple ---) not applicable to your issue.
For a bug report, you must include the Python version used, code that will reproduce the error, and the error log/traceback.
Paste the output of
python -V
here:Code:
Error/Debug Log:
Describe your issue
hi, so im using multi_script which is present in examples folder ... the bot have few defects
the delay is not working .. i input 120 in delay between each follow and the bot follows 82 accounts in like 2-3 mins same happens in like function and in comment function
the bot is also skipping private account user
can anyone kindly tell me how fix it
thanks :)