Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pychan import FourChan, LogLevel, PychanLogger
- from pychan.models import Thread
- from selenium import webdriver
- from selenium.webdriver.common.by import By
- from selenium.webdriver.common.keys import Keys
- import time
- import random
- import os
- ITTAN = 30
- IPPUN = 60
- NIFUN = 120
- GOFUN = 300
- JUPPUN = 600
- HANJIKAN = 1800
- ITIJIKAN = 3600
- BEG_DELAY = GOFUN
- BEG_DELAY_FACTOR = ITIJIKAN
- LAST_REPLYCOUNT = 0
- IMG_GENKAI_TOPPA = False
- jp_thread_no = 0
- #AMELIA
- BAELZ = 0
- BIJOU = 1
- FAUNA = 2
- FWMC = 3
- GURA = 4
- INANIS = 5
- IRYS = 6
- KIARA = 7
- KRONII = 8
- MORI = 9
- MUMEI = 10
- NERISSA = 11
- SHIORI = 12
- CURRENT_MAX = 12
- bigrange, smallrange = 200, 20
- vt_thread_numbers = [0 for a in range(smallrange)]
- img_totals = [0 for b in range(smallrange)]
- img_counts = [0 for c in range(smallrange)]
- img_lists = [[0 for d in range(bigrange)] for e in range(smallrange)]
- ameliaimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\amelia"
- baelzimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\baelz"
- bijouimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\bijou"
- faunaimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\fauna"
- fwmcimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\fwmc"
- guraimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\gura"
- inanisimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\inanis"
- irysimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\irys"
- kiaraimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\kiara"
- kroniiimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\kronii"
- moriimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\mori"
- mumeiimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\mumei"
- nerissaimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\nerissa"
- shioriimgdirectory = "C:\\Users\\user\\PycharmProjects\\ENggarBot\\shiori"
- img_directories = ([baelzimgdirectory, bijouimgdirectory, faunaimgdirectory, fwmcimgdirectory, guraimgdirectory,
- inanisimgdirectory, irysimgdirectory, kiaraimgdirectory, kroniiimgdirectory, moriimgdirectory,
- mumeiimgdirectory, nerissaimgdirectory, shioriimgdirectory])
- #amelia's thread has no title because her fans are on another level of autism, separate loop in find_vt_threads
- baelz_thread_title = "/rrat/"
- bijou_thread_title = "/gem/"
- fauna_thread_title = "/uuu/"
- fwmc_thread_title = "/baubau/"
- gura_thread_title = "/ggg/"
- inanis_thread_title = "/wah/"
- irys_thread_title = "/HiRyS/"
- kiara_thread_title = "/wawa/"
- kronii_thread_title = "/∞/"
- mori_thread_title = "森カリオペ"
- mumei_thread_title = "/who/"
- nerissa_thread_title = "/ope/"
- shiori_thread_title = "Shiori Novella"
- logger = PychanLogger(LogLevel.INFO)
- fourchan = FourChan(logger=logger, raise_http_exceptions=True, raise_parsing_exceptions=True)
- options = webdriver.ChromeOptions()
- options.add_argument("user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data")
- driver = webdriver.Chrome(options=options)
- def init_img_folders():
- #AMELIA
- img_lists[BAELZ] = os.listdir(baelzimgdirectory)
- img_totals[BAELZ] = len(img_lists[BAELZ])
- random.shuffle(img_lists[BAELZ])
- img_counts[BAELZ] = 0
- img_lists[BIJOU] = os.listdir(bijouimgdirectory)
- img_totals[BIJOU] = len(img_lists[BIJOU])
- random.shuffle(img_lists[BIJOU])
- img_counts[BIJOU] = 0
- img_lists[FAUNA] = os.listdir(faunaimgdirectory)
- img_totals[FAUNA] = len(img_lists[FAUNA])
- random.shuffle(img_lists[FAUNA])
- img_counts[FAUNA] = 0
- img_lists[FWMC] = os.listdir(fwmcimgdirectory)
- img_totals[FWMC] = len(img_lists[FWMC])
- random.shuffle(img_lists[FWMC])
- img_counts[FWMC] = 0
- img_lists[GURA] = os.listdir(guraimgdirectory)
- img_totals[GURA] = len(img_lists[GURA])
- random.shuffle(img_lists[GURA])
- img_counts[GURA] = 0
- img_lists[INANIS] = os.listdir(inanisimgdirectory)
- img_totals[INANIS] = len(img_lists[INANIS])
- random.shuffle(img_lists[INANIS])
- img_counts[INANIS] = 0
- img_lists[IRYS] = os.listdir(irysimgdirectory)
- img_totals[IRYS] = len(img_lists[IRYS])
- random.shuffle(img_lists[IRYS])
- img_counts[IRYS] = 0
- img_lists[KIARA] = os.listdir(kiaraimgdirectory)
- img_totals[KIARA] = len(img_lists[KIARA])
- random.shuffle(img_lists[KIARA])
- img_counts[KIARA] = 0
- img_lists[KRONII] = os.listdir(kroniiimgdirectory)
- img_totals[KRONII] = len(img_lists[KRONII])
- random.shuffle(img_lists[KRONII])
- img_counts[KRONII] = 0
- img_lists[MORI] = os.listdir(moriimgdirectory)
- img_totals[MORI] = len(img_lists[MORI])
- random.shuffle(img_lists[MORI])
- img_counts[MORI] = 0
- img_lists[MUMEI] = os.listdir(mumeiimgdirectory)
- img_totals[MUMEI] = len(img_lists[MUMEI])
- random.shuffle(img_lists[MUMEI])
- img_counts[MUMEI] = 0
- img_lists[NERISSA] = os.listdir(nerissaimgdirectory)
- img_totals[NERISSA] = len(img_lists[NERISSA])
- random.shuffle(img_lists[NERISSA])
- img_counts[NERISSA] = 0
- img_lists[SHIORI] = os.listdir(shioriimgdirectory)
- img_totals[SHIORI] = len(img_lists[SHIORI])
- random.shuffle(img_lists[SHIORI])
- img_counts[SHIORI] = 0
- def find_vt_threads():
- global vt_thread_numbers
- for g in range(smallrange):
- vt_thread_numbers[g] = 0
- for thread in fourchan.get_threads("vt"):
- threadtitle = str(thread.title)
- # get the amelia thread separately because her fans are turboautists that refuse to have a title
- #OP_post_no = int(thread.number)
- #for post in fourchan.get_posts(thread)
- # if (post.number == OP_post_no) and ("Amelia Watson appreciation" in post.text):
- # vt_thread_numbers[AMELIA] = thread.number
- if baelz_thread_title in threadtitle:
- vt_thread_numbers[BAELZ] = thread.number
- elif bijou_thread_title in threadtitle:
- vt_thread_numbers[BIJOU] = thread.number
- elif fauna_thread_title in threadtitle:
- vt_thread_numbers[FAUNA] = thread.number
- elif fwmc_thread_title in threadtitle:
- vt_thread_numbers[FWMC] = thread.number
- elif gura_thread_title in threadtitle:
- vt_thread_numbers[GURA] = thread.number
- elif inanis_thread_title in threadtitle:
- vt_thread_numbers[INANIS] = thread.number
- elif irys_thread_title in threadtitle:
- vt_thread_numbers[IRYS] = thread.number
- elif kiara_thread_title in threadtitle:
- vt_thread_numbers[KIARA] = thread.number
- elif kronii_thread_title in threadtitle:
- vt_thread_numbers[KRONII] = thread.number
- elif mori_thread_title in threadtitle:
- vt_thread_numbers[MORI] = thread.number
- elif mumei_thread_title in threadtitle:
- vt_thread_numbers[MUMEI] = thread.number
- elif nerissa_thread_title in threadtitle:
- vt_thread_numbers[NERISSA] = thread.number
- elif shiori_thread_title in threadtitle:
- vt_thread_numbers[SHIORI] = thread.number
- def find_jp_thread():
- global jp_thread_no, LAST_JP_THREADNO
- LAST_JP_THREADNO = jp_thread_no
- jp_thread_no = 0
- while jp_thread_no == 0:
- for thread in fourchan.get_threads("jp"):
- if thread.title == "hololive":
- jp_thread_no = thread.number
- break
- def check_jp_thread():
- global jp_thread_no, jp_thread_imgcount, jp_thread_replycount, BEG_DELAY, LAST_REPLYCOUNT, IMG_GENKAI_TOPPA
- find_jp_thread()
- jp_thread = Thread("jp", jp_thread_no)
- driver.get(jp_thread.url)
- element = driver.find_element(By.CLASS_NAME, "ts-replies")
- jp_thread_replycounttext = element.get_property("innerText")
- try:
- jp_thread_replycount = int(jp_thread_replycounttext)
- except ValueError:
- time.sleep(GOFUN)
- print("Current /jp/ thread reply count is: " + str(jp_thread_replycount))
- element = driver.find_element(By.CLASS_NAME, "ts-images")
- imagecounttext = element.get_property("innerText")
- jp_thread_imgcount = int(imagecounttext)
- if jp_thread_imgcount >= 300:
- IMG_GENKAI_TOPPA = True
- else:
- IMG_GENKAI_TOPPA = False
- print("Current /jp/ thread file count is: " + str(jp_thread_imgcount))
- if LAST_REPLYCOUNT == 0: #first loop
- LAST_REPLYCOUNT = jp_thread_replycount
- else:
- new_replycount = jp_thread_replycount - LAST_REPLYCOUNT
- if new_replycount < 0: #thread changed
- BEG_DELAY = GOFUN
- LAST_REPLYCOUNT = jp_thread_replycount
- else:
- BEG_DELAY = int(BEG_DELAY_FACTOR / new_replycount)
- LAST_REPLYCOUNT = jp_thread_replycount
- if IMG_GENKAI_TOPPA:
- BEG_DELAY = int(BEG_DELAY / 2)
- def make_pasta():
- global nextpastatext
- nextpastatext = ""
- pasta_loop_count = 0
- jp_thread = Thread("jp", jp_thread_no)
- nextmemberthread = Thread("vt", vt_thread_numbers[nextmember])
- while not nextpastatext:
- nextmemberfound = False
- nextpasta = random.choice(fourchan.get_posts(nextmemberthread))
- nextpastatext = nextpasta.text
- if (("youtu.be" in nextpastatext) or ("x.com" in nextpastatext) or ("twitter.com" in nextpastatext) or
- ("https://" in nextpastatext) or (">>" in nextpastatext)):
- nextpastatext = ""
- match nextmember:
- case 0:
- if ("baelz" in nextpastatext.lower()) or ("bae" in nextpastatext.lower()):
- nextmemberfound = True
- case 1:
- if ("bijou" in nextpastatext.lower()) or ("biboo" in nextpastatext.lower()):
- nextmemberfound = True
- case 2:
- if ("fau" in nextpastatext.lower()) or ("ceres" in nextpastatext.lower()):
- nextmemberfound = True
- case 3:
- if ("fuwa" in nextpastatext.lower()) or ("moco" in nextpastatext.lower()):
- nextmemberfound = True
- case 4:
- if ("guwa" in nextpastatext.lower()) or ("gura" in nextpastatext.lower()):
- nextmemberfound = True
- case 5:
- if "ina" in nextpastatext.lower():
- nextmemberfound = True
- case 6:
- if "irys" in nextpastatext.lower():
- nextmemberfound = True
- case 7:
- if ("kiara" in nextpastatext.lower()) or ("kiwawa" in nextpastatext.lower()):
- nextmemberfound = True
- case 8:
- if "kronii" in nextpastatext.lower():
- nextmemberfound = True
- case 9:
- if 'mori' in nextpastatext.lower():
- nextmemberfound = True
- case 10:
- if ('mumei' in nextpastatext.lower()) or ("moom" in nextpastatext.lower()):
- nextmemberfound = True
- case 11:
- if "rissa" in nextpastatext.lower():
- nextmemberfound = True
- case 12:
- if 'shiori' in nextpastatext.lower():
- nextmemberfound = True
- if not nextmemberfound:
- nextpastatext = ""
- for post in fourchan.get_posts(jp_thread):
- if post.text == nextpastatext:
- nextpastatext = ""
- pasta_loop_count += 1
- if pasta_loop_count > 100:
- nextpastatext = "Burnt the water, now the pasta is ruined."
- if nextpastatext == "Burnt the water, now the pasta is ruined.":
- nextpastatext = ""
- else:
- print("Gonna post this, lol: " + nextpastatext)
- def strain_the_pasta():
- global nextpastatext, nextmember
- first_pasta_attempt = True
- nextpastatext = ""
- while not nextpastatext:
- if not first_pasta_attempt:
- find_vt_threads()
- nextmemberthreadnumber = 0
- while nextmemberthreadnumber == 0:
- nextmember = random.randint(0, CURRENT_MAX)
- nextmemberthreadnumber = vt_thread_numbers[nextmember]
- nextmemberthread = Thread("vt", vt_thread_numbers[nextmember])
- if nextmemberthread.is_closed or nextmemberthread.is_archived:
- nextmemberthreadnumber = 0
- vt_thread_numbers[nextmember] = nextmemberthreadnumber
- if img_counts[nextmember] == img_totals[nextmember]:
- random.shuffle(img_lists[nextmember])
- img_counts[nextmember] = 0
- make_pasta()
- first_pasta_attempt = False
- init_img_folders()
- find_vt_threads()
- loop_count = 0
- while True:
- loop_count += 1
- if loop_count > 33:
- find_vt_threads()
- loop_count = 0
- check_jp_thread()
- print("Current beg delay: " + str(BEG_DELAY))
- time.sleep(random.randint(BEG_DELAY, (BEG_DELAY + IPPUN)))
- element = driver.find_element(By.PARTIAL_LINK_TEXT, "Post a")
- element.click()
- time.sleep(IPPUN)
- if IMG_GENKAI_TOPPA:
- strain_the_pasta()
- element = driver.find_element(By.NAME, "com")
- element.send_keys(nextpastatext)
- else:
- nextmember = random.randint(0, CURRENT_MAX)
- nextbegimage = os.path.join(img_directories[nextmember],
- img_lists[nextmember][img_counts[nextmember]])
- element = driver.find_element(By.ID, "postFile")
- element.send_keys(nextbegimage)
- img_counts[nextmember] += 1
- element = driver.find_element(By.ID, "t-load")
- element.click()
- time.sleep(IPPUN)
- element = driver.find_element(By.ID, "t-resp")
- element.send_keys(Keys.RETURN)
- print("Posted it, lol. 30 sec wait...")
- time.sleep(ITTAN)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement