Задать вопрос
owner228
@owner228

Почему бот перестал переключаться по бинду?

По мере роста кода бот перестал переключаться по бинду при нажатии на F8.

Код
pause = False
mistake_mode = False
alternate_mode = False

def toggle_pause():
    global pause
    pause = not pause

def toggle_mistake_mode():
    global mistake_mode
    mistake_mode = not mistake_mode

def toggle_alternate_mode():
    global alternate_mode
    alternate_mode = not alternate_mode

def introduce_mistakes(text):
    result = []
    for char in text:
        if random.random() < 0.1:
            if random.random() < 0.5:
                result.append('')
            else:
                result.append(random.choice('abcdefghijklmnopqrstuvwxyz'))
        else:
            result.append(char)
    return ''.join(result)

def main():
    global pause, mistake_mode, alternate_mode
    keyboard.add_hotkey('f4', toggle_pause)
    keyboard.add_hotkey('f2', toggle_mistake_mode)
    keyboard.add_hotkey('f8', toggle_alternate_mode)

    # Чтение строк из всех файлов
    with open("C:\\suptr spam bot\\слова1.txt", "r") as f1, \
            open("C:\\suptr spam bot\\слова2.txt", "r") as f2, \
            open("C:\\suptr spam bot\\слова3.txt", "r") as f3, \
            open("C:\\suptr spam bot\\слова4.txt", "r") as f4, \
            open("C:\\suptr spam bot\\слова5.txt", "r") as f5, \
            open("C:\\suptr spam bot\\слова6.txt", "r") as f6, \
            open("C:\\suptr spam bot\\слова8.txt", "r") as f8, \
            open("C:\\suptr spam bot\\слова9.txt", "r") as f9, \
            open("C:\\suptr spam bot\\слова10.txt", "r") as f10, \
            open("C:\\suptr spam bot\\слова11.txt", "r") as f11, \
            open("C:\\suptr spam bot\\слова12.txt", "r") as f12, \
            open("C:\\suptr spam bot\\слова13.txt", "r") as f13, \
            open("C:\\suptr spam bot\\ссс1.txt", "r") as s1, \
            open("C:\\suptr spam bot\\ссс2.txt", "r") as s2, \
            open("C:\\suptr spam bot\\ссс3.txt", "r") as s3, \
            open("C:\\suptr spam bot\\ссс4.txt", "r") as s4, \
            open("C:\\suptr spam bot\\ссс5.txt", "r") as s5, \
            open("C:\\suptr spam bot\\шшш1.txt", "r") as sh1, \
            open("C:\\suptr spam bot\\шшш2.txt", "r") as sh2, \
            open("C:\\suptr spam bot\\шшш3.txt", "r") as sh3:
        lines1 = f1.readlines()
        lines2 = f2.readlines()
        lines3 = f3.readlines()
        lines4 = f4.readlines()
        lines5 = f5.readlines()
        lines6 = f6.readlines()
        lines8 = f8.readlines()
        lines9 = f9.readlines()
        lines10 = f10.readlines()
        lines11 = f11.readlines()
        lines12 = f12.readlines()
        lines13 = f13.readlines()
        lines14 = s1.readlines()
        lines15 = s2.readlines()
        lines16 = s3.readlines()
        lines17 = s4.readlines()
        lines18 = s5.readlines()
        lines19 = sh1.readlines()
        lines20 = sh2.readlines()
        lines21 = sh3.readlines()

    with open("C:\\suptr spam bot\\слова7.txt", "r") as f7:
        lines7 = f7.readlines()

    with open("C:\\suptr spam bot\\бот1.txt", "r") as b1, \
            open("C:\\suptr spam bot\\бот2.txt", "r") as b2, \
            open("C:\\suptr spam bot\\бот3.txt", "r") as b3, \
            open("C:\\suptr spam bot\\бот4.txt", "r") as b4, \
            open("C:\\suptr spam bot\\бот5.txt", "r") as b5:
        bot_lines1 = b1.readlines()
        bot_lines2 = b2.readlines()
        bot_lines3 = b3.readlines()
        bot_lines4 = b4.readlines()
        bot_lines5 = b5.readlines()

    with open("C:\\suptr spam bot\\шабл.txt", "r") as s1, \
            open("C:\\suptr spam bot\\шабл2.txt", "r") as s2, \
            open("C:\\suptr spam bot\\шабл3.txt", "r") as s3, \
            open("C:\\suptr spam bot\\шабл4.txt", "r") as s4, \
            open("C:\\suptr spam bot\\шабл5.txt", "r") as s5, \
            open("C:\\suptr spam bot\\шабл6.txt", "r") as s6:
        template_lines1 = s1.readlines()
        template_lines2 = s2.readlines()
        template_lines3 = s3.readlines()
        template_lines4 = s4.readlines()
        template_lines5 = s5.readlines()
        template_lines6 = s6.readlines()

    random.shuffle(lines1)
    random.shuffle(lines2)
    random.shuffle(lines3)
    random.shuffle(lines4)
    random.shuffle(lines5)
    random.shuffle(lines6)
    random.shuffle(lines7)
    random.shuffle(lines8)
    random.shuffle(lines9)
    random.shuffle(lines10)
    random.shuffle(lines11)
    random.shuffle(lines12)
    random.shuffle(lines13)
    random.shuffle(lines14)
    random.shuffle(lines15)
    random.shuffle(lines16)
    random.shuffle(lines17)
    random.shuffle(lines18)
    random.shuffle(lines19)
    random.shuffle(lines20)
    random.shuffle(lines21)
    random.shuffle(bot_lines1)
    random.shuffle(bot_lines2)
    random.shuffle(bot_lines3)
    random.shuffle(bot_lines4)
    random.shuffle(bot_lines5)
    random.shuffle(template_lines1)
    random.shuffle(template_lines2)
    random.shuffle(template_lines3)
    random.shuffle(template_lines4)
    random.shuffle(template_lines5)
    random.shuffle(template_lines6)

    i = 0
    while True:
        if pause:
            time.sleep(0.2)
        else:
            if alternate_mode:
                if random.choice([True, False]):
                    line1 = bot_lines1[i % len(bot_lines1)].strip()
                    line2 = bot_lines2[i % len(bot_lines2)].strip()
                    line3 = bot_lines3[i % len(bot_lines3)].strip()
                    line = f"{line1} {line2} {line3}"
                else:
                    line4 = bot_lines4[i % len(bot_lines4)].strip()
                    line5 = bot_lines5[i % len(bot_lines5)].strip()
                    line = f"{line4} {line5}"
            else:
                choice = random.choice([1, 2, 3, 4, 5, 6])
                if choice == 1:
                    line1 = lines1[i % len(lines1)].strip()
                    line2 = lines2[i % len(lines2)].strip()
                    line3 = lines3[i % len(lines3)].strip()
                    line4 = lines4[i % len(lines4)].strip()
                    line5 = lines5[i % len(lines5)].strip()
                    line6 = lines6[i % len(lines6)].strip()
                    line = f"{line1} {line2} {line3} {line4} {line5} {line6}"
                elif choice == 2:
                    line8 = lines8[i % len(lines8)].strip()
                    line9 = lines9[i % len(lines9)].strip()
                    line10 = lines10[i % len(lines10)].strip()
                    line = f"{line8} {line9} {line10}"
                elif choice == 3:
                    line11 = lines11[i % len(lines11)].strip()
                    line12 = lines12[i % len(lines12)].strip()
                    line13 = lines13[i % len(lines13)].strip()
                    line = f"{line11} {line12} {line13}"
                elif choice == 4:
                    line14 = lines14[i % len(lines14)].strip()
                    line15 = lines15[i % len(lines15)].strip()
                    line16 = lines16[i % len(lines16)].strip()
                    line17 = lines17[i % len(lines17)].strip()
                    line18 = lines18[i % len(lines18)].strip()
                    line = f"{line14} {line15} {line16} {line17} {line18}"
                elif choice == 5:
                    line19 = lines19[i % len(lines19)].strip()
                    line20 = lines20[i % len(lines20)].strip()
                    line21 = lines21[i % len(lines21)].strip()
                    line = f"{line19} {line20} {line21}"
                else:
                    line14 = template_lines1[i % len(template_lines1)].strip()
                    line15 = template_lines2[i % len(template_lines2)].strip()
                    line16 = template_lines3[i % len(template_lines3)].strip()
                    line17 = template_lines4[i % len(template_lines4)].strip()
                    line18 = template_lines5[i % len(template_lines5)].strip()
                    line19 = template_lines6[i % len(template_lines6)].strip()
                    line = f"{line14} {line15} {line16} {line17} {line18} {line19}"

                if mistake_mode:
                    line = introduce_mistakes(line)

                i += 1

                pyautogui.typewrite(line, 0.05)
                pyautogui.press("enter")
                # time.sleep(random.uniform(2, 10))
            time.sleep(0.0001)

main()
  • Вопрос задан
  • 53 просмотра
Подписаться 1 Простой Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
03 янв. 2025, в 10:40
2000 руб./за проект
03 янв. 2025, в 10:37
500000 руб./за проект
03 янв. 2025, в 10:35
45000 руб./за проект