コード例 #1
0
ファイル: bot.py プロジェクト: Gourav-raj/Class-Reminder
def joinclass(class_name, start_time, end_time):

    try_time = int(start_time.split(":")[1]) + 15
    try_time = start_time.split(":")[0] + ":" + str(try_time)

    now = datetime.now()
    cur_time = now.strftime("%H:%M")
    print(cur_time)
    if (cur_time >= start_time and cur_time < end_time):
        print("Class Joined")
        discord_webhook.send_msg(class_name=class_name,
                                 status="running",
                                 start_time=start_time,
                                 end_time=end_time)
        #now schedule leaving class
        tmp = "%H:%M"
        class_running_time = datetime.strptime(
            end_time, tmp) - datetime.strptime(cur_time, tmp)
        print(class_running_time)
        time.sleep(class_running_time.seconds)
        print("Class left")
        discord_webhook.send_msg(class_name=class_name,
                                 status="ended",
                                 start_time=start_time,
                                 end_time=end_time)
コード例 #2
0
ファイル: bot.py プロジェクト: Gourav-raj/Class-Reminder
def sched():
    #class start time 09:00
    tmp = "%H:%M"
    #cur_day
    cur_day = calendar.day_name[datetime.today().weekday()]
    if (cur_day == "Sunday" or cur_day == "Saturday"):
        print("To day is", cur_day, "no class today")
        discord_webhook.send_msg(class_name=cur_day,
                                 status="ended",
                                 start_time="No class",
                                 end_time="No class")
        cls_st = "09:00"
        cur_time = datetime.now().strftime("%H:%M")
        class_running_time = datetime.strptime(
            cls_st, tmp) - datetime.strptime(cur_time, tmp)
        time.sleep(abs(class_running_time).total_seconds())
        sched()

    #connect to sql
    conn = sqlite3.connect('my_database.db')
    c = conn.cursor()
    while True:
        time.sleep(1)
        cur_time = datetime.now().strftime("%H:%M")
        print(cur_time)
        min_time = '20:00'
        flg = 0
        for row in c.execute('SELECT * FROM timetable where day =?',
                             (cur_day, )):
            #schedule all classes
            name = row[0]
            start_time = row[1]
            end_time = row[2]
            day = row[3]
            print(start_time)
            if (cur_time >= start_time and cur_time <= end_time):
                joinclass(name, start_time, end_time)
                cur_time = datetime.now().strftime("%H:%M")
            if (end_time > cur_time):
                flg = 1
                min_time = min(start_time, min_time)
        if (flg == 0):
            print(cur_time)
            print("All classes done for today")
            break
        else:
            print(min_time)
            class_running_time = datetime.strptime(
                min_time, tmp) - datetime.strptime(cur_time, tmp)
            print(abs(class_running_time).total_seconds())
            time.sleep(abs(class_running_time).total_seconds())
            sched()

    cur_time = datetime.now().strftime("%H:%M")
    cls_st = "09:00"
    class_running_time = datetime.strptime(cls_st, tmp) - datetime.strptime(
        cur_time, tmp)
    time.sleep(abs(class_running_time).total_seconds())
    sched()
コード例 #3
0
def start():
	while True:
		try:
			print("iter")
			instagram = Instagram()
			instagram.with_credentials(insta_username, insta_password)
			instagram.login(force=False,two_step_verificator=True)
			sleep(2) # Delay to mimic user

			followers = []
			account = instagram.get_account(username)
			sleep(1)
			curr_time = datetime.datetime.now(timezone('Asia/Kolkata'))
			curr_time = curr_time.strftime("%b %d, %Y - %H:%M:%S")
			followers = instagram.get_followers(account.identifier, FOLLOWER_LIMIT, 100, delayed=True) # Get 150 followers of 'kevin', 100 a time with random delay between requests
			# print(followers)

			current_followers = []

			for follower in followers['accounts']:
				current_followers.append(follower.username)

			del followers

			if not path.exists("follower_list.txt"):
				f = open("follower_list.txt","w")
				f.write(str(current_followers))
				f.close()
			else:
				f = open("follower_list.txt","r+")
				old_followers = f.read()
				f.close()
				old_followers = ast.literal_eval(old_followers)

				unfollowers = check_unfollowers(current_followers,old_followers)
				followers = check_followers(current_followers,old_followers)

				follower_change  = len(current_followers)-len(old_followers)

				follow_count = len(followers)
				unfollow_count = len(unfollowers)

				discord_webhook.send_msg(username,follower_change,followers,unfollowers,follow_count,unfollow_count,curr_time,discord_webhook_url)

				f = open("follower_list.txt","w")
				f.write(str(current_followers))
				f.close()

			

		except KeyboardInterrupt:
			print("Exiting...")
			sys.exit(0)
		except Exception as e:
			print(e)

		sleep(MINS_TO_SLEEP*60)
