def comment(self): print( "\nQuesta funzione ti permette di commentare ogni post di un singolo user con una frase a tua scelta.\n" ) username, passw = login(self.user, self.passw) print("\n----------------------------") account = input("\nInserisci l'account a cui commentare: ") comment = input("\nInserisci la frase da commentare: ") bot = Bot(comment_delay=10, max_comments_per_day=10000) bot.login(username=username, password=passw) media = bot.get_total_user_medias(account) for n in range(len(media)): bot.comment(media[n], comment) print( f"\nFoto numero {n + 1} commentata. Se cosi' non fosse, la foto e' gia' stata commentata dallo stesso account." )
def comment(self): print( "\nQuesta funzione ti permette di commentare ogni post sotto ad un hashtag a tua scelta (ad esempio, inserendo l'hashtag #dog, si andra' a commentare ogni post contenente l'hashtag #dog). \n" ) username, passw = login(self.user, self.passw) print("\n----------------------------") hshtg = input("\nInserisci l'hashtag da prendere in considerazione: ") comment = input("\nInserisci la frase da commentare: ") bot = Bot(comment_delay=10, max_comments_per_day=10000) bot.login(username=username, password=passw) media = bot.get_total_hashtag_medias(hshtg) for n in range(len(media)): bot.comment(media[n], comment) print( f"\nFoto numero {n + 1} commentata. Se cosi' non fosse, la foto e' gia' stata commentata dallo stesso account." )
def like_and_comment_my_wife(username: str, password: str, user_id: str, comments: list, last_commented: list, comments_enabled=False) -> list: bot = Bot() bot.login(username=username, password=password) bot.like_user(user_id, filtration=False) if not comments_enabled: return last_commented medias = bot.get_last_user_medias(WIFE_ACCOUNT, LAST_POSTS_COUNT) not_commented = set(medias) - set(last_commented) for media_id in not_commented: if not bot.is_commented(media_id): comment = random.choice(comments) bot.comment(media_id, comment) last_commented.append(media_id) return last_commented[-LAST_POSTS_COUNT:]
if tag2 in text: print("tag=" + tag2 + "Contain tag:" + text) #sleep(randint(1,3)) results_to_comment.append(media) except Exception as e: print(str(e)) import datetime, time st = datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d-%H-%M-%S') fil = open('reports_mediaids_' + st + '.txt', 'w') import subprocess for mediaid_to_comment in results_to_comment: try: message_to_send = content[randint(0, len(content) - 1)] print("printing message: " + message_to_send + " to media_id: " + str(mediaid_to_comment)) sleep(randint(2, 5)) bot.comment(mediaid_to_comment, message_to_send) print("Calculating link: ") link = subprocess.check_output( ['php', 'id_parser.php', str(mediaid_to_comment)]) print("link with media:" + str(link)) fil.write(str(mediaid_to_comment) + "," + str(link)) except Exception as e: print(str(e)) fil.close()
import random bot = Bot() bot.login(username=os.environ['INSTAGRAM_USERNAME'], password=os.environ['INSTAGRAM_PASSWORD']) path_to_photo = sys.argv[1] text = "" if len(sys.argv) > 2: text = sys.argv[2] if text == "": text = random.choice([ "mew mew mew", "MEW!", "mew", "meow", "nyanyanyanyanaynaynya", ":^_^:", "I liked your mew", "very mew" "OWWWWWWW", "murmurmur murmur mur m u r", ]) bot.upload_photo(path_to_photo, text) last_media_id = bot.get_your_medias()[0] text = "#cat #cats #meow #bestmeow #vsco #awesome #nice #aaw #ny #nya #lovecat #kitty #kittens #kitten #instakitty #hellokitty #cute #cutecats #cutecat #pretty #kitties #kittycat #lovecats #blackcat #mycat" bot.comment(last_media_id, text) bot.logout()
This files contains comments to comment. Workflow: 1) Get your timeline medias 2) Comment them with random comments from file. Notes: You can change file and add there your comments. """ import time import sys import os from tqdm import tqdm sys.path.append(os.path.join(sys.path[0],'../')) from instabot import Bot comments_file_name = "comments_emojie.txt" if not os.path.exists(comments_file_name): print ("Can't find '%s' file." % comments_file_name) exit() bot = Bot() bot.login() for media in tqdm(bot.get_timeline_medias()): comment_text = bot.get_comment(comment_base_file=comments_file_name) bot.comment(media, comment_text) time.sleep(10) bot.logout()
from instabot import Bot from instabot.bot import delay bot = Bot(comment_delay=10) bot.login() def delete_comment(self, media_id, comment_id): if super(self.__class__, self).deleteComment(media_id, comment_id): delay.small_delay(self) return True self.logger.info("Comment with %s in media %s is not deleted." % (comment_id, media_id)) return False needed_text = '#лофт #хобби #мастерская #стильлофт #своимируками' my_medias = bot.get_your_medias() for media_id in my_medias: comment_list = bot.get_media_comments(media_id) for comment_item in comment_list: if comment_item["text"].encode('utf-8') == needed_text: print(comment_item["text"].encode('utf-8')) print(comment_item["pk"]) comment_id = comment_item["pk"] delete_comment(bot, media_id, comment_id) for media_id in my_medias: bot.comment(media_id, needed_text)