Closed Abdulsamipy closed 4 years ago
import time
from instabot import Bot
uname = ""
pw = ""
bot = Bot()
bot.login(username = uname, password = pw)
def is_int(num):
try:
int(num)
return True
except Exception:
return False
while True:
sleepTime = ""
while not is_int(sleepTime):
sleepTime = input("How long to wait for?")
sleepTime = int(sleepTime)
# put the code you want to use from message_user.py here
Thanks for your Kind Respond .. can you kindly tell me where to input .. pardon me i'm a newbie
"""
import csv import os import sys import time
from tqdm import tqdm
sys.path.append(os.path.join(sys.path[0], "../")) from instabot import Bot # noqa: E402
instaUsers = ["R1B4Z01D", "KoanMedia"] directMessage = "Thanks for the example."
messagesToSend = 100 banDelay = 86400 / messagesToSend
print("Which type of delivery method? (Type number)") print("%d: %s" % (0, "Messages From CSV File.")) print("%d: %s" % (1, "Group Message All Users From List.")) print("%d: %s" % (2, "Message Each User From List.")) print("%d: %s" % (3, "Message Each Your Follower.")) print("%d: %s" % (4, "Message LatestMediaLikers Of A Page"))
deliveryMethod = int(input())
bot = Bot() bot.login()
if deliveryMethod == 0: with open("messages.csv", "rU") as f: reader = csv.reader(f) for row in reader: print("Messaging " + row[0]) bot.send_message(row[1], row[0]) print("Waiting " + str(banDelay) + " seconds...") time.sleep(banDelay) elif deliveryMethod == 1: bot.send_message(directMessage, instaUsers) print("Sent A Group Message To All Users..") time.sleep(3) exit() elif deliveryMethod == 2: bot.send_messages(directMessage, instaUsers) print("Sent An Individual Messages To All Users..") time.sleep(3) exit() elif deliveryMethod == 3: for follower in tqdm(bot.followers): bot.send_message(directMessage, follower) print("Sent An Individual Messages To Your Followers..") time.sleep(3) exit()
elif deliveryMethod == 4: scrape = input("what page likers do you want to message? :") with open("scrape.txt", "w") as file: file.write(scrape)
pages_to_scrape = bot.read_list_from_file("scrape.txt") f = open("medialikers.txt", "w") # stored likers in user_ids for users in pages_to_scrape: medias = bot.get_user_medias(users, filtration=False) getlikers = bot.get_media_likers(medias[0]) for likers in getlikers: f.write(likers + "\n") print("succesfully written latest medialikers of" + str(pages_to_scrape)) f.close()
print("Reading from medialikers.txt") wusers = bot.read_list_from_file("medialikers.txt") with open("usernames.txt", "w") as f: for user_id in wusers: username = bot.get_username_from_user_id(user_id) f.write(username + "\n") print("succesfully converted " + str(wusers))
with open("usernames.txt", encoding="utf-8") as file: instaUsers4 = [l.strip() for l in file] bot.send_messages(directMessage, instaUsers4) print("Sent An Individual Messages To All Users..")
Please look up marking's on github. posting code random in a comment makes it very, very difficult to read it (almost impossible) If you read the code @scretr posted and you read the comment you can tell very very easliy to know where to post your code.
I am going to close this since it is not an issue with this bot.
.## 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, First of all i want to say that I'm a complete newbie and got into python 2 weeks ago.. if i say something stupid kindly pardon me ..
so i am using message_User template and want to be able to choose delay between each message on my own so i was wondering if any expert here guide me on how i can add such option .... i want to be able to add custom delay in CMD ... lets say i want the bot wait 60 sec or 180 sec between each message .. i want the bot to ask me how much time i want it to go to sleep in between messages
i hope this explains what i want ..
thanks and kindly help me modify 👍