コード例 #4
0
def submitForm(ip):
	global SUBMITTED_COUNT
	ip_port = ip

	if ip_port!="0":
		print("Using %s"%ip_port)
		logger.debug("Using %s"%ip_port)

	proxyDict = {"http":ip_port,"https":ip_port}

	s = requests.Session()
	uname_size = random.randint(5,10)
	uname = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k = uname_size))
	passwd_size = random.randint(8,20)
	passwd = ''.join(random.choices(string.ascii_uppercase + string.ascii_lowercase + string.digits, k = passwd_size))
	data = {'password':passwd}

	if ip_port == "0":
		# No proxy
		try:
			r = s.get(URL + "login.php?nick=%s"%(uname),headers=headers)
			r = s.post(URL + "login.php?nick=%s"%(uname),headers=headers,data=data)
			r = s.post(URL + "confirmed.php?",headers=headers)
		except Exception as e:
			# IP blocked or site is down
			print("Connection failed with no proxy")
			logger.error("Error - %s"%e)
			discord_webhook.send_msg(status='error',sent=SUBMITTED_COUNT,error="Connection with real IP failed - %s"%e)
			return 0


	else:
		# Use Proxy
		try:
			r = s.get(URL + "login.php?nick=%s"%(uname),headers=headers,proxies=proxyDict)
			r = s.post(URL + "login.php?nick=%s"%(uname),headers=headers,proxies=proxyDict,data=data)
			r = s.post(URL + "confirmed.php?",headers=headers,proxies=proxyDict)
		except Exception as e:
			print("Error - ",e)
			logger.error("Error - %s"%e)
			discord_webhook.send_msg(status='error',sent=SUBMITTED_COUNT,error="Proxy IP connection failed - %s"%e)
			return 0


	if r.status_code!=200:
		return 0

	if "We apologize for the problem you encountered" in r.text:
		print("Sent %s, %s successfully!"%(uname,passwd))
		SUBMITTED_COUNT+=1
		logger.info("Submitted %s, %s - %d"%(uname,passwd,SUBMITTED_COUNT))
		
		if SUBMITTED_COUNT%50==0:
			logger.info("SUBMITTED UNTIL NOW - %d"%SUBMITTED_COUNT)

	return 1
コード例 #5
0
def login():

    global link_driver
    count = 0

    #Logging in
    print("logging in")
    user_id = link_driver.find_element_by_id("txtusername")
    user_id.send_keys(user)
    paswd = link_driver.find_element_by_id("password")
    paswd.send_keys(password)

    time.sleep(1)
    link_driver.find_element_by_id("Submit").click()

    # Enter into G-learn

    timetable_btn = None
    while True:
        try:

            if ("https://login.gitam.edu/studentapps.aspx"
                    in link_driver.current_url):
                glearn_btn = WebDriverWait(link_driver, 10).until(
                    EC.presence_of_element_located((By.LINK_TEXT, "G-Learn")))
                glearn_btn.click()

            timetable_btn = WebDriverWait(link_driver, 60).until(
                EC.presence_of_element_located((By.LINK_TEXT, "My timetable")))
            timetable_btn.location_once_scrolled_into_view

            if not (type(timetable_btn) == type(None)):
                timetable_btn.click()
                break

        except:
            if count > 15:
                print('Looks like G-learn is down')

                # send msg to discord
                discord_webhook.send_msg(class_name='-',
                                         status="G-learn down",
                                         start_time='-',
                                         end_time='-',
                                         t_date='-')
                return

            time.sleep(15)
            print("trying again")
            count = count + 1
            link_driver.refresh()

    print('Logged in\n')
    time.sleep(5)
コード例 #6
0
ファイル: bot.py プロジェクト: vmc99/glearn-zoom-bot
def login():

    global driver
    count = 0

    #Logging in
    print("logging in")
    user_id = driver.find_element_by_id("txtusername")
    user_id.send_keys(user)
    paswd = driver.find_element_by_id("password")
    paswd.send_keys(password)

    time.sleep(1)
    driver.find_element_by_id("Submit").click()

    # Enter into G-learn

    class_table = None
    while True:
        try:
            if ("https://login.gitam.edu/studentapps.aspx"
                    in driver.current_url):
                glearn_btn = WebDriverWait(driver, 10).until(
                    EC.presence_of_element_located((By.LINK_TEXT, "G-Learn")))
                glearn_btn.click()

            class_table = WebDriverWait(driver, 60).until(
                EC.presence_of_element_located(
                    (By.XPATH,
                     "//div[@id='ContentPlaceHolder1_divlblonline']")))
            class_table.location_once_scrolled_into_view

            if not (type(class_table) == type(None)):
                break
        except:
            if count > 15:
                print('Looks like G-learn is down')

                # G-learn down send msg to discord
                discord_webhook.send_msg(class_name='-',
                                         status="G-learn down",
                                         start_time='-',
                                         end_time='-')
                return
            time.sleep(15)
            print("trying again")
            count = count + 1
            driver.refresh()

    print('Logged in')
    time.sleep(5)
