Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import asyncio
- import string
- import sys
- import random
- import socket
- import pickle
- import os
- import datetime
- from random import randrange
- from random import randint
- from selenium import webdriver
- from selenium.webdriver.common.keys import Keys
- from selenium.webdriver.common.by import By
- from selenium.webdriver.support.ui import WebDriverWait
- from selenium.webdriver.support import expected_conditions as ec
- from selenium.webdriver.common.action_chains import ActionChains
- # from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
- # binary = FirefoxBinary("C:\\Program Files\\Light\\light.exe")
- # get = os.listdir('C:\\Users\\Administrator\\AppData\\Roaming\\Light\\Light\\Profiles')
- # putanja = 'C:\\Users\\Administrator\\AppData\\Roaming\\Light\\Light\\Profiles\\' + get[0]
- options = webdriver.ChromeOptions()
- # options.add_argument("user-data-dir=C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\User Data")
- ua = "user-data-dir=C:\\Profiles\\" + str(sys.argv[1]) + "Parent"
- options.add_argument(ua)
- pd = "--profile-directory=" + str(sys.argv[1])
- options.add_argument(pd)
- # options.set_headless(headless=True)
- options.add_argument('window-size=1920x1080')
- options.add_argument('start-maximized')
- options.add_argument('log-level=3')
- # options.add_argument('--ignore-certificate-errors')
- # options.add_argument("--proxy-server='direct://'")
- # options.add_argument('--proxy-bypass-list=*')
- #PROXY = '190.2.140.41:37415'
- #options.add_argument('--proxy-server=%s' % PROXY)
- # options.add_argument('user-agent=Chrome/61.0.3163.79')
- print(ua)
- print(pd)
- driver = webdriver.Chrome(executable_path="chromedriver.exe", chrome_options=options)
- # driver.set_window_size(1920, 1080)
- driver.get("https://discordapp.com/activity")
- videle = "//video[@class='ready-36e6Vk']"
- try:
- WebDriverWait(driver, 20).until(
- ec.presence_of_element_located((By.XPATH, videle)))
- WebDriverWait(driver, 120).until_not(
- ec.presence_of_element_located((By.XPATH, videle)))
- except Exception as e:
- driver.get('https://discordapp.com/activity')
- time.sleep(5)
- # driver.implicitly_wait(5)
- # gl = driver.find_elements_by_xpath("//div[@class='guildSeparator-1X4GQ1']/following-sibling::div[@class='guild-1EfMGQ']")
- # gl = driver.find_elements_by_class_name("guild-1EfMGQ")
- # loc = 60
- # print('CHeckujem guilde')
- # home = gl[0]
- # for guild in range(0,len(gl)-2):
- # last_height = driver.execute_script("return document.body.scrollHeight")
- # driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
- # driver.execute_script('arguments[0].scrollIntoView()', guild)
- ##driver.execute_script('arguments[0].scrollIntoView()', gl[guild])
- ##await asyncio.sleep(1)
- ##actions = ActionChains(driver)
- # actions.move_to_element(gl[guild]).click().perform()
- ##gl[guild].click()
- ##actions.perform(gl[guild])
- # await asyncio.sleep(1)
- ##driver.execute_script("arguments[0].click();", gl[guild])
- # gl[guild].send_keys(u'ue007')
- # condition = ec.visibility_of_element_located(gl[guild])
- # fo = WebDriverWait(driver, 15).until(condition)
- # fo.click()
- # print('Usao u guildu')
- # await asyncio.sleep(10)
- # driver.execute_script('arguments[0].scrollIntoView()', home)
- # actions.click(home).perform()
- # actions = ActionChains(driver)
- # actions.move_to_element(home.click().perform())
- # driver.execute_script('arguments[0].scrollIntoView()', home)
- # await asyncio.sleep(1)
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- try:
- PREFIX_FILE_PATH = 'C:\\BOT\\' + str(sys.argv[1])
- PREFIX_FILE_PATH_BF = 'C:\\BOT\\'
- PREFIX_FILE_PATH_PICKLE = 'Z:\\Shared\\pickles\\' + str(sys.argv[1])
- breaker = False
- memberi = []
- max_number_members = 0
- next_member = 0
- servers_list_check = []
- data = 0
- cnt = 1
- userFile = open(PREFIX_FILE_PATH_BF + "accountConfig.txt", "r")
- logfile = open(PREFIX_FILE_PATH_BF + "LOG.txt", "w")
- configLoad = userFile.readlines()
- username = configLoad[0]
- password = configLoad[1]
- userFile.close()
- serverFile = open(PREFIX_FILE_PATH_BF + "serverProtocolConfig.txt", "r")
- serverLoad = serverFile.readlines()
- IPadress = serverLoad[0]
- portLoader = serverLoad[1]
- serverFile.close()
- messageSend = []
- host = IPadress
- port = int(portLoader)
- print('HOST : ', host)
- print('PORT : ', port)
- oServersF = open(PREFIX_FILE_PATH_BF + "oservers.txt", "r")
- oServersX = oServersF.readlines()
- oServers = [x.replace("\n", "") for x in oServersX]
- cachedKicks = []
- kicksToPerform = []
- def mwconn(host, port):
- try:
- s.connect((host, port))
- except socket.error as exc:
- print('Caught exception socket.error:' + exc)
- mwconn(host, port)
- iskoristi = False
- async def start_process():
- print('Startujem bota ')
- global iskoristi
- if iskoristi == False:
- iskoristi = True
- await start_bot()
- def init_client():
- global s
- sFileName = PREFIX_FILE_PATH_PICKLE + 'dict.pickle'
- messageConfigure = "GIVE_PICKLE"
- boolForSend = 0
- global messageSend
- while True:
- if boolForSend == 0:
- BUFFER_SIZE = 1024
- s.send(messageConfigure.encode())
- print('Poslao pickleFile request serveru')
- fDownloadFile = PREFIX_FILE_PATH_PICKLE + "dict.pickle"
- with open(fDownloadFile, 'wb') as fw:
- msg = s.recv(BUFFER_SIZE)
- fsize = int(msg.decode('utf-8').strip())
- rsize = 0
- while True:
- data = s.recv(BUFFER_SIZE)
- rsize = rsize + len(data)
- fw.write(data)
- if rsize >= fsize:
- break
- print("Zavrseno skidanje pickle-a")
- messageConfigure = 'GIVE_MESSAGE'
- sFileName = PREFIX_FILE_PATH + 'porukaZaSlanje.txt'
- boolForSend = boolForSend + 1
- time.sleep(0.1) # MORA ZBOG TPP
- continue # MORA ZBOG TPP extra layer
- if boolForSend == 1:
- s.send(messageConfigure.encode())
- print('Poslao messageFile request serveru')
- sData = s.recv(1024)
- fDownloadFile = open(sFileName, "wb")
- while sData:
- if 'done031337' in str(sData):
- break
- fDownloadFile.write(sData)
- sData = s.recv(1024)
- print("Zavrseno skidanje poruke")
- fDownloadFile.close()
- messageFile = open(PREFIX_FILE_PATH + "porukaZaSlanje.txt", "r")
- lineRead = messageFile.readlines()
- for line in lineRead:
- print('PORUKA : ', line, ' ZAVRSENO')
- messageSend.append(line)
- boolForSend = boolForSend + 1
- messageConfigure = 'GIVE_PICKLE2'
- messageFile.close()
- sFileName = PREFIX_FILE_PATH + 'serverMe8mbersConfig.txt'
- time.sleep(0.1)
- continue
- if boolForSend == 2:
- BUFFER_SIZE = 1024
- messageConfigure = 'GIVE_PICKLE2'
- s.send(messageConfigure.encode())
- print('Poslao serverListFile request serveru')
- fDownloadFile = PREFIX_FILE_PATH + "remembServers.pickle"
- with open(fDownloadFile, 'wb') as fw:
- msg = s.recv(BUFFER_SIZE)
- fsize = int(msg.decode('utf-8').strip())
- rsize = 0
- while True:
- data = s.recv(BUFFER_SIZE)
- rsize = rsize + len(data)
- fw.write(data)
- if rsize >= fsize:
- break
- print("Zavrseno skidanje pickle-a 2")
- messageConfigure = 'GIVE_MESSAGE'
- sFileName = PREFIX_FILE_PATH + 'porukaZaSlanje.txt'
- boolForSend = boolForSend + 1
- time.sleep(0.1) # MORA ZBOG TPP
- continue # MORA ZBOG TPP extra layer
- if boolForSend == 3:
- print('LOGUJEM SE IN...')
- loop = asyncio.get_event_loop()
- loop.run_until_complete(start_process())
- return
- def BMP(s):
- return "".join((i if ord(i) < 10000 else '\ufffd' for i in s))
- # @client.event
- # async def on_ready():
- # client.loop.create_task(start_bot())
- def random_string(length):
- return ''.join(random.choice(string.ascii_letters) for m in range(1, length))
- def configure_message(message, length, idx):
- global messageSend
- message = messageSend[idx]
- message1 = ''
- message2 = ''
- messageo = message
- for i in range(1, randint(1, 30)):
- message2 += ' '
- messageo = messageo.replace('!!!', message2)
- # messageo = messageo.replace('/Gameplay', '/' + random_string(5))
- # messageo = messageo.replace('trailer.html', 'trailer/' + random_string(5))
- for i in range(1, randint(1, 50)):
- message1 += ' '
- return message + ' ' + message2
- check_flaw = 0
- async def start_bot():
- #pickle_in = open(PREFIX_FILE_PATH_PICKLE + "dict.pickle", "rb")
- #memberi_load = pickle.load(pickle_in) #
- serverListReader = open(PREFIX_FILE_PATH + "remembServers.pickle", "rb")
- loadListReader = pickle.load(serverListReader) #
- dict_remember = {}
- for passout in loadListReader:
- dict_remember[passout] = 0
- serverListReader.close()
- #pickle_in.close()
- #random_seed = []
- random_seed = [5, 1 , 1, 3 , 3, 4]
- global check_flaw1
- regularMESSAGE = 'GIVE_DATA'
- formatMESSAGE = ''
- global messageSend
- global s
- global cnt
- if len(messageSend[0]) < 6:
- formatMESSAGE = 'MALA PORUKA, GASIM SE'
- s.send(formatMESSAGE.encode())
- s.close()
- print('GASIM SE')
- print('Duzina poruke '+ str(len(messageSend)))
- sys.exit(0)
- while True:
- try:
- rnd = randint(0, len(random_seed) - 1)
- print('PORUKA ZA SLANJE : ', messageSend[rnd])
- # if cnt == 100:
- # driver.get('https://discordapp.com/activity')
- # await asyncio.sleep(2)
- try:
- WebDriverWait(driver, 20).until(
- ec.presence_of_element_located((By.XPATH, "//div[@class='guildSeparator-1X4GQ1']")))
- except Exception as e:
- s.close()
- sys.exit(1)
- #await asyncio.sleep(5)
- print('Nisam nasao GUILDe, gasim se')
- logfile.close()
- continue
- gl = driver.find_elements_by_xpath(
- "//div[@class='guildSeparator-1X4GQ1']/following-sibling::div[contains(@class, 'guild-1EfMGQ')]/descendant::a")
- cursrvs = []
- for guild in gl:
- srvr = str(guild.get_attribute('aria-label'))
- cursrvs.append(srvr)
- if len(cursrvs) < 2:
- await asyncio.sleep(5)
- print('Lista GUILDi je manja od 2, ranujem loop opet!')
- continue
- for x in oServers:
- if x not in cursrvs:
- if x not in cachedKicks:
- print('Server ' + x + ' ne postoji u listi originalnih, DOBIO KICK')
- cachedKicks.append(x)
- kicksToPerform.append(x)
- # perform pending kicks
- if len(kicksToPerform) > 0:
- por = 'LOSE ' + kicksToPerform.pop(0)
- s.send(por.encode())
- print('Poslao serveru pending kick')
- await asyncio.sleep(1)
- continue
- s.send(regularMESSAGE.encode())
- print('Poslao REQ serveru')
- #await asyncio.sleep(1)
- data = s.recv(2048)
- if 'stop' in str(data):
- print('Stopirana sesija')
- break
- if 'napusti' in str(data):
- await asyncio.sleep((60 * 60) * 6)
- print('VRATIO SAM SE IZ OKIDANJA')
- if not data:
- await asyncio.sleep(5)
- continue
- next_member = str(data.decode('utf-8').strip())
- print('MEMBER DOBIJEN ', next_member)
- #random_index = randrange(len(random_seed))
- print('Dobio novi zadatak za izvrsavanje')
- await asyncio.sleep(2)
- bdy = driver.find_element_by_tag_name("body")
- bdyactions = ActionChains(driver)
- bdyactions.move_to_element(bdy).click().send_keys(Keys.ENTER).perform()
- # try:
- # inputbox = WebDriverWait(driver, 20).until(
- # ec.presence_of_element_located((By.XPATH, "//input[@type='text']")))
- # print('Located input box.')
- # driver.execute_script('arguments[0].scrollIntoView(true)', inputbox)
- # except Exception as e:
- # print(str(e))
- # print('Couldnt find search box!')
- #
- # await asyncio.sleep(60 + randint(1, 13))
- # continue
- await asyncio.sleep(10)
- res = driver.find_element_by_tag_name("body")
- ActionChains(driver).move_to_element(res).send_keys(Keys.CONTROL + 'k').perform()
- print('Otvaram Search Members...')
- await asyncio.sleep(3)
- ele = WebDriverWait(driver, 10).until(ec.presence_of_element_located((By.XPATH, "//input[@class='input-2VB9rf']")))
- driver.execute_script('arguments[0].scrollIntoView(true)', ele)
- #driver.execute_script('arguments[0].focus()', ele)
- ActionChains(driver).move_to_element(ele).click().perform()
- await asyncio.sleep(1)
- try:
- mname = str(next_member)
- firstPART = mname[:-5]
- secondPART = mname[len(mname) - 4:]
- ActionChains(driver).move_to_element(ele).perform()
- ele.send_keys('@')
- ele.send_keys('@')
- ActionChains(driver).move_to_element(ele).send_keys(firstPART).perform()
- await asyncio.sleep(3)
- ActionChains(driver).move_to_element(ele).send_keys('#' + secondPART).perform()
- except Exception as e:
- formatMESSAGE = 'Poslao ' + str(cnt) + '. poruku memberu ' + BMP(mname) + '- u na serveru ' + ' FAILURE1 ' + datetime.datetime.now().strftime(
- '%Y-%m-%d %H:%M:%S')
- s.send(formatMESSAGE.encode())
- WebDriverWait(driver, 10).until(
- ec.presence_of_element_located((By.XPATH, "//a[@href='/activity']")))
- act = driver.find_element_by_xpath("//a[@href='/activity']")
- driver.execute_script('arguments[0].focus()', act)
- act.click()
- await asyncio.sleep(14 + randint(1, 8))
- #await asyncio.sleep(60 + randint(1, 13))
- continue
- try:
- WebDriverWait(driver, 15).until(
- ec.presence_of_element_located((By.CSS_SELECTOR, ".resultFocused-3aIoYe")))
- ActionChains(driver).send_keys(Keys.ENTER).perform()
- await asyncio.sleep(3)
- WebDriverWait(driver, 10).until(ec.presence_of_element_located(
- (By.XPATH, "//textarea[@placeholder='Message @" + BMP(firstPART) + "']")))
- res3 = driver.find_element_by_xpath(
- "//textarea[@placeholder='Message @" + BMP(firstPART) + "']")
- res3.send_keys(configure_message(messageSend, 5, rnd))
- res3.send_keys(Keys.ENTER)
- cnt = cnt + 1
- if cnt >= 210:
- logfile.close()
- else:
- logfile.write(BMP(mname) + '\n')
- except Exception as e:
- print(str(e))
- ActionChains(driver).send_keys(Keys.ESCAPE).perform()
- await asyncio.sleep(2)
- ActionChains(driver).send_keys(Keys.ESCAPE).perform()
- form = 'Poslao ' + str(cnt) + '. poruku memberu ' + BMP(
- firstPART) + ' FAILURE ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- print('Nije moguce poslati poruku ', BMP(firstPART), ' greska = ', str(e),
- datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
- print('RAZLOG: Nisam nasao memebera u listi...')
- s.send(form.encode())
- #await asyncio.sleep(60 + randint(1, 13))
- #print('SPAVAM ', random_seed[rnd] * 60 + 4, ' sekundi')
- await asyncio.sleep(14 + randint(1, 8))
- continue
- try:
- WebDriverWait(driver, 10).until(
- ec.presence_of_element_located((By.XPATH, "//a[@href='/activity']")))
- act = driver.find_element_by_xpath("//a[@href='/activity']")
- driver.execute_script('arguments[0].focus()', act)
- try:
- #print('Clicked activity 1st time')
- act.click()
- except Exception as e:
- #print('Clicked activity 2nd time')
- bu = driver.find_element_by_xpath("//a[@href='/activity']")
- bu.click()
- except Exception as e:
- print(str(e))
- print('Poslao ', cnt, '. poruku memberu ', BMP(firstPART), ' ', datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
- formatMESSAGE = 'Poslao ' + str(cnt) + '. poruku memberu ' + BMP(
- BMP(firstPART)) + ' ' + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- s.send(formatMESSAGE.encode())
- await asyncio.sleep(14 + randint(1, 8))
- # if cnt % (48) == 0: #prosti
- # await asyncio.sleep(970 + randint(1, 5))
- # else:
- #await asyncio.sleep(60 + randint(1, 13))
- except Exception as e:
- porukaLOG = 'Nije moguce poslati poruku ' + BMP(firstPART) + ' greska = ' + str(
- e) + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
- print('Nije moguce poslati poruku ', BMP(firstPART+secondPART), ' greska = ', str(e),
- datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S'))
- s.send(porukaLOG.encode())
- await asyncio.sleep(14 + randint(1, 8))
- #await asyncio.sleep(60 + randint(1, 13))
- print('Bot zavrsio sa radom')
- s.close()
- sys.exit(0)
- init_client()
- except Exception as e:
- s.close()
- print(str(e))
- print('GASIM SE1')
- sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement