Exemplo n.º 1
0
class Instagram(SocialMedia):
    def __init__(self, senero):
        self.senero = senero
        self.api = InstagramAPI(senero['instagram']['username'],
                                senero['instagram']['password'])
        self.api.login()

        super(Instagram, self).__init__(senero)

    def get_relevant(self):
        all_relevant_items = []
        for tag in ['senero', 'monero']:
            feed_resp = self.api.get_hashtag_feed(tag)
            items = feed_resp.json()["items"]
            items = Instagram.filter_items(items)
            all_relevant_items.extend(items)
        Instagram.sort_items_by_likecount(all_relevant_items)
        return all_relevant_items

    def update_status(self, txt, post=None):
        if post is not None:
            self.api.comment(post['caption']['media_id'], txt)

    def logout(self):
        self.api.logout()

    @staticmethod
    def filter_items(items):
        items = list(filter(lambda item: not item["has_liked"], items))
        return items

    @staticmethod
    def sort_items_by_likecount(items):
        items.sort(key=lambda item: item["like_count"], reverse=True)
Exemplo n.º 2
0
class Bot:
    def __init__(self, username, password):
        self.account = InstagramAPI(username, password)
        self.account.login()
        #account.getUsernameInfo(username)
        req = requests.get('https://api.instagram.com/oembed/?url={}'.format(
            'https://www.instagram.com/p/B2riIVNhwar/'))

    def comment(self, message, post_url, amount):
        req = requests.get(
            'https://api.instagram.com/oembed/?url={}'.format(post_url))
        media_id = req.json()['media_id']
        for i in range(amount):
            try:
                print("Trying...")
                self.account.comment(media_id, message)
                time.sleep(120)
            except:
                print("Failed...")
                pass

    def delete_post(self, post_url):
        media_id = self.req.json()['media_id']
        self.account.deleteMedia(media_id)

    def upload_post(self, path, caption):
        os.chdir(path)
        for pic in os.listdir('.'):
            self.account.uploadPhoto(pic, caption=caption)
            time.sleep(10)

    def follow(self, username):
        url = 'https://www.instagram.com/' + username + '/?__a=1'
        req = requests.get(url)
        follow_list = ['1399376725', '236279329']

        #print(req.json()['logging_page_id'])
        id = req.json()
        print(id['graphql']['user']['id'])
        self.account.follow(id['graphql']['user']['id'])

    def post_from_website(self, website_url, dir, amount, caption, sleep):

        scraper = Pic_Scraper.Pic_Scraper()
        scraper.scrape(website_url, dir)
        scraper.resize(dir)
        post_count = 0
        for meme in os.listdir('.'):
            if post_count < amount:
                image = meme
                text = caption
                try:
                    InstagramAPI.uploadPhoto(image, caption=text)
                    time.sleep(sleep)
                    post_count += 1
                except:
                    pass
            else:
                break
Exemplo n.º 3
0
def postComment():
    comment = request.args.get('comment')
    url = request.args.get('url')

    mediaId = get_media_id(url)

    InstagramAPI.comment(mediaId=mediaId, commentText=comment)

    return "ok with: " + comment + " -- " + mediaId
Exemplo n.º 4
0
def like_looper(user):
    InstagramAPI.getTotalUserFeed(get_userid(user))
    media_id = InstagramAPI.LastJson['items'][0]['id']
    while True:
        InstagramAPI.like(media_id)
        InstagramAPI.comment(media_id, 'Wow!')
        print('yes')
        InstagramAPI.getTotalUserFeed(get_userid(user))
        comment_id = InstagramAPI.LastJson['items'][0]['comments'][-1]['pk']
        time.sleep(8)
        InstagramAPI.unlike(media_id)
        InstagramAPI.deleteComment(media_id, comment_id)
        print('oh')
        time.sleep(8)
class JobExecutor:
    def __init__(self):
        self.api = InstagramAPI("username", "password")
        self.comment_text = "#HBDSwiggy"
        self.api.login()

    def comment(self, post_id):
        print("Commenting...")
        self.api.comment(post_id, self.comment_text)
        return self.api.LastJson

    def process_jobs(self, post_ids):
        for post_id in post_ids:
            self.comment(post_id)
        return True