コード例 #7
0
def check_ones(pincode):
    today = date.today()
    today = today.strftime("%d/%m/%Y")
    temp_url = URL + pincode + "&date=" + str(today)
    result = requests.get(temp_url)

    if (result.status_code != 200):
        print(
            "Sorry due to some techical reasons we cant access Vaccination Availability Info right now"
        )
        discord_webhook.send_msg(-1, [])
        return
    dict = result.json()
    if len(dict["sessions"]) == 0:
        discord_webhook.send_msg(0, [])
    else:
        print("Vaccines Available!!")
        print("Details are also sent to your Discord")
        discord_webhook.send_msg(-1, dict["sessions"])
コード例 #8
0
def joinclass(class_name, start_time, end_time):
    global driver

    try_time = int(start_time.split(":")[1]) + 15
    try_time = start_time.split(":")[0] + ":" + str(try_time)

    time.sleep(5)

    classes_available = driver.find_elements_by_class_name("name-channel-type")

    for i in classes_available:
        if class_name.lower() in i.get_attribute('innerHTML').lower():
            print("JOINING CLASS ", class_name)
            i.click()
            break

    time.sleep(4)

    try:
        joinbtn = driver.find_element_by_class_name("ts-calling-join-button")
        joinbtn.click()

    except:
        k = 1
        while (k <= 15):
            print("Join button not found, trying again")
            time.sleep(60)
            driver.refresh()
            joinclass(class_name, start_time, end_time)
            # schedule.every(1).minutes.do(joinclass,class_name,start_time,end_time)
            k += 1
        print("Seems like there is no class today.")
        discord_webhook.send_msg(class_name=class_name,
                                 status="noclass",
                                 start_time=start_time,
                                 end_time=end_time)

    time.sleep(4)
    webcam = driver.find_element_by_xpath(
        '//*[@id="page-content-wrapper"]/div[1]/div/calling-pre-join-screen/div/div/div[2]/div[1]/div[2]/div/div/section/div[2]/toggle-button[1]/div/button/span[1]'
    )
    if (webcam.get_attribute('title') == 'Turn camera off'):
        webcam.click()
    time.sleep(1)

    microphone = driver.find_element_by_xpath(
        '//*[@id="preJoinAudioButton"]/div/button/span[1]')
    if (microphone.get_attribute('title') == 'Mute microphone'):
        microphone.click()

    time.sleep(1)
    joinnowbtn = driver.find_element_by_xpath(
        '//*[@id="page-content-wrapper"]/div[1]/div/calling-pre-join-screen/div/div/div[2]/div[1]/div[2]/div/div/section/div[1]/div/div/button'
    )
    joinnowbtn.click()

    discord_webhook.send_msg(class_name=class_name,
                             status="joined",
                             start_time=start_time,
                             end_time=end_time)

    #now schedule leaving class
    tmp = "%H:%M"

    class_running_time = datetime.strptime(end_time, tmp) - datetime.strptime(
        start_time, tmp)

    time.sleep(class_running_time.seconds)

    driver.find_element_by_class_name("ts-calling-screen").click()

    driver.find_element_by_xpath(
        '//*[@id="teams-app-bar"]/ul/li[3]').click()  #come back to homepage
    time.sleep(1)

    driver.find_element_by_xpath('//*[@id="hangup-button"]').click()
    print("Class left")
    discord_webhook.send_msg(class_name=class_name,
                             status="left",
                             start_time=start_time,
                             end_time=end_time)
