gnn

Untitled

gnn
Sep 23rd, 2020 (edited)
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 25.36 KB | None | 0 0
  1. import requests, hashlib, string, random, uuid, time, calendar, re, json, urllib.parse, base64, pickle
  2.  
  3. class colors:
  4.  
  5.     ENDC     = '\33[0m'
  6.     BOLD     = '\33[1m'
  7.     ITALIC   = '\33[3m'
  8.     URL      = '\33[4m'
  9.     BLINK    = '\33[5m'
  10.     BLINK2   = '\33[6m'
  11.     SELECTED = '\33[7m'
  12.  
  13.     BLACK  = '\33[30m'
  14.     RED    = '\33[31m'
  15.     GREEN  = '\33[32m'
  16.     YELLOW = '\33[33m'
  17.     BLUE   = '\33[34m'
  18.     VIOLET = '\33[35m'
  19.     BEIGE  = '\33[36m'
  20.     WHITE  = '\33[37m'
  21.  
  22.     BLACKBG  = '\33[40m'
  23.     REDBG    = '\33[41m'
  24.     GREENBG  = '\33[42m'
  25.     YELLOWBG = '\33[43m'
  26.     BLUEBG   = '\33[44m'
  27.     VIOLETBG = '\33[45m'
  28.     BEIGEBG  = '\33[46m'
  29.     WHITEBG  = '\33[47m'
  30.  
  31.     GREY    = '\33[90m'
  32.     RED2    = '\33[91m'
  33.     GREEN2  = '\33[92m'
  34.     YELLOW2 = '\33[93m'
  35.     BLUE2   = '\33[94m'
  36.     VIOLET2 = '\33[95m'
  37.     BEIGE2  = '\33[96m'
  38.     WHITE2  = '\33[97m'
  39.  
  40.     GREYBG    = '\33[100m'
  41.     REDBG2    = '\33[101m'
  42.     GREENBG2  = '\33[102m'
  43.     YELLOWBG2 = '\33[103m'
  44.     BLUEBG2   = '\33[104m'
  45.     VIOLETBG2 = '\33[105m'
  46.     BEIGEBG2  = '\33[106m'
  47.     WHITEBG2  = '\33[107m'
  48.  
  49. def printc(value, color='', nonewline=None, more=''):
  50.  
  51.     end = '\n'
  52.     if nonewline: end = ''
  53.  
  54.     if color: print(color + value + colors.ENDC + more, end=end)
  55.     else: print(value + more, end=end)
  56.  
  57. def inputc(value, color='', more=''):
  58.  
  59.     if color: return input(color + value + colors.ENDC + more)
  60.     else: return input(value + more)
  61.  
  62. def RandomString(n = 10):
  63.     letters = string.ascii_lowercase + '1234567890'
  64.     return ''.join(random.choice(letters) for i in range(n))
  65.  
  66. def RandomStringUpper(n = 10):
  67.     letters = string.ascii_uppercase + '1234567890'
  68.     return ''.join(random.choice(letters) for i in range(n))
  69.  
  70. def RandomStringChars(n = 10):
  71.     letters = string.ascii_lowercase
  72.     return ''.join(random.choice(letters) for i in range(n))
  73.  
  74. def randomStringWithChar(stringLength=10):
  75.     letters = string.ascii_lowercase + '1234567890'
  76.     result = ''.join(random.choice(letters) for i in range(stringLength - 1))
  77.     return RandomStringChars(1) + result
  78.  
  79. def printn(args): print(args, end='')
  80. def ClearConsole(): printn("\033[H\033[2J")
  81. def DeleteLine(): printn("\033[F"); print("\033[K")
  82.  
  83. class account:
  84.  
  85.     def __init__(self, username: str, password: str):
  86.         #self.fheaders = self.fetch_headers()
  87.         self.username = username
  88.         self.password = password
  89.         self.cookies = dict()
  90.         self.csrftoken = ''#self.fheaders['csrftoken']
  91.         self.mid = ''#self.fheaders['mid']
  92.         self.DeviceID = self.generate_device_id(self.hex_digest(username, password))
  93.         self.guid1 = str(uuid.uuid4())
  94.         self.guid2 = str(uuid.uuid4())
  95.         self.guid3 = str(uuid.uuid4())
  96.         self.checkpoint = bool()
  97.         self.loggedIn = bool()
  98.         self.ds_user_id = str()
  99.         self.proxies = []
  100.         self.proxiesIndex = 0
  101.         self.proxyInNeed = bool()
  102.         self.proxy = str()
  103.         self.maxID = str()
  104.         self.kickmeout = bool()
  105.  
  106.         TimeStamp = calendar.timegm(time.gmtime())
  107.  
  108.         headers = {}
  109.         headers['User-Agent'] = self.UserAgent()
  110.         headers['Host'] = 'i.instagram.com'
  111.         headers['x-ig-app-locale'] = 'en_SA'
  112.         headers['x-ig-device-locale'] = 'en_SA'
  113.         headers['x-ig-mapped-locale'] = 'en_US'
  114.         headers['x-pigeon-session-id'] = self.guid()
  115.         headers['x-pigeon-rawclienttime'] = f'{TimeStamp}'
  116.         headers['x-ig-connection-speed'] = '643kbps'
  117.         headers['x-ig-bandwidth-speed-kbps'] = '1236.889'
  118.         headers['x-ig-bandwidth-totalbytes-b'] = '6672937'
  119.         headers['x-ig-bandwidth-totaltime-ms'] = '7015'
  120.         headers['x-ig-app-startup-country'] = 'SA'
  121.         headers['x-bloks-version-id'] = '85e371bf185c688d008ad58d18c84943f3e6d568c4eecd561eb4b0677b1e4c55'
  122.         headers['x-ig-www-claim'] = '0'
  123.         headers['x-bloks-is-layout-rtl'] = 'false'
  124.         headers['x-ig-device-id'] = self.guid()
  125.         headers['x-ig-android-id'] = self.DeviceID
  126.         headers['x-ig-connection-type'] = 'WIFI'
  127.         headers['x-ig-capabilities'] = '3brTvw8='
  128.         headers['x-ig-app-id'] = '567067343352427'
  129.         headers['accept-language'] = 'en-SA, en-US'
  130.         headers['x-mid'] = self.mid
  131.         headers['content-type'] = 'application/x-www-form-urlencoded; charset=UTF-8'
  132.         headers['accept-encoding'] = 'gzip, deflate'
  133.         headers['x-fb-http-engine'] = 'Liger'
  134.         headers['Connection'] = 'close'
  135.         self.headers = headers
  136.         self.login()
  137.  
  138.     def UserAgent(self): # "user-agent"
  139.         version = f'{random.randint(3, 138)}.{random.randint(5, 10)}.{random.randint(0, 10)}'
  140.         if random.randint(0, 1):
  141.             version = f'{random.randint(4, 138)}.{random.randint(0, 10)}.{random.randint(0, 10)}'
  142.         if random.randint(0, 1):
  143.             version = '155.0.0.37.107' #last version
  144.  
  145.         return self.randDevice().replace('(VERSION)', version)
  146.  
  147.     def guid(self): return str(uuid.uuid4()) # "phone_id", "guid", "adid"
  148.  
  149.     def fetch_headers(self) -> dict:
  150.         url = 'https://i.instagram.com/api/v1/si/fetch_headers/'
  151.  
  152.         headers = {}
  153.         headers['Host'] = 'i.instagram.com'
  154.         headers['User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:80.0) Gecko/20100101 Firefox/80.0'
  155.         headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'
  156.         headers['Accept-Language'] = 'ar,en-US;q=0.7,en;q=0.3'
  157.         headers['Accept-Encoding'] = 'gzip, deflate, br'
  158.         headers['Connection'] = 'close'
  159.  
  160.         return requests.get(url, headers=headers).cookies.get_dict()
  161.  
  162.     def hex_digest(self, *args):
  163.         m = hashlib.md5()
  164.         m.update(b''.join([arg.encode('utf-8') for arg in args]))
  165.         return m.hexdigest()
  166.  
  167.     def generate_device_id(self, seed):
  168.         volatile_seed = "12345"
  169.         m = hashlib.md5()
  170.         m.update(seed.encode('utf-8') + volatile_seed.encode('utf-8'))
  171.         return 'android-' + m.hexdigest()[:16]
  172.  
  173.     def randDevice(self) -> str:
  174.  
  175.         dpi = [
  176.         '480', '320', '640', '515', '120', '160', '240', '800'
  177.         ]
  178.         manufacturer = [
  179.             'HUAWEI', 'Xiaomi', 'samsung', 'OnePlus', 'LGE/lge', 'ZTE', 'HTC',
  180.             'LENOVO', 'MOTOROLA', 'NOKIA', 'OPPO', 'SONY', 'VIVO', 'LAVA'
  181.         ]
  182.        
  183.         randResolution = random.randrange(2, 9) * 180
  184.         lowerResolution = randResolution - 180
  185.  
  186.         DEVICE = {
  187.             'android_version': random.randrange(18, 25),
  188.             'android_release': f'{random.randrange(1, 7)}.{random.randrange(0, 7)}',
  189.             'dpi': f'{random.choice(dpi)}dpi',
  190.             'resolution': f'{lowerResolution}x{randResolution}',
  191.             'manufacturer': random.choice(manufacturer),
  192.             'device': f'{random.choice(manufacturer)}-{RandomStringUpper(5)}',
  193.             'model': f'{randomStringWithChar(4)}',
  194.             'cpu': f'{RandomStringChars(2)}{random.randrange(1000, 9999)}'
  195.         }
  196.  
  197.         if random.randrange(0, 2):
  198.             DEVICE['android_release'] = f'{random.randrange(1, 7)}.{random.randrange(0, 7)}.{random.randrange(1, 7)}'
  199.  
  200.         USER_AGENT_BASE = (
  201.             'Instagram (VERSION) '
  202.             'Android ({android_version}/{android_release}; '
  203.             '{dpi}; {resolution}; {manufacturer}; '
  204.             '{device}; {model}; {cpu}; en_US)'
  205.         )
  206.  
  207.         return USER_AGENT_BASE.format(**DEVICE)
  208.  
  209.     def sendCode(self, url, security_code):
  210.         postData = {}
  211.         guid = str(uuid.uuid4())
  212.  
  213.         postData['security_code'] = security_code
  214.         postData['guid'] = self.guid1
  215.         postData['_csrftoken'] = self.cookies['csrftoken']
  216.         postData['device_id'] = self.DeviceID
  217.        
  218.         payload = {}
  219.         payload['signed_body'] = f'SIGNATURE.{json.dumps(postData)}'
  220.  
  221.         response = requests.post(url, headers=self.headers, cookies=self.cookies, data=payload, verify=True)
  222.         return response
  223.  
  224.     def sendMethod(self, url, choice):
  225.         postData = {}
  226.         guid = str(uuid.uuid4())
  227.  
  228.         postData['choice'] = choice # (Phone number = 0, email = 1)
  229.         postData['guid'] = self.guid1
  230.         postData['_csrftoken'] = self.cookies['csrftoken']
  231.         postData['device_id'] = self.DeviceID
  232.  
  233.         payload = {}
  234.         payload['signed_body'] = f'SIGNATURE.{json.dumps(postData)}'
  235.  
  236.         return requests.post(url, headers=self.headers, cookies=self.cookies, data=payload, verify=True)
  237.  
  238.     def login(self):
  239.  
  240.         TimeStamp = calendar.timegm(time.gmtime())
  241.  
  242.         data = {}
  243.         data['jazoest'] = '22713'
  244.         data['phone_id'] = self.guid1
  245.         data['enc_password'] = f'#PWD_INSTAGRAM_BROWSER:0:{TimeStamp}:{self.password}'
  246.         data['_csrftoken'] = self.csrftoken
  247.         data['username'] = self.username
  248.         data['adid'] = self.guid2
  249.         data['guid'] = self.guid3
  250.         data['device_id'] = self.DeviceID
  251.         data['google_tokens'] = '[]'
  252.         data['login_attempt_count'] = '0'
  253.  
  254.         payload = {}
  255.         payload['signed_body'] = f'SIGNATURE.{json.dumps(data)}'
  256.  
  257.         response = requests.post('https://i.instagram.com/api/v1/accounts/login/', headers=self.headers, data=payload, verify=True)
  258.         if 'logged_in_user' in response.text:
  259.             self.loggedIn = True
  260.             self.cookies = response.cookies.get_dict()
  261.             self.csrftoken = self.cookies['csrftoken']
  262.             self.ds_user_id = self.cookies['ds_user_id']
  263.             printc(f'Logged In @{self.username} Successfully', colors.GREEN2)
  264.             #printc('SessionID: ', colors.GREEN2, more=self.cookies['sessionid'])
  265.         elif 'challenge_required' in response.text:
  266.             printc(f'@{self.username} Challenge is required', colors.RED)
  267.             return
  268.             self.checkpoint = True
  269.             self.cookies = response.cookies.get_dict()
  270.  
  271.             checkpoint_path = re.findall(r'"api_path": "(.*?)"', response.text)[0]
  272.             challenge_url = f'https://i.instagram.com/api/v1{checkpoint_path}'
  273.  
  274.             getMethods = requests.get(challenge_url, headers=self.headers, cookies=self.cookies)
  275.  
  276.             phone = bool()
  277.             email = bool()
  278.             try:
  279.                 step_name = getMethods.json()['step_name']
  280.             except Exception as ex:
  281.                 printc('Error, @ctpe', colors.RED)
  282.                 print(getMethods.text)
  283.                 exit()
  284.            
  285.             if step_name == "select_verify_method":
  286.                 if "phone_number" in getMethods.text:
  287.                     phone = True
  288.                 if "email" in getMethods.text:
  289.                     email = True
  290.             elif step_name == "delta_login_review":
  291.                 choice = 0
  292.             else:
  293.                 print(f'Strange step_name: {step_name}\n Send me this {insta}')
  294.                 choice = 0
  295.  
  296.             printc('Challenge is required', colors.RED)
  297.             if email:
  298.                 printc('1', colors.YELLOW, more=') email')
  299.             if phone:
  300.                 printc('0', colors.YELLOW, more=') phone number')
  301.             choice = inputc('Choose a method to unlock your account: ', colors.YELLOW)
  302.            
  303.             res = self.sendMethod(challenge_url, choice)
  304.             sendto = res.json()['step_data']['contact_point']
  305.             print(f'A code has been sent to {sendto}')
  306.            
  307.             code = inputc('Enter code: ', colors.YELLOW)
  308.             response = self.sendCode(challenge_url, code)
  309.             if 'logged_in_user' in response.text:
  310.                 self.loggedIn = True
  311.                 self.cookies = response.cookies.get_dict()
  312.                 self.csrftoken = self.cookies['csrftoken']
  313.                 self.ds_user_id = self.cookies['ds_user_id']
  314.                 printc('Logged In Successfully', colors.GREEN2)
  315.                 printc('SessionID: ', colors.GREEN2, more=self.cookies['sessionid'])
  316.             else: printc('Login failure, try again', colors.GREEN2); exit()
  317.  
  318.         elif "Incorrect Username" in response.text:
  319.             printc(f'@{self.username} doesn\'t not exist', colors.RED)
  320.         elif 'Incorrect password' in response.text:
  321.             printc(f'@{self.username} wrong password', colors.RED)
  322.         elif 'inactive user' in response.text:
  323.             printc(f'@{self.username} banned account', colors.RED)
  324.         else:
  325.             printc(f'@{self.username} unknown response\n{response.text}\n', colors.RED)
  326.  
  327.     #id_to_shortcode = lambda instagram_id: base64.b64encode(instagram_id.to_bytes(9, 'big'), b'-_').decode().replace('A', ' ').lstrip().replace(' ', 'A')
  328.  
  329.     def shortcodeToID(self, shortcode):
  330.         code = ('A' * (12-len(shortcode)))+shortcode
  331.         return int.from_bytes(base64.b64decode(code.encode(), b'-_'), 'big')
  332.  
  333.     def getID(self, us):
  334.         headers = {}
  335.         headers["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:78.0) Gecko/20100101 Firefox/78.0"
  336.         headers["Host"] = "www.instagram.com"
  337.         headers["Accept"] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
  338.         headers["Accept-Language"] = "ar,en-US;q=0.7,en;q=0.3"
  339.         headers["Accept-Encoding"] = "gzip, deflate, br"
  340.         headers["Connection"] = "keep-alive"
  341.  
  342.         res = requests.get(f'https://www.instagram.com/{us}/?__a=1', headers=headers, cookies=self.cookies)
  343.         return res.json()['graphql']['user']['id']
  344.  
  345.     def sendComment(self, shortcode, comment, postID=None):
  346.         url = f'https://i.instagram.com/api/v1/media/{self.shortcodeToID(shortcode)}/comment/'
  347.  
  348.         if postID:
  349.             url = f'https://i.instagram.com/api/v1/media/{postID}/comment/'
  350.  
  351.         data = {
  352.             "delivery_class":"organic",
  353.             "idempotence_token":f'{self.guid()}',
  354.             "carousel_index":"0",
  355.             "_csrftoken":f"{self.csrftoken}",
  356.             "radio_type":"wifi-none",
  357.             "_uid":f'{self.ds_user_id}',
  358.             "_uuid":f'{self.guid()}',
  359.             "comment_text":f'{comment}',
  360.             "is_carousel_bumped_post":"false",
  361.             "feed_position":"0"
  362.         }
  363.  
  364.         payload = {}
  365.         payload['signed_body'] = f'SIGNATURE.{json.dumps(data)}'
  366.  
  367.         if self.proxies:
  368.             if self.proxyInNeed:
  369.                 self.proxy = self.proxiesIndex
  370.                 if self.proxiesIndex == len(self.proxies) - 1:
  371.                     self.proxiesIndex = 0
  372.                 else: self.proxiesIndex += 1
  373.  
  374.             try:
  375.                 if self.proxy:
  376.                     proxies = {'http': self.proxy, 'https': self.proxy}
  377.                     response = requests.post(url, headers=self.headers, cookies=self.cookies, data=payload, verify=True, proxies=proxies)
  378.                 else:
  379.                     response = requests.post(url, headers=self.headers, cookies=self.cookies, data=payload, verify=True)
  380.             except Exception:
  381.                 if self.proxyInNeed:
  382.                     self.proxy = self.proxiesIndex
  383.                     if self.proxiesIndex == len(self.proxies) - 1:
  384.                         self.proxiesIndex = 0
  385.                     else: self.proxiesIndex += 1
  386.             else:
  387.                 if response.json()['status'] == 'ok':
  388.                     printc(f'Sent Successfully by @{self.username}', color=colors.GREEN)
  389.                     self.proxyInNeed = False
  390.                 elif 'Commenting is Off' in response.text:
  391.                     printc(f'You can\'t comment in the target post, cause commenting is Off', color=colors.RED2)
  392.                     exit(1)
  393.                 elif 'feedback_required' in response.text or 'repute/report_problem/instagram_comment/' in response.text:
  394.                     printc(f'@{self.username} Got comment\'s block', color=colors.RED2)
  395.                     self.kickmeout = True
  396.                 else: self.proxyInNeed = True
  397.         else:
  398.             response = requests.post(url, headers=self.headers, cookies=self.cookies, data=payload, verify=True)
  399.             if response.json()['status'] == 'ok':
  400.                 printc(f'Sent Successfully by @{self.username}', color=colors.GREEN)
  401.             elif 'Commenting is Off' in response.text:
  402.                 printc(f'You can\'t comment in the target post, cause commenting is Off', color=colors.RED2)
  403.                 exit(1)
  404.             elif 'feedback_required' in response.text or 'repute/report_problem/instagram_comment/' in response.text:
  405.                 printc(f'@{self.username} Got comment\'s block', color=colors.RED2)
  406.                 self.kickmeout = True
  407.             else: self.kickmeout = True
  408.    
  409.     def getFollowers(self, userID) -> list:
  410.         url = f'https://i.instagram.com/api/v1/friendships/{userID}/followers/?search_surface=follow_list_page&order=default&query=&enable_groups=true&rank_token=missing'
  411.         if self.maxID:
  412.             url += f'&max_id={self.maxID}'
  413.  
  414.         try:
  415.             response = requests.get(url, headers=self.headers, cookies=self.cookies, verify=True, timeout=10)
  416.             res = response.json()
  417.         except Exception as ex:
  418.             return None
  419.        
  420.         users = []
  421.         try:
  422.             _x = res['users']
  423.         except Exception as ex:
  424.             print(ex)
  425.             print(response.text)
  426.         for i in res['users']:
  427.             users.append(i['username'])
  428.  
  429.         if res['next_max_id']:
  430.             self.maxID = res['next_max_id']
  431.         else: self.maxID = str()
  432.  
  433.         return users
  434.  
  435. ClearConsole()
  436. printc('''
  437.  _____                          __  ___       __
  438. / ___/__  __ _  __ _  ___ ___  / /_/ _ )___  / /_
  439. / /__/ _ \/  ' \/  ' \/ -_) _ \/ __/ _  / _ \/ __/
  440. \___/\___/_/_/_/_/_/_/\__/_//_/\__/____/\___/\__/  
  441.  
  442. ''', colors.BLUE)
  443.  
  444. printc(f'By Hades, inst: @0xhades', colors.BLUE2)
  445. print()
  446.  
  447. pickled = bool()
  448.  
  449. target = str()
  450. usernames = []
  451. passwords = []
  452. accounts = []
  453. proxies = []
  454. mentions = []
  455. comments = []
  456. mention = bool()
  457. loop = bool()
  458. eloop = 0
  459. wloop = 0
  460. sleep = int()
  461. selfin = bool()
  462. targets = []
  463.  
  464. choice = inputc('Want to grab followers list to mention them? [Y\\N]: ', colors.YELLOW)
  465. if choice.lower() == 'y':
  466.     list_limit = int(inputc('Want to grab all the followers? (No=0, Yes set a limit=size of list): ', colors.YELLOW))
  467.     username = inputc('Username: ', colors.YELLOW)
  468.     password = inputc('Password: ', colors.YELLOW)
  469.     sleep = int(inputc('sleep (milliseconds, best: 1000, no? = 0): ', colors.YELLOW))
  470.     _account = account(username, password)
  471.     _target = inputc('Get followers from (enter a username): ', colors.YELLOW)
  472.     ID = _account.getID(_target)
  473.  
  474.     count = 0
  475.     while True:
  476.         users = _account.getFollowers(ID)
  477.         if not users: break
  478.         for user in users:
  479.             targets.append(user)
  480.         count += len(users)
  481.         DeleteLine()
  482.         printc(f'Grabbed: {count}', color=colors.BLUE2, nonewline=True)
  483.         if list_limit != 0:
  484.             if count >= list_limit: break
  485.         if not _account.maxID: break
  486.         time.sleep(sleep / 1000)
  487.     selfin = True
  488.     if not len(users) > 0:
  489.         inputc('I can\'t get followrs for some reason, add them manually', colors.RED)
  490.         selfin = False
  491.     print()
  492.  
  493. target = inputc('Enter the Post URL from web: ', colors.YELLOW).split('/')[4]
  494. sleep = int(inputc('commenting sleep (milliseconds, best: 12000, no? = 0): ', colors.YELLOW))
  495.  
  496. choice = inputc('Multi accounts(M) or single(S)? or saved sessions(Pickle)(P) [M/S/P]: ', colors.YELLOW)
  497.  
  498. if choice.lower() == 'm':
  499.     logsleep = int(inputc('login sleep (milliseconds, best: 500, no? = 0): ', colors.YELLOW))
  500.     choice = inputc('Combo list(C) or (usernames+password)(T) [C/T]: ', colors.YELLOW)
  501.     if choice.lower() == 'c':
  502.         try:
  503.             combos = open(inputc('Enter the combo list: ', colors.BLUE) , 'r').read().splitlines()
  504.         except Exception as ex: print(ex)
  505.         for combo in combos:
  506.             usernames.append(combo.split(':')[0])
  507.             passwords.append(combo.split(':')[1])
  508.     else:
  509.         usernames = open(inputc('Enter the usernames list: ', colors.BLUE) , 'r').read().splitlines()
  510.         passwords = open(inputc('Enter the passwords list: ', colors.BLUE) , 'r').read().splitlines()
  511.  
  512. elif choice.lower() == 'p':
  513.     with open(inputc('Enter the path to the sessions: ', colors.BLUE), 'rb') as f:
  514.         accounts = pickle.load(f)
  515.     pickled = True
  516.  
  517. else:
  518.     logsleep = int(inputc('login sleep (milliseconds, best: 500, no? = 0): ', colors.YELLOW))
  519.     usernames.append(inputc('Username: ', colors.YELLOW))
  520.     passwords.append(inputc('Password: ', colors.YELLOW))
  521.  
  522. if len(usernames) != len(passwords): printc(f'Usernames list and passwords are not equal', colors.RED); exit(1)
  523.  
  524. if not pickled:
  525.     for i in range(len(usernames)):
  526.         acc = account(usernames[i], passwords[i])
  527.         time.sleep(logsleep / 1000)
  528.         if acc.loggedIn:
  529.             accounts.append(acc)
  530.  
  531.     choice = inputc('Want to save the sessions (cookies)? [Y\\N]: ', colors.YELLOW)
  532.     if choice.lower() == 'y':
  533.         with open(inputc('Enter the path to a file: ', colors.BLUE), 'wb') as f:
  534.             pickle.dump(accounts, f)
  535.  
  536. unloggedIn = 0
  537. for i in accounts:
  538.     if not i.loggedIn: unloggedIn += 1
  539.  
  540. if unloggedIn == len(accounts): exit(1)
  541.  
  542. choice = inputc('Want to use proxies? [Y\\N]: ', colors.YELLOW)
  543. if choice.lower() == 'y':
  544.     proxies = open(inputc('Enter the proxies list: ', colors.BLUE) , 'r').read().splitlines()
  545.     for i in accounts:
  546.         i.proxies = proxies
  547.  
  548. if not selfin:
  549.     choice = inputc('Want to use mentions Bot? [Y\\N]: ', colors.YELLOW)
  550.     if choice.lower() == 'y':
  551.         mention = True
  552.         choice = inputc('Want to load the usernames here(T) or from an extend file(F) ? [T\F]: ', colors.YELLOW)
  553.         if choice.lower() == 'f':
  554.             targets = open(inputc('Enter the path to the usernames file: ', colors.BLUE) , 'r').read().splitlines()
  555.             mentions_per_comment = int(inputc('how many mentions per comment?: ', colors.YELLOW))
  556.            
  557.             users = len(targets)
  558.             comment_limit = mentions_per_comment
  559.             comments_count = 0
  560.             if users > comment_limit:
  561.                 temp = ''
  562.                 for i in range(users):
  563.                     if i != 0 and i % comment_limit == 0:
  564.                         comments_count += 1
  565.                         comments.append(temp)
  566.                         temp = ''
  567.                         if (users - (comments_count * comment_limit)) < comment_limit: break
  568.                     temp += f'@{targets[i]} '
  569.                 left = (users - (comments_count * comment_limit))
  570.                 temp = ''
  571.                 for user in targets[-left:]:
  572.                     temp += f'@{targets[i]} '
  573.                 comments.append(temp)
  574.                 comments_count += 1
  575.  
  576.             else:
  577.  
  578.                 for user in targets:
  579.                     temp += f' @{targets[i]} '
  580.                 comments.append(temp)
  581.                 comments_count += 1
  582.  
  583.         else:
  584.             comments.append(inputc('Enter usernames, please use @ before every username:\n', colors.YELLOW))
  585.     else:
  586.         choice = inputc('Want to load the comments here(T) or from an extend file(F) ? [T\F]: ', colors.YELLOW)
  587.         if choice.lower() == 'f':
  588.             comments = open(inputc('Enter the path to the comments file: ', colors.BLUE) , 'r').read().splitlines()
  589.         else:
  590.             comments.append(inputc('Enter text:\n', colors.YELLOW))
  591.  
  592. else:
  593.  
  594.     mentions_per_comment = int(inputc('how many mentions per comment?: ', colors.YELLOW))
  595.            
  596.     users = len(targets)
  597.     comment_limit = mentions_per_comment
  598.     comments_count = 0
  599.     if users > comment_limit:
  600.         temp = ''
  601.         for i in range(users):
  602.             if i != 0 and i % comment_limit == 0:
  603.                 comments_count += 1
  604.                 comments.append(temp)
  605.                 temp = ''
  606.                 if (users - (comments_count * comment_limit)) < comment_limit: break
  607.             temp += f'@{targets[i]} '
  608.         left = (users - (comments_count * comment_limit))
  609.         temp = ''
  610.         for user in targets[-left:]:
  611.             temp += f'@{targets[i]} '
  612.         comments.append(temp)
  613.         comments_count += 1
  614.  
  615.     else:
  616.  
  617.         for user in targets:
  618.             temp += f' @{targets[i]} '
  619.         comments.append(temp)
  620.         comments_count += 1
  621.  
  622. choice = inputc('Do want to repeat the comment (loop)? (Y/N): ', colors.YELLOW)
  623. if choice.lower() == 'y':
  624.     loop = True
  625.     eloop = int(inputc('Enter the number of loops for each comment (no = 1): ', colors.YELLOW))
  626.     wloop = int(inputc('Enter the number of loops for the whole comments (no = 1): ', colors.YELLOW))
  627.    
  628. blocked = 0
  629. for comment in comments:
  630.  
  631.     def send(comment) -> bool:
  632.         global blocked
  633.         if loop:
  634.             for lap in range(wloop):
  635.                 for _lap in range(eloop):
  636.                     acc = random.choice(accounts)
  637.                     acc.sendComment(target, comment)
  638.                     if acc.kickmeout: blocked += 1; return False
  639.                     time.sleep(sleep / 1000)
  640.                     return True
  641.         else:
  642.  
  643.             acc = random.choice(accounts)
  644.             acc.sendComment(target, comment)
  645.             if acc.kickmeout: blocked += 1; return False
  646.             time.sleep(sleep / 1000)
  647.             return True
  648.  
  649.     while True:
  650.         if send(comment): break
  651.         if blocked == len(accounts):
  652.             printc('All accounts got blocked!', colors.RED)
  653.             exit(1)
  654.  
Add Comment
Please, Sign In to add comment