@alwaysneedhelp

Почему не принимает сообщение?

Мой бот почему то отказывается обрабатывать сообщение(написан на aiogram).
from aiogram import Bot,types
from aiogram.dispatcher import Dispatcher 
from aiogram.utils import executor
import selenium
import selenium.webdriver.support.ui as ui
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
import time
import requests
import random
from bs4 import BeautifulSoup as bs
c = 0

def get_free_proxies():
    url = "site"
    # получаем ответ HTTP и создаем объект soup
    global proxies
    proxies = bs(requests.get(url).content, "html.parser")
    proxies = str(proxies)
    proxies = proxies.split(' ')
    proxies = str(proxies)
    proxies = proxies.split(f'\\n')
    return proxies
    	






#command of watching video
def watch_video(c):
	#login
	opts = Options()
	opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36")
	proxies = get_free_proxies()
	opts.add_argument('--proxy-server=%s' % proxies[c])
	driver = webdriver.Chrome(chrome_options=opts, executable_path=r'C:\Users\s-isroilov\Desktop\chromedriver.exe')
	driver.get('https://accounts.google.com/signup/v2/webcreateaccount?biz=false&cc=UZ&continue=https%3A%2F%2Fwww.google.com%2Fsearch%3Fq%3Dzaregatsya%26oq%3Dzaregatsya%26aqs%3Dchrome..69i57.2411j0j1%26sourceid%3Dchrome%26ie%3DUTF-8&dsh=S2080565863%3A1665468718327866&flowEntry=SignUp&flowName=GlifWebSignIn&hl=ru&ifkv=AQDHYWqdgbDaL-9wueIt0CeC5_kNMk4ufHCDs3oVXbzjDofs2pskEKXgR_t-iOrPzD11RFgI5nDVzw')
	c = 0
	while c != 10:
		driver.implicitly_wait(10)
		email = sdriver.find_element_by_id('identifierId')
		email.send_keys('gmail')
		nextBtn = sdriver.find_element_by_id('identifierNext')
		nextBtn.click()
		driver.implicitly_wait(5)
		try:
			driver.find_element_by_name("Passwd").send_keys("password")
			driver.find_element_by_id("passwordNext").click()#clicking next
			c = 10
		except:
			element = driver.find_element_by_id('next')
			element.click()
			continue
					#_______

		#timer
	driver.get(url)
	#subscribing
	driver.implicitly_wait(1000)
	sub = driver.find_element_by_id('subscribe-button').click()
	driver.implicitly_wait(10000)
	if driver.find_element_by_id('cancel-button')!=None:
		driver.find_element_by_id('cancel-button').click()
	while True:
		driver.implicitly_wait(1000000)
		if driver.find_element_by_class_name('ytp-autonav-endscreen-upnext-thumbnail') !=None:
			return 1
		else:
			continue




bot = Bot('TOKEN')
dp = Dispatcher(bot)




#telegram bot

@dp.message_handler(commands = ['start', 'help'])


async def start(message : types.Message):
	await message.reply('Use command /watch')




@dp.message_handler(commands = ['watch'])




async def new_message(message: types.Message):
	await message.reply('Enter the link to the video')



@dp.message_handler()


async def ok(message: types.Message):
	await message.reply('Now enter how many times shall I need to watch?(just a number)')
	global url
	url = message.text	


@dp.message_handler(text=(int))


async def nevermind(message:types.Message):
	global times
	times = int(message.text)
	if times>100:
		await message.reply('Enter number less then 100(now restart me with command /watch)')
	try:
		p = Pool(times)
		p.map(watch_video, list(range(0,len(proxies))))
	except:
		await message.reply('I said just a number(now write /watch again')






executor.start_polling(dp, skip_updates=True)

*скрин*
634671032d67b662064687.png
  • Вопрос задан
  • 163 просмотра
Решения вопроса 2
Vindicar
@Vindicar
RTFM!
text=(int)
Это не будет работать.
Учи, как пользоваться реализацией FSM (finite state machine) в aiogram.
Ответ написан
Комментировать
Тебе нужно убрать text=(int), и сделать проверку на число внутри хэндлера
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

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

Похожие вопросы