コード例 #9
0
ファイル: msbot.py プロジェクト: varunp2k/Teams-Bot
def joinclass(class_name,start_time,end_time):
	global mah

	try_time = int(start_time.split(":")[1]) + 15
	try_time = start_time.split(":")[0] + ":" + str(try_time)

	time.sleep(5)


	classes_available = mah.find_elements_by_class_name("name-channel-type")

	for i in classes_available:
		if class_name.lower() in i.get_attribute('innerHTML').lower():
			print("JOINING CLASS ",class_name)
			i.click()
			break


	time.sleep(4)


	try:
		joinbtn = mah.find_element_by_class_name("ts-calling-join-button")
		joinbtn.click()

	except:
		#join button not found
		#refresh every minute until found
		k = 1
		while(k<=15):
			print("Join button not found, trying again")
			time.sleep(60)
			mah.refresh()
			joinclass(class_name,start_time,end_time)
			# schedule.every(1).minutes.do(joinclass,class_name,start_time,end_time)
			k+=1
		print("Seems like there is no class today.")  
		discord_webhook.send_msg(class_name=class_name,status="noclass",start_time=start_time,end_time=end_time)
	time.sleep(6)
	webcam = mah.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/div/calling-pre-join-screen/div/div/div[2]/div[1]/div[2]/div/div/section/div[2]/toggle-button[1]/div/button/span[1]')
	if(webcam.get_attribute('title')=='Turn camera off'):
		webcam.click()
	time.sleep(2)

	microphone = mah.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/div/calling-pre-join-screen/div/div/div[2]/div[1]/div[2]/div/div/section/div[2]/toggle-button[2]/div/button/span[1]')
	if(microphone.get_attribute('title')=='Mute microphone'):
		microphone.click()
	time.sleep(1)   

	enter = mah.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/div[1]/div/calling-pre-join-screen/div/div/div[2]/div[1]/div[2]/div/div/section/div[1]/div/div/button')
	enter.click()
	print("CLASS JOINED ",class_name)

	discord_webhook.send_msg(class_name=class_name,status="joined",start_time=start_time,end_time=end_time)

	tmp = "%H:%M"

	class_running_time = datetime.strptime(end_time,tmp) - datetime.strptime(start_time,tmp)

	time.sleep(class_running_time.seconds)


	back = mah.find_element_by_id('app-bar-12a84919f-59d8-4441-a975-2a8c2643b741')
	back.click() #come back to homepage
	time.sleep(1)

	end = mah.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/div/multi-call-list/div/div/calling-monitor/div/div/div[2]/calling-unified-bar/section/div/div/div[2]/items-group/div/item-widget/push-button/div/button')
	end.click()
	print("Class left")
	discord_webhook.send_msg(class_name=class_name,status="left",start_time=start_time,end_time=end_time)
コード例 #10
0
ファイル: link_bot.py プロジェクト: vmc99/glearn-scraper
def sched():

    # Start browser
    print('browser started')
    global driver
    driver = webdriver.Chrome(ChromeDriverManager().install(),
                              options=opt,
                              service_log_path='NUL')
    driver.get(URL)
    WebDriverWait(driver, 10000).until(
        EC.visibility_of_element_located((By.TAG_NAME, 'body')))

    login('student_timetable')

    # Schedule all classes
    timetable = driver.find_elements_by_xpath(
        "//table[@id='ContentPlaceHolder1_grd1']/tbody/tr")
    columns = timetable[0].find_elements_by_tag_name('th')

    for i in range(len(timetable) + 1):

        for j in range(2, len(columns)):

            if i > 1:

                class_name_xpath = f"//table[@id='ContentPlaceHolder1_grd1']/tbody/tr[{i}]/td[{j}]"
                class_name = driver.find_element_by_xpath(
                    class_name_xpath).text
                if not class_name == "":

                    day_xpath = f"//table[@id='ContentPlaceHolder1_grd1']/tbody/tr[{i}]/td[{1}]"
                    day = driver.find_element_by_xpath(day_xpath).text

                    timings_xpath = f"//table[@id='ContentPlaceHolder1_grd1']/tbody/tr[{1}]/th[{j}]"
                    timings = driver.find_element_by_xpath(timings_xpath).text
                    timings_split = timings.split('to')
                    start_time = timings_split[0].strip()
                    end_time = timings_split[1].strip()

                    # To get the message 10 minutes before the class
                    tmp = "%H:%M"
                    msg_tmp = datetime.strptime(start_time, tmp)
                    ten_minutes = timedelta(minutes=10)
                    msg_time = msg_tmp - ten_minutes
                    msg_time = datetime.strftime(msg_time, tmp)

                    if day.lower() == "monday":
                        schedule.every().monday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "tuesday":
                        schedule.every().tuesday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "wednesday":
                        schedule.every().wednesday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "thursday":
                        schedule.every().thursday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "friday":
                        schedule.every().friday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "saturday":
                        schedule.every().saturday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )
                    if day.lower() == "sunday":
                        schedule.every().sunday.at(msg_time).do(
                            fetch_link, class_name, start_time, end_time)
                        print(
                            f"Scheduled class {class_name} on {day} at {start_time}"
                        )

                else:
                    continue

    print('All classes are fetched')

    count = 0
    while True:

        try:
            back_btn = WebDriverWait(driver, 10).until(
                EC.presence_of_element_located(
                    (By.XPATH, "//div[@class='col-md-12']//img[1]")))
            back_btn.click()
            class_table = WebDriverWait(driver, 60).until(
                EC.presence_of_element_located(
                    (By.XPATH,
                     "//div[@id='ContentPlaceHolder1_divlblonline']")))
            class_table.location_once_scrolled_into_view
            if not (type(class_table) == type(None)):
                break

        except:
            if count > 15:
                print('Looks like G-learn is down')

                # G-learn down send msg to discord
                discord_webhook.send_msg(class_name='-',
                                         link='-',
                                         status="G-learn down",
                                         date='-',
                                         start_time='-',
                                         end_time='-')
                break
            time.sleep(15)
            print("trying again")
            count = count + 1
            driver.refresh()

    while True:
        # Checks whether a scheduled task is pending to run or not
        schedule.run_pending()
        time.sleep(1)
