How to skip and at the same time attend a lecture or "Python bot learns for me"

A little introductory

: 5/2, 8/. (, ) , - - , – . , - , , . , python -, :





  • ;





  • ;





  • ;





  • .





, . . – . - «».





Microsoft Teams , , , . , -, . .





pyautogui. , , , , , - . : , pyautogui , , .





:





def find_element(element):
    """    """
    sleep(1)
    r = None
    count = 100
    while r is None:
        count -= 1
        r = pyautogui.locateOnScreen(dir_true_files + element, confidence=0.7)
        print(count)
        if count == 0:
            print(element + '  !')
            break
        else:
            if r != None:
                print(element + ' !')
                return r
            else:
                continue
      
      



pyautogui «100» 70% .





:





def press_key(key):
    """  """
    sleep(1)
    pyautogui.press(key)


def write_text(text):
    """ """
    sleep(1)
    pyautogui.write(text, interval=0.2)


def create_screenshot(screens_directory, name):
    """ """
    sleep(1)
    im1 = pyautogui.screenshot()
    screenshot = im1.save(screens_directory + name)
    return screenshot
      
      



, , , – 09.00 12.00 « !», 12.00 17.00 « !», 17.00 21.00 « !». , n , – [‘ ?’, ‘ ’, ‘ !’, ‘ , ’, ‘ ’] .. – .





OBS. . , ffmpeg, . « ». , , OBS, pyautogui .





def active_window(title):
    """       """
    sleep(1)
    app = Application().connect(title_re=title, backend='win32')
    app.window(title_re=title).set_focus()
    sleep(3)
      
      



, MS Teams , . ?





-, . @BotFather. , telebot. , , – .





MS Teams? selenium. «Open Microsoft Teams»:





def site_desktop(url):
    chrome_options = webdriver.ChromeOptions()
    driver = webdriver.Chrome(executable_path=driver_chrome, options=chrome_options)
    driver.set_window_size(1920, 1080)
    driver.get(url)
    find_and_click('/open_team.png')
    sleep(3)
    driver.close()
      
      



, , ( 9.00, 10.40 ..) , ‘https://’, .





, url, :





  1. selenium chrome driver ;





  2. " Microsoft Teams";





  3. MS Teams, - /. , ;





  4. ;





  5. OBS, , ;





  6. 90 ;





  7. , ;





  8. OBS, , ;





  9. . .





bot = telebot.TeleBot(bot_token)


@bot.message_handler(content_types=['text'])
def get_text_messages(message):
    if message.text:
        try:
            bot.send_message(message.chat.id, text='   ')
            txt = message.text
            site_desktop(txt)
            find_and_click('/disable_micro.png')
            if find_element('/micro_status_on.png'):
                find_and_click('/disable_micro.png')
            find_and_click('/apply_study.png')
            active_window('OBS')
            press_key('f7')
            sleep(3)

            create_screenshot(dir_to_save_fail_screen, name_fail_screen)
            bot.send_photo(message.chat.id, open(dir_to_save_fail_screen + name_fail_screen, 'rb'))
            bot.send_message(message.chat.id, text='  ,   ')

            #   90  == 5400
            sleep(5400)

            bot.send_message(message.chat.id, text='   ,   , ')
            active_window('OBS')
            press_key('f8')
            sleep(3)

            find_and_click('/exit.png')
            bot.send_message(message.chat.id, text=' ')
        except Exception as e:
            bot.send_message(message.chat.id, text=' + ' + str(e))


bot.polling()
      
      



, 90 time.sleep, , , , . OBS MS Teams , . .





, - ( , ):





ZY I in no way urge you to skip lessons / pairs in this way - learning is light! But, alas, Russian education partly consists of archaic lectures from the times of the Soviet Union, the exhaust from which ... a little more than none. And such a robot will allow at least partially to unload and switch to something more useful and productive.








All Articles