Exemplo n.º 6
0
                api = InstagramAPI(username, password)

                print("Trying to login {0}".format(
                    accounts['accounts'][i]['username']))

                if (api.login()):
                    cls()
                    print("Logged in {}".format(username))
                    while (True):

                        post_media_id = post_data[j]
                        comment = accounts['accounts'][i]['comment']

                        #komment yazsin stime saniye arayla

                        resp = api.comment(post_media_id, comment)

                        if (resp):
                            counter += 1
                            print("{0}. Commented\n".format(counter))
                            print("Username: {0}\n".format(
                                accounts['accounts'][i]['comment']))
                            print("Post: {0}\n".format(
                                posts["posts"][j]['link']))
                            print("Comment: {0}".format(comment))
                            print(
                                "---------------------------------------------------"
                            )
                            sleep(stime)
                        else:
                            print("Account blocked")
Exemplo n.º 7
0
def commentsByHashtag(ListHashtag, fechatest, user, pwd):
    #login en el Api de instagram
    API = InstagramAPI(user, pwd)
    #print('login:'******''
            oportunity = 0
            oppkIgual = 20
            #coneccion a API para obtener post de los hashtags
            g = API.getHashtagFeed(hashtag, next_max_id)
            #temp obtiene la respuesta
            temp = API.LastJson
            # usamos un while para recorrer todas las paginas hasta llegar a la fecha tpe
            contadorLikes = 0
            while 1:
                try:
                    oportunity = 0
                    # g nos indica si hubo un error en el API al hacer la consulta
                    while g == False:
                        #esperamos un tiempo entre 150 y 270 segundos para volver a consultar
                        n = random.randint(50, 90)
                        time.sleep(3 * n)
                        g = API.getHashtagFeed(hashtag, next_max_id)
                        temp = API.LastJson
                    #recorremos nyestro json respuesta
                    salir = 0
                    for item in temp["items"]:
                        #obtenemos el id del post y se lo mandamos a la funcion like() y comment del Api
                        # ademas escogemos al azar uno de nuestros comentarios
                        lc = random.choice(listaComments)
                        rp = API.like(item['id'])
                        rp = API.comment(item['id'], lc)
                        if (rp):
                            contadorLikes = contadorLikes + 1
                        print('likes para hashtag:', hashtag, contadorLikes,
                              item['code'])
                        #esperamos 50 segundos para no excder el limite de likes de instagram de 100 por hora
                        time.sleep(30)
                        #obtenemos la fecha y la comparamos con la fecha de corte
                        ts = int(item['taken_at'])
                        fecha = datetime.utcfromtimestamp(ts).strftime(
                            '%Y-%m-%d %H:%M:%S')
                        dtfechaD = datetime.strptime(
                            fecha.split(' ')[0], "%Y-%m-%d")
                        fechaFinal = dtfechaD.strftime("%Y-%m-%d")
                        if (fechaFinal < fechatest):
                            #Muchas veces vienen post con otras fechas , asi que dejamos pasar 16 post hasta estar seguros que la fecha fue sobrepasada
                            if (oportunity < 16):
                                oportunity = oportunity + 1
                            else:
                                salir = 1
                        if (salir == 1):
                            break
                    try:
                        #repetimos el proceso de arriba pero para los hashtags populares que nos devuelve el api
                        for item in temp["ranked_items"]:
                            lc = random.choice(listaComments)
                            rp = API.like(item['id'])
                            rp = API.comment(item['id'], lc)
                            if (rp):
                                contadorLikes = contadorLikes + 1
                            print('commnets para hashtag:', hashtag,
                                  contadorLikes, item['code'])
                            time.sleep(30)
                            ts = int(item['taken_at'])
                            fecha = datetime.utcfromtimestamp(ts).strftime(
                                '%Y-%m-%d %H:%M:%S')
                            dtfechaD = datetime.strptime(
                                fecha.split(' ')[0], "%Y-%m-%d")
                            fechaFinal = dtfechaD.strftime("%Y-%m-%d")
                            if (fechaFinal < fechatest):
                                if (oportunity < 16):
                                    oportunity = oportunity + 1
                                else:
                                    salir = 1
                            if (salir == 1):
                                break
                    except Exception as e:
                        pass
                    #comprbamos si tenemos mas paginas por visitar
                    if temp["more_available"] == False:
                        next_max_id = False
                        break
                    #comenzamos el proceso de nuevo
                    next_max_id = temp["next_max_id"]
                    g = API.getHashtagFeed(hashtag, next_max_id)
                    temp = API.LastJson
                except Exception as e:
                    print(e)
        except Exception as e:
            print(e)
Exemplo n.º 8
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 15 09:42:33 2018

@author: michael
"""


from InstagramAPI import InstagramAPI
from PIL import Image
from PIL import ImageFont
from PIL import ImageDraw 
import requests

#InstagramAPI = InstagramAPI("know_your_foodprint", "ThisIsFoodprint")
#InstagramAPI.login()  # login

def get_media_id(url):
    req = requests.get('https://api.instagram.com/oembed/?url={}'.format(url))
    media_id = req.json()['media_id']
    return media_id

InstagramAPI = InstagramAPI("know_your_foodprint", "ThisIsFoodprint")
InstagramAPI.login()

InstagramAPI.comment(mediaId="1868849409401728190_8586045462", commentText="test")

Exemplo n.º 9
0
class CommentControl:

    POST_LIMIT = 10

    COMMENTS = [emoji.emojize("Nice pic! :thumbs_up:"),
               emoji.emojize(":thumbs_up: :thumbs_up: :thumbs_up:"),
               emoji.emojize(":fire: :fire: :fire:"),
               emoji.emojize("😍 😍 😍"),
               emoji.emojize("Nice one! :thumbs_up:"),
               emoji.emojize("Loving it! 💜"),
               emoji.emojize("Wow that looks awesome! :thumbs_up:"),
               emoji.emojize("Love ur profile! Keep it up! 🙏")]

    comments = []
    USERNAME = ""
    PASSWORD = ""

    def __init__(self, username, password, comments_file_path=''):
        self.api = InstagramAPI(username or self.USERNAME, password or self.PASSWORD)
        self.api.login()
        if comments_file_path:
            self.load_comments(comments_file_path)

    def delete_all_comments(self):
        while len(self.comments):
            comment = self.comments.pop()
            if not self.delete_comment(comment["mediaId"], comment["commentId"]):
                return False

    def delete_comment(self, mediaid, commentId):
        return self.api.deleteComment(mediaid, commentId)

    def register_commentId(self, api, mediaId, commentId):
        self.comments.append({"mediaId" : mediaId, "commentId" : commentId})

    def leave_comment(self, mediaId, comment_text=''):
        comment_text = comment_text or self.choose_text()
        self.api.comment(mediaId, comment_text)
        comment_id = self.api.LastJson["comment"]["pk"]
        self.register_commentId(self.api, mediaId, comment_id)

    def choose_text(self):
        return random.choice(self.COMMENTS)

    def tag_lookup(self, tag):
        self.api.tagFeed(tag)
        return self.api.LastJson["items"][:self.POST_LIMIT]

    def leave_comments_by_tag(self, tag):
        posts = self.tag_lookup(tag)

        for post in posts:
            self.leave_comment(post["id"])
            time.sleep(20)  # 20sec

    def save_comments(self, path=''):
        with open(('comments_{}.json'.format(int(time.time()))), 'w') as out:
             json.dump(self.comments, out)

    def load_comments(self, file_path):
        with open(file_path, 'r') as file:
            self.comments = json.load(file)
Exemplo n.º 10
0
api = InstagramAPI(login, password)
api.login()

api.follow(test_user_id)
api.unfollow(test_user_id)

api.like(test_user_post_id)
api.unlike(test_user_post_id)

print '## Followers ##'
api.getUserFollowers(test_user_id)
pprint(api.LastJson)

print '## Following ##'
api.getUserFollowings(test_user_id)
pprint(api.LastJson)

api.comment(test_user_post_id, 'test comment')

print '## Media likers ##'
api.getMediaLikers(test_user_post_id)
pprint(api.LastJson)

print '## Geo media ##'
api.getGeoMedia(test_user_id)
pprint(api.LastJson)

api.uploadPhoto('test_photo.jpg', caption='test load photo')

Exemplo n.º 11
0
InstagramAPI.login()

key = input(
    "[+]1)Comment spam | 2)FollowUnfollow | 3)LikeUnlike: 4)Direct Spam: ")

#COMMENT-SPAM PART
if key == 1:
    MEDIAID()
    print ""
    text = raw_input("[+]text: ")
    mediaID = raw_input("[+]media id: ")
    continue1 = raw_input("[+]Do you wanna continue?[Y/N]: ")
    if continue1 == "Y":
        while True:
            for x in range(3):
                InstagramAPI.comment(mediaID, text)
            time.sleep(50)
        print "ok"
    else:
        exit()

#FOLLOWUNFOLLOW PART
elif key == 2:
    USERID()
    print ""
    userID = raw_input("[+]userID: ")
    while True:
        InstagramAPI.follow(userID)
        time.sleep(3)
        InstagramAPI.unfollow(userID)
        time.sleep(1)
Exemplo n.º 12
0
class CommentControl:
    TABLE_ID_COMMENTS = 1
    TABLE_ID_RESPONSES = 2
    POST_LIMIT = 10
    MIN_TIME_DELAY = 10  # seconds
    MAX_TIME_DELAY = 20  # seconds
    USERNAME = ""
    PASSWORD = ""
    DB_PATH = "comments.sqlite3"

    comments = []
    responses = []
    api = {}

    def __init__(self, ):
        # Populate comments list
        self.__read_from_db(self.TABLE_ID_COMMENTS)
        self.__read_from_db(self.TABLE_ID_RESPONSES)

    def login(self, username, password):
        # Login to Instagram
        self.api = InstagramAPI(username or self.USERNAME, password
                                or self.PASSWORD)
        return self.api.login()

    def logout(self):
        self.api.logout()

    '''
    Adds new response to the pool
    '''

    def add_response(self, text):
        response = Response(text)
        self.__write_to_db(response)

        # Look up and update id
        self.__update_id(response)

        self.responses.append(response)

    '''
    Removes the response from the pool
    '''

    def remove_response(self, obj):
        if isinstance(obj, Response):
            self.__delete_from_db(obj)
            for i in range(len(self.responses)):
                if self.responses[i].get_id() == obj.get_id():
                    self.responses.pop(i)
        elif isinstance(obj, str) or isinstance(obj, int):
            self.remove_response(
                self.__find_obj_by_id(obj, self.TABLE_ID_RESPONSES))
        else:
            return False

    '''
    Deletes comment from Instagram
    '''

    def delete_comment(self, obj):
        if isinstance(obj, Comment) and self.api.deleteComment(
                obj.get_media_id(), obj.get_id()):
            self.__delete_from_db(obj)
            return True
        elif isinstance(obj, str) or isinstance(obj, int):
            self.delete_comment(
                self.__find_obj_by_id(obj, self.TABLE_ID_COMMENTS))
        else:
            return False

    '''
    Deletes all comments in query from Instagram
    '''

    def delete_all_comments(self):
        print("Preparing to delete all comments...")
        while len(self.comments):
            comment = self.comments.pop()
            if not self.delete_comment(comment):
                return False
        print("Success!")

    '''
    Adds new comment to certain media_id post
    '''

    def add_comment(self, media_id, post_code, comment_text=''):
        comment_text = comment_text or self.__choose_random_response()
        self.api.comment(media_id, emoji.emojize(comment_text))
        comment_id = self.api.LastJson["comment"]["pk"]
        self.__register_comment(media_id, comment_id, post_code, comment_text)

    '''
    Adds comments to posts found by certain hashtag
    '''

    def add_comments_by_tag(self, tag):
        posts = self.tag_lookup(tag)

        while True:
            post = posts.pop()
            self.add_comment(media_id=post["pk"], post_code=post["code"])
            if len(posts):
                delay = random.randint(self.MIN_TIME_DELAY,
                                       self.MAX_TIME_DELAY)
                print('Sleeping for {} seconds'.format(delay))
                time.sleep(delay)
            else:
                break

    '''
    Prints all comments with ids and posts urls to console
    '''

    def print_comments(self):
        print('--------------------------\nID\t\t\t\tPost Url\t\t\t\tText\n')
        for comment in self.comments:
            print('{0}\t\t{1}\t\t{2}'.format(comment.get_id(),
                                             comment.get_post_url(),
                                             comment.get_text()))
        print('--------------------------')

    '''
    Prints all responses to console
    '''

    def print_responses(self):
        print('--------------------------\nID\t\tText\n')
        for response in self.responses:
            print('{0}\t\t{1}\t\t'.format(response.get_id(),
                                          response.get_text()))
        print('--------------------------')

    '''
    Returns an array of posts on Instagram by specified hashtag
    '''

    def tag_lookup(self, tag):
        self.api.tagFeed(tag)
        return self.api.LastJson["items"][:self.POST_LIMIT]

    '''
    Chooses random response from the pool
    '''

    def __choose_random_response(self):
        return random.choice(self.responses).get_text()

    '''
    Registers newly added comment
    '''

    def __register_comment(self,
                           media_id,
                           comment_id,
                           post_code,
                           comment_text=''):
        comment = Comment(media_id, comment_id, comment_text, post_code)
        self.comments.append(comment)
        if self.__write_to_db(comment):
            print("Succesfully added comment (id: {0} , url: {2} )\r\n\t{1}".
                  format(comment.get_id(), comment.get_text(),
                         comment.get_post_url()))
        else:
            print(
                "Failed to add comment (id: {0} , url: {2} )\r\n\t{1}".format(
                    comment.get_id(), comment.get_text(),
                    comment.get_post_url()))

    '''
    Deletes specific obj from db
    '''

    def __delete_from_db(self, obj):

        # Connect to db
        db = sqlite3.connect(self.DB_PATH)
        print("Connected to db to write!")

        if isinstance(obj, Comment):
            comment = obj

            # Prepare SQL statement
            statement = 'DELETE FROM Comments WHERE id={}'.format(
                comment.get_id())

        elif isinstance(obj, Response):
            response = obj

            # Prepare SQL statement
            statement = 'DELETE FROM Responses WHERE id={}'.format(
                response.get_id())

        else:
            db.close()
            return False

        # Execute SQL statement
        db.execute(statement)
        db.commit()

        print('Success!')

        db.close()
        return True

    '''
    Determines the id(s) of the obj from db and return the corresponding array
    '''

    def __find_id_in_db(self, obj):
        # Connect to db
        db = sqlite3.connect(self.DB_PATH)
        print("Connected to db to read!")

        statement = ''

        # Prepare SQL statement
        if isinstance(obj, Comment):
            statement = 'SELECT id, media_id FROM Comments WHERE text=\"' + obj.get_text(
            ) + '\"'
        elif isinstance(obj, Response):
            statement = 'SELECT id FROM Responses WHERE text=\"' + obj.get_text(
            ) + '\"'

        # Execute SQL statement
        array = db.execute(statement)

        print('Success!')

        db.close()

        return array

    '''
    Updates the ids of obj
    '''

    def __update_id(self, obj):
        array = self.__find_id_in_db(obj)

        # Fill up
        if isinstance(obj, Comment):
            obj.set_media_id(array[1])
            obj.set_id(array[0])
        elif isinstance(obj, Response):
            obj.set_id(array[0])

    '''
        Returns the obj found by id
    '''

    def __find_obj_by_id(self, obj_id, table_id):
        # Connect to db
        db = sqlite3.connect(self.DB_PATH)
        cur = db.cursor()
        print("Connected to db to read!")

        statement = ''

        # Prepare SQL statement
        if table_id == self.TABLE_ID_COMMENTS:
            statement = 'SELECT id, media_id, text, post_url FROM Comments WHERE id={}'.format(
                obj_id)
        elif table_id == self.TABLE_ID_RESPONSES:
            statement = 'SELECT text, id FROM Responses WHERE id={}'.format(
                obj_id)

        # Execute SQL statement
        cur.execute(statement)
        result = cur.fetchone()

        # Fill up
        if table_id == self.TABLE_ID_COMMENTS:
            return Comment(result[1], result[0], result[2], result[3])
        elif table_id == self.TABLE_ID_RESPONSES:
            return Response(result[0], result[1])

    '''
    Reads comments from db
    '''

    def __read_from_db(self, table_id):
        # Connect to db
        db = sqlite3.connect(self.DB_PATH)
        cur = db.cursor()
        print("Connected to db to read!")

        statement = ''

        # Prepare SQL statement
        if table_id == self.TABLE_ID_COMMENTS:
            statement = 'SELECT media_id, id, text, post_url FROM Comments'
        elif table_id == self.TABLE_ID_RESPONSES:
            statement = 'SELECT text, id FROM Responses'

        # Execute SQL statement
        cur.execute(statement)
        result = cur.fetchall()

        # Fill up
        if table_id == self.TABLE_ID_COMMENTS:
            for comment in result:
                self.comments.append(
                    Comment(comment[0], comment[1], comment[2], comment[3]))
        elif table_id == self.TABLE_ID_RESPONSES:
            for response in result:
                self.responses.append(Response(response[0], response[1]))

        print('Success!')

        db.commit()
        db.close()

    '''
    Writes specified object to db
    '''

    def __write_to_db(self, obj):
        if isinstance(obj, Comment):
            comment = obj

            # Connect to db
            db = sqlite3.connect(self.DB_PATH)
            cur = db.cursor()
            print("Connected to db to write!")

            # Prepare SQL statement
            statement = 'INSERT INTO Comments (id, media_id, text, post_url) VALUES (\"{0}\", \"{1}\", \"{2}\", \"{3}\")'.format(
                comment.get_id(), comment.get_media_id(), comment.get_text(),
                comment.get_post_url())

            # Execute SQL statement
            cur.execute(statement)
            db.commit()

            print('Success!')

            db.close()
            return True
        elif isinstance(obj, Response):
            response = obj

            # Connect to db
            db = sqlite3.connect(self.DB_PATH)
            cur = db.cursor()
            print("Connected to db to write!")

            # Prepare SQL statement
            statement = 'INSERT INTO Responses (text) VALUES (\"{0}\")'.format(
                response.get_text())

            # Execute SQL statement
            cur.execute(statement)
            db.commit()

            print('Success!')

            db.close()
            return True
        else:
            return False
Exemplo n.º 13
0
class Tryagaın:
    def __init__(self, username='', password='', time=60):
        self.usernamex = username
        self.passwordx = password
        self.onlythem = [
            "3250759456", "2208388885", "6241679691", "5460601317",
            "3151687331", "6042552619", "1991903177", "7780971935",
            "6098326189", "2298597515", "5652484133", "2302559194",
            "1819469370", "4712779073", "4876075992", "7300451762",
            "1609544161", "5923190686"
        ]
        self.bigaccs = [
            '2959196915', '2111407363', '237681409', '384728850', '251091171',
            '209500791', '2017572216', '554961375', '317932194', '270350200',
            '26352342', '173560420', '2041553882', '460711162', '204318825',
            '253160049', '1364414581'
        ]
        self.api = InstagramAPI(username, password)
        self.whotofollowlist = []
        self.shitbool = False
        self.templist = []
        self.testone = []
        self.username = []
        self.private = []
        self.followbool = False
        self.unfollowbool = False
        self.likebool = False
        self.coommentbool = False
        self.followcount = 0
        self.likecount = 0
        self.commentcount = 0
        self.commentbx = 4
        self.followercount = 0
        self.saythetime = time

    def runtheprogram(self):
        user = ''
        user = self.usernamex
        logtxt = '---------PROGRAM STARTED İN THAT TİME:{}------------'.format(
            str(datetime.datetime.now().strftime("%H:%M:%S")))
        self.api.login()
        while self.templist.__len__() < 6:
            self.shitbool = False
            temp = random.choice(self.bigaccs)
            for i in range(self.templist.__len__()):
                if temp == self.templist[i]:
                    self.shitbool = True
            if self.shitbool is False:
                self.templist.append(temp)
        for i in range(self.templist.__len__()):
            tempfollowers = (self.whotofollow(self.templist[i]))
            for z in range(tempfollowers.__len__()):
                self.username.append(tempfollowers[z]['username'])
                self.whotofollowlist.append(tempfollowers[z]['pk'])
                self.private.append(tempfollowers[z]['is_private'])

        self.writelog(logtxt, user)
        print('{} account will be followed'.format(
            self.whotofollowlist.__len__()))
        #
        x = threading.Thread(target=self.follow, args=())  # Following
        y = threading.Thread(target=self.unfollow, args=())  # Unfollowing
        z = threading.Thread(target=self.likeandcommenthastags,
                             args=())  # Givinglikeandcommentstohastags
        c = threading.Thread(target=self.BlockControl,
                             args=())  # Blockcontrolalghrıthm
        print("Here we Go")
        x.start()
        y.start()
        z.start()
        c.start()

        # x.join()
        y.join()
        z.join()
        #
        # BlockControl()
        # print(xbool)
        #

        # api.getProfileData()
        # print(api.LastJson)

        print("We Re finished")

    def whotofollow(self, pk):
        followers = []
        next_max_id = ''
        while True:
            try:
                self.api.getUserFollowers(pk, next_max_id)
                temp = self.api.LastJson
                for item in temp["users"]:
                    followers.append(item)
                time.sleep(2)
                if not temp['big_list']:
                    break
                next_max_id = temp["next_max_id"]
                if followers.__len__() > 150:
                    break
            except:
                pass
        return followers

    def follow(self):
        print("Start FOLLOWİNG!!!!")
        while 1:
            try:
                x = 60
                if self.whotofollowlist.__len__() < x:
                    x = self.whotofollowlist.__len__()
                for i in range(x):
                    if self.followbool == True:
                        break
                    else:
                        self.api.follow(self.whotofollowlist[i])
                        self.followcount = 1 + self.followcount
                        print(
                            "FOLLOWED: " + self.username[i] + ' ---' +
                            str(datetime.datetime.now().strftime("%H:%M:%S")) +
                            " ---İs Private ?::: {}".format(self.private[i]))
                    time.sleep(self.saythetime * 2)
            except:
                pass

    def unfollow(self):
        print("Start UNFOLLOWİNG!!!!")

        while 1:
            try:

                followers = []
                tmpfollowers = self.api.getTotalSelfFollowers()
                for i in range(tmpfollowers.__len__()):
                    followers.append(tmpfollowers[i]['pk'])
                # benim takip ettiklerim
                tempfollowing = self.api.getTotalSelfFollowings()
                following = []
                for i in range(tempfollowing.__len__()):
                    following.append(tempfollowing[i]['pk'])
                for i in range(following.__len__()):
                    if self.unfollowbool == True:
                        break
                    else:
                        if (following[i] in followers) is False:
                            if (following[i] in self.whotofollowlist) is False:
                                if (str(following[i])
                                        in self.onlythem) is False:
                                    self.api.unfollow(following[i])
                                    print("unfollow ")
                                    time.sleep(self.saythetime)

            except:
                pass

    def likeandcommenthastags(self):
        self.timesleepcounter()
        if self.followercount < 500:
            self.commentbx = 12
        commentcounter = 0
        randomlist = [
            "🤣", "😍", "😋", "😇", "😜", "🙏", "🤟", "💗", "◼", "🇹🇷", "♥", "🌃", "🌉",
            "🧡", "💛", "💚", "💙", "💜", "🖤", "❣", "💕", "💞", "💓", "💗", "💖", "😀",
            "😬", "😁", "😂", "😃", "😄", "🤣", "😅", "😆", "🤪"
        ]
        Hastag = [
            "selfie", "follow", "istanbul", "aşk", "bff", "happy", "güzel",
            "gezi", "mode", "moda", "moda", "yemek", "yemek", "komik", "komik",
            "hayat", "hayat", "tbt", "life", "smile", "cool", "amazing"
        ]

        randomsecondlist = [
            "mükemmel olmuş", "süpermiş", "LOL", "Çok Güzel",
            "Cidden Mükemmelmiş", "Çok Beğendim",
            "Bir Tek Ben Beğenmiş Olamam", "Bu da Ne Böyle",
            "Kaçırdıgım Bir şey mi var?", "Harikaaaaaa", "Aşk", "harika ötesi",
            "Mükemmel demek az kalır", "İnanması güç",
            "Lütfen Takip Edib Süprizlerim Var"
        ]
        while 1:
            try:
                self.api.getHashtagFeed(random.choice(Hastag), "")
                tagFeedJson = self.api.LastJson["items"]
                print("{} posts will be liked".format(len(tagFeedJson)))
                for i in range(10):
                    if self.likebool == True:
                        break
                    listofcomments = []

                    mediathings = tagFeedJson[i]['pk']
                    self.api.like(mediathings)
                    self.likecount = 1 + self.likecount
                    print("Liked ")
                    commentcounter = commentcounter + 1
                    if commentcounter % self.commentbx == 0 and self.coommentbool == False:

                        self.api.getMediaComments(str(mediathings))
                        try:
                            for z in range(10):
                                listofcomments.append(
                                    self.api.LastJson['comments'][z]['text'])
                        except:
                            print()

                        def takecomment(trynumber):
                            trynumber = trynumber + 1
                            if listofcomments.__len__() > 0:
                                comment = random.choice(listofcomments)
                                if (
                                        '@' in comment
                                ) is False and listofcomments.__len__() > 0:
                                    return comment
                                else:
                                    if trynumber < 10:
                                        takecomment(trynumber)
                            else:
                                return "{}{}{}".format(
                                    random.choice(randomlist),
                                    random.choice(randomsecondlist),
                                    random.choice(randomlist))

                        self.api.comment(mediathings, takecomment(0))
                        self.commentcount = 1 + self.commentcount
                        print("Commented")
                    time.sleep(self.saythetime)
            except:
                self.likeandcommenthastags()

    def BlockControl(self):
        user = self.usernamex
        while 1:
            tt = self.api.LastResponse
            qq = self.api.qq
            if ("400" in str(tt)) is True:
                if ("comment" in str(qq)) and ("block" in str(qq)) and (
                        self.coommentbool is False):
                    self.coommentbool = True
                    arg = "comment"
                    q = threading.Thread(target=self.MakeitFalse, args=(arg, ))
                    forlog = 'Comment is Blocked We Comment {} Times and the clock is {} '.format(
                        str(self.commentcount),
                        str(datetime.datetime.now().strftime("%H:%M:%S")))
                    if q.isAlive():
                        continue
                    else:
                        self.writelog(forlog, user)
                        q.start()
                if ("like" in str(qq)) and ("block" in str(qq)) and (
                        self.likebool is False):
                    arg = "like"
                    ü = threading.Thread(target=self.MakeitFalse, args=(arg, ))
                    forlog = 'Like is Blocked We Liked {} Times and the clock is {} '.format(
                        str(self.likecount),
                        str(datetime.datetime.now().strftime("%H:%M:%S")))
                    self.likebool = True
                    if ü.isAlive():
                        pass
                    else:
                        self.writelog(forlog, user)

                        ü.start()
                if ("follow" in str(qq)) and ("block" in str(qq)) and (
                        self.followbool is False):
                    arg = "follow"
                    ğ = threading.Thread(target=self.MakeitFalse, args=(arg, ))
                    forlog = 'Follow is Blocked We Followed {} Times and the clock is {} '.format(
                        str(self.followcount),
                        str(datetime.datetime.now().strftime("%H:%M:%S")))
                    self.followbool = True
                    if ğ.isAlive():
                        pass
                    else:
                        self.writelog(forlog, user)
                        ğ.start()
                if ("unfollow" in str(qq)) and ("block" in str(qq)) and (
                        self.unfollowbool is False):
                    arg = "unfollow"
                    ş = threading.Thread(target=self.MakeitFalse, args=(arg, ))
                    self.unfollowbool = True

                    if ş.isAlive():
                        pass
                    else:
                        ş.start()

    def MakeitFalse(self, boolname=''):
        time.sleep(3600)
        if boolname == "comment":
            self.coommentbool = False
        if boolname == "like":
            self.likebool = False
        if boolname == "follow":
            self.followbool = False
        if boolname == "unfollow":
            self.unfollowbool = False

    def timesleepcounter(self):
        myfollowers = self.api.getTotalSelfFollowers()
        self.followercount = myfollowers.__len__()

    def writelog(self, writethat, username):
        myfile = open('logs.txt', 'a')
        myfile.writelines(writethat + username + "\n")
        myfile.close()