コード例 #11
0
ファイル: link_bot.py プロジェクト: vmc99/glearn-scraper
def fetch_link(class_name, start_time, end_time):
    global driver

    try:
        driver.refresh()
        time.sleep(10)
        glearn_url = 'http://glearn.gitam.edu/student/welcome.aspx'
        if not ((glearn_url).lower() == (driver.current_url).lower()):
            print('glearn not loaded')
            login('glearn')

    except:
        driver.close()
        time.sleep(10)
        print('Browser closed, opening again')
        start_browser()

    # Today's date
    today_date = date.today()
    # Today's date converted to string
    date_string = today_date.strftime("%d-%b-%Y")
    count = 0
    check = False

    while True:

        # List is created
        classes_available = driver.find_elements_by_xpath(
            "//table[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr")

        for i in range(len(classes_available)):

            # Class name
            x_path1 = f"//*[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr[{i+1}]/td/a/div/h4"

            # date and time
            x_path2 = f"//table[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr[{i+1}]/td/a/div/h6"

            className = driver.find_element_by_xpath(x_path1).text
            date_time = driver.find_element_by_xpath(x_path2).text

            # Extract Time
            timing = extract_time(date_time)
            converted_time = convert_time(timing)

            # Extract Day
            temp = date_time.split()
            class_date = (temp[2].split("-"))[0]
            class_date = int(class_date)

            if start_time == converted_time and today_date.day == class_date:

                # Extract Date
                dat = date_time.split(':')
                dat = dat[1]

                check = True

                link = f"//tbody/tr[{i+1}]/td[1]/a"

                zoom_link = driver.find_element_by_xpath(link).get_attribute(
                    'href')
                time.sleep(5)

                # Send Link to Discord
                discord_webhook.send_msg(class_name=className,
                                         status="fetched",
                                         link=zoom_link,
                                         date=dat,
                                         start_time=start_time,
                                         end_time=end_time)
                break

        if check == False:

            if count > 15:
                print("No class")

                # NO class send msg to discord
                discord_webhook.send_msg(class_name=class_name,
                                         link='-',
                                         status="noclass",
                                         date=date_string,
                                         start_time=start_time,
                                         end_time=end_time)
                return

            print("Class not found, trying again")
            time.sleep(60)
            driver.refresh()
            count += 1
            time.sleep(3)

        if check == True:
            break

    time.sleep(5)
コード例 #12
0
def discord_notify():
	global SUBMITTED_COUNT
	discord_webhook.send_msg(status='info',sent=SUBMITTED_COUNT,error="")
コード例 #13
0
        print("i am waiting for the class: elapsed time " + str(tuna) + "s")
        tuna += 30
        schedule.run_pending()
        time.sleep(30)


if __name__ == "__main__":
    # joinclass("Maths","15:13","15:15","sunday")
    createDB()
    while True:
        op = int(
            input((
                "\n\n1. Start Bot \n2. View Timetable \n3. Update Timetable \n4. Add Class \n5. Delete Class\n6. Join Specific Class\n7. Exit\nEnter option : "
            )))
        if (op == 1):
            sched()
        elif (op == 2):
            view_timetable()
        elif (op == 3):
            update_timetable()
        elif (op == 4):
            add_timetable()
        elif (op == 5):
            delete_timetable()
        elif (op == 6):
            dw.send_msg('TEST', "testing", '00:00', '11:11')
            join_specific()
        else:
            print("Invalid input!")
            exit()
コード例 #14
0
def joinclass(class_name, start_time, end_time):
    # start_browser()
    global driver

    try_time = int(start_time.split(":")[1]) + 15
    try_time = start_time.split(":")[0] + ":" + str(try_time)

    classSearch = driver.find_element_by_xpath(
        '//*[@id="main-content-inner"]/div/div[1]/div[1]/div/div/div[1]/div/header/bb-search-box/div/input')
    classSearch.click()
    classSearch.send_keys(class_name)
    time.sleep(3)
    classbtn = driver.find_element_by_partial_link_text(class_name)
    classbtn.click()
    time.sleep(5)
    try:
      sessionlist = driver.find_element_by_id('sessions-list')
        courseRoomText = driver.find_element_by_xpath(
            '//*[@id="sessions-list"]/li[1]/a/span').get_attribute("innerText")
        print('str(courseRoomText): ' + str(courseRoomText))
        # TODO: find sessionlisttext when room created
        if str(courseRoomText) == "Course Room":
            sessionlist.click()
            clickRoom = driver.find_element_by_xpath(
                '//*[@id="sessions-list"]/li[2]/a')
            clickRoom.click()
            print("join button clicked!")
            print('Joining: ' + str(driver.find_element_by_xpath(
                '//*[@id="sessions-list"]/li[2]/a/span')))

            # options
            skipaudio = driver.find_element_by_xpath(
                """//*[@id="dialog-description-audio"]/div[3]/button""")
            skipaudio.click()
            skipvideo = driver.find_element_by_xpath(
                """//*[@id="techcheck-modal"]/button""")
            skipvideo.click()
            skiptutorial = driver.find_element_by_xpath(
                """//*[@id="announcement-modal-page-wrap"]/div/div[4]/button""")
            skiptutorial.click()
        elif str(courseRoomText) != "Course Room":
            clickRoom = driver.find_element_by_xpath(
                '//*[@id="sessions-list"]/li[1]/a')
            clickRoom.click()
            print('Joining: ' + str(driver.find_element_by_xpath(
                '//*[@id="sessions-list"]/li[1]/a/span')))
            # options
            skipaudio = driver.find_element_by_xpath(
                """//*[@id="dialog-description-audio"]/div[3]/button""")
            skipaudio.click()
            skipvideo = driver.find_element_by_xpath(
                """//*[@id="techcheck-modal"]/button""")
            skipvideo.click()
            skiptutorial = driver.find_element_by_xpath(
                """//*[@id="announcement-modal-page-wrap"]/div/div[4]/button""")
            skiptutorial.click()
    except:
        # join button not found
        # refresh every minute until found
        k = 1
        while(k <= 2):
            print("Join button not found, trying again")
            time.sleep(10)
            driver.refresh()
            joinclass(class_name, start_time, end_time)
            # schedule.every(1).minutes.do(joinclass,class_name,start_time,end_time)
            k += 1
        print("Seems like there is no class today.")
        discord_webhook.send_msg(
            class_name=class_name, status="noclass", start_time=start_time, end_time=end_time)

    discord_webhook.send_msg(
        class_name=class_name, status="joined", start_time=start_time, end_time=end_time)

    # now schedule leaving class
    tmp = "%H:%M"

    class_running_time = datetime.strptime(
        end_time, tmp) - datetime.strptime(start_time, tmp)

    time.sleep(class_running_time.seconds)
    driver.close()
    print("Class left")
    discord_webhook.send_msg(
        class_name=class_name, status="left", start_time=start_time, end_time=end_time)
コード例 #15
0
def start():
    iterno = 0
    while True:
        try:
            iterno = iterno + 1
            print("Checking For unfollows ")
            print("Loop No.", iterno)
            instagram = Instagram()
            instagram.with_credentials(insta_username, insta_password)
            instagram.login(force=False, two_step_verificator=True)
            sleep(2)

            followers = []
            account = instagram.get_account(username)
            sleep(2)
            curr_time = datetime.datetime.now(timezone('Asia/Kolkata'))
            curr_time = curr_time.strftime("%b %d, %Y - %H:%M:%S")
            followers = instagram.get_followers(account.identifier,
                                                10**6,
                                                150,
                                                delayed=True)

            current_followers = []

            for follower in followers['accounts']:
                current_followers.append(follower.username)

            del followers

            if not path.exists("Follower_List.txt"):
                f = open("Follower_List.txt", "w")
                f.write(str(current_followers))
                f.close()
            else:
                f = open("Follower_List.txt", "r+")
                old_followers = f.read()
                f.close()
                old_followers = ast.literal_eval(old_followers)

                unfollowers = check_unfollowers(current_followers,
                                                old_followers)
                followers = check_followers(current_followers, old_followers)

                follower_change = len(current_followers) - len(old_followers)

                follow_count = len(followers)
                unfollow_count = len(unfollowers)

                discord_webhook.send_msg(insta_username, insta_password,
                                         username, follower_change, followers,
                                         unfollowers, follow_count,
                                         unfollow_count, curr_time,
                                         discord_webhook_url, ufforuf, fof)

                f = open("Follower_List.txt", "w")
                f.write(str(current_followers))
                f.close()

        except KeyboardInterrupt:
            print("Exiting...")
            sys.exit(0)
        except Exception as e:
            print(e)

        sleep(SLEEP_MINS * 60)
コード例 #16
0
ファイル: bot.py プロジェクト: vmc99/glearn-zoom-bot
def join_class(class_name, start_time, end_time):
    global driver
    global driver2

    try:
        driver.refresh()
        time.sleep(10)

        glearn_url = 'http://glearn.gitam.edu/student/welcome.aspx'
        if not ((glearn_url).lower() == (driver.current_url).lower()):
            print('glearn not loaded')
            login()

    except:
        driver.close()
        time.sleep(10)
        print('browser closed, opening again')
        start_browser()

    # Today's date
    today_date = date.today()
    # Today's date converted to string
    date_string = today_date.strftime("%d-%b-%Y")
    count = 0
    check = False

    while True:

        # List is created
        classes_available = driver.find_elements_by_xpath(
            "//table[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr"
        )  # List is created

        for i in range(len(classes_available)):

            # Class name
            x_path1 = f"//*[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr[{i+1}]/td/a/div/h4"
            # date and time
            x_path2 = f"//table[@id='ContentPlaceHolder1_GridViewonline']/tbody/tr[{i+1}]/td/a/div/h6"

            className = driver.find_element_by_xpath(x_path1).text
            date_time = driver.find_element_by_xpath(x_path2).text

            # Extract Time
            timing = extract_time(date_time)
            converted_time = convert_time(timing)

            # Extract Day
            temp = date_time.split()
            class_date = (temp[2].split("-"))[0]
            class_date = int(class_date)

            if start_time == converted_time and today_date.day == class_date:

                check = True
                print("JOINING :", className)

                link = f"//tbody/tr[{i+1}]/td[1]/a"
                zoom_link = driver.find_element_by_xpath(link).get_attribute(
                    'href')
                time.sleep(5)

                # Using driver2 for opening zoom link

                driver2 = webdriver.Chrome(ChromeDriverManager().install(),
                                           options=opt2,
                                           service_log_path='NUL')
                driver2.get(zoom_link)
                WebDriverWait(driver2, 10000).until(
                    EC.visibility_of_element_located((By.TAG_NAME, 'body')))
                time.sleep(1)
                driver2.minimize_window()
                time.sleep(1)
                driver2.maximize_window()

                break

        if check == False:

            if count > 15:
                print("No class")

                # NO class send msg to discord
                discord_webhook.send_msg(class_name=class_name,
                                         status="noclass",
                                         start_time=start_time,
                                         end_time=end_time,
                                         t_date=date_string)
                return

            print("Class not found, trying again")
            time.sleep(60)
            driver.refresh()
            count += 1
            time.sleep(3)

        if check == True:
            break

    time.sleep(5)

    # open zoom

    loop_var = 0
    while loop_var < 10:

        open_zoom_btn = ImageDetection('Images/open_zoom.png', 0.75,
                                       'grayscale')

        if type(open_zoom_btn) == type(None):
            open_zoom_btn = ImageDetection('Images/open_zoom_dark.png', 0.75,
                                           'grayscale')

        if not (type(open_zoom_btn) == type(None)):
            pyautogui.moveTo(open_zoom_btn)
            pyautogui.click()
            break
        else:
            loop_var += 1
            time.sleep(1)

    if type(open_zoom_btn) == type(None):
        open_zoom_btn = ImageDetection('Images/open_zoom.png', 0.75, 'edged')

        if not (type(open_zoom_btn) == type(None)):
            pyautogui.moveTo(open_zoom_btn)
            pyautogui.click()

    # To join a new meeting if the previous meeting is still going on

    loop_var = 0
    while loop_var < 3:
        leave_join_btn = ImageDetection('Images/leave_join.png', 0.75,
                                        'grayscale')
        if not (type(leave_join_btn) == type(None)):
            pyautogui.moveTo(leave_join_btn)
            pyautogui.click()
            break
        else:
            loop_var += 1
            time.sleep(1)

    time.sleep(5)
    driver2.close()

    # after opening zoom desktop app

    Entered_class = join_audio(className, start_time, end_time, date_string)

    if Entered_class == False:
        print("looks like class is cancelled")

        # Class Cancelled send msg to discrod
        discord_webhook.send_msg(class_name=class_name,
                                 status="zoom_link down",
                                 start_time=start_time,
                                 end_time=end_time,
                                 t_date=date_string)
        return
コード例 #17
0
ファイル: bot.py プロジェクト: vmc99/glearn-zoom-bot
def join_audio(class_name, start_time, end_time, date_string):
    global driver
    count = 0

    while True:

        time.sleep(5)
        join_audio_btn = ImageDetection('Images/join_audio.png', 0.75,
                                        'grayscale')
        if not (type(join_audio_btn) == type(None)):
            pyautogui.moveTo(join_audio_btn)
            pyautogui.click()
            break

        else:

            if (count > 30):
                #Class Cancelled Exiting from function
                return False

            count += 1
            print('Join audio button not found, trying again')
            time.sleep(15)

    time.sleep(5)

    # Stop Video
    stop_video_btn = ImageDetection('Images/stop_video.png', 0.95, 'grayscale')
    if not (type(stop_video_btn) == type(None)):
        pyautogui.moveTo(stop_video_btn)
        pyautogui.click()

    # Mute Mic
    mute_btn = ImageDetection('Images/mute.png', 0.8, 'grayscale')
    if not (type(mute_btn) == type(None)):
        pyautogui.moveTo(mute_btn)
        pyautogui.click()

    # Moving mouse away from the meeting controls
    pyautogui.moveTo(x=960, y=540)

    tmp = "%H:%M"

    t = time.localtime()
    current_start_time = time.strftime(tmp, t)  # Current time

    print('Joined class')

    # Class joined send msg to discord
    discord_webhook.send_msg(class_name=class_name,
                             status="joined",
                             start_time=current_start_time,
                             end_time=end_time,
                             t_date=date_string)

    class_running_time = datetime.strptime(end_time, tmp) - datetime.strptime(
        current_start_time, tmp)

    # Sleep till class end time
    print("Waiting till the class ends")
    waiting_time = class_running_time.seconds
    time.sleep(waiting_time)

    leave_btn = ImageDetection('Images/leave.png', 0.8, 'grayscale')
    if not (type(leave_btn) == type(None)):
        pyautogui.moveTo(leave_btn)
        pyautogui.click()
    else:
        print('leave button not found')

    time.sleep(1)
    leave_meeting_btn = ImageDetection('Images/leave_meeting.png', 0.8,
                                       'grayscale')
    if not (type(leave_meeting_btn) == type(None)):
        pyautogui.moveTo(leave_meeting_btn)
        pyautogui.click()
    else:
        print('leave meeting button not found')

    print("Class left")

    t = time.localtime()
    current_end_time = time.strftime(tmp, t)  # Current time

    # Class left send msg to discord
    discord_webhook.send_msg(class_name=class_name,
                             status="left",
                             start_time=current_start_time,
                             end_time=current_end_time,
                             t_date=date_string)

    return True
コード例 #18
0
ファイル: a.py プロジェクト: Akathian/akathian.com
def start(request):
    request_json = request.get_json()
    insta_username = request_json['insta_username']
    insta_password = request_json['insta_password']
    username = request_json['username']
    discord_webhook_url = request_json['discord_webhook_url']
    try:
        instagram = Instagram()
        instagram.with_credentials(insta_username, insta_password)
        instagram.login(force=False, two_step_verificator=True)
        sleep(2)  # Delay to mimic user

        followers = []
        account = instagram.get_account(username)
        sleep(1)
        curr_time = datetime.datetime.now(timezone('US/Eastern'))
        curr_time = curr_time.strftime("%b %d, %Y - %H:%M:%S")
        followers = instagram.get_followers(
            account.identifier, FOLLOWER_LIMIT, 100, delayed=True
        )  # Get 150 followers of 'kevin', 100 a time with random delay between requests
        # print(followers)
        followings = instagram.get_following(account.identifier,
                                             FOLLOWER_LIMIT,
                                             100,
                                             delayed=True)

        current_followers = []
        current_followings = []

        for following in followings['accounts']:
            current_followings.append(following.username)

        for follower in followers['accounts']:
            current_followers.append(follower.username)

        del followers
        del followings
        not_follow_back = check_not_followback(current_followings,
                                               current_followers)
        if not path.exists(username + "_follower_list.txt"):
            f = open(username + "_follower_list.txt", "w")
            f.write(str(current_followers))
            f.close()
        else:
            f = open(username + "_follower_list.txt", "r+")
            old_followers = f.read()
            f.close()
            old_followers = ast.literal_eval(old_followers)

            unfollowers = check_unfollowers(current_followers, old_followers)
            followers = check_followers(current_followers, old_followers)

            follower_change = len(current_followers) - len(old_followers)

            follow_count = len(followers)
            unfollow_count = len(unfollowers)

            discord_webhook.send_msg(username, follower_change, followers,
                                     unfollowers, follow_count, unfollow_count,
                                     curr_time, discord_webhook_url,
                                     not_follow_back)
            retMap = {
                'username': username,
                'follower_change': follower_change,
                'followers': followers,
                'unfollowers': unfollowers,
                'follow_count': follow_count,
                'unfollow_count': unfollow_count,
                'curr_time': curr_time,
                'discord_webhook_url': discord_webhook_url,
                'not_follow_back': not_follow_back
            }

            f = open(username + "_follower_list.txt", "w")
            f.write(str(current_followers))
            f.close()
            retJson = json.dumps(retMap)

    except Exception as e:
        print(e)