Ошибка
Сам код:
Код:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 581, in infinity_polling
self.polling(none_stop=True, timeout=timeout, long_polling_timeout=long_polling_timeout,
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 629, in polling
self.__threaded_polling(non_stop, interval, timeout, long_polling_timeout, allowed_updates)
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 691, in __threaded_polling
raise e
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 650, in __threaded_polling
polling_thread.raise_exceptions()
File "/usr/local/lib/python3.8/dist-packages/telebot/util.py", line 107, in raise_exceptions
raise self.exception_info
File "/usr/local/lib/python3.8/dist-packages/telebot/util.py", line 89, in run
task(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 371, in __retrieve_updates
updates = self.get_updates(offset=(self.last_update_id + 1),
File "/usr/local/lib/python3.8/dist-packages/telebot/__init__.py", line 349, in get_updates
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
File "/usr/local/lib/python3.8/dist-packages/telebot/apihelper.py", line 328, in get_updates
return _make_request(token, method_url, params=payload)
File "/usr/local/lib/python3.8/dist-packages/telebot/apihelper.py", line 152, in _make_request
result = _get_req_session().request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 431, in send
raise ValueError(err)
ValueError: Invalid timeout (True, 25). Pass a (connect, read) timeout tuple, or a single float to set both timeouts to the same value
"
Сам код:
Код:
import telebot
from telebot import types
from threading import Thread
from rHLDS import Console
from config import token, ip, port, password
import traceback
bot = telebot.TeleBot(token)
srv = Console(host=ip, port=port, password=password)
srv.connect()
def read_user_list(id):
with open('users.txt', 'r', encoding='utf-8') as f:
for line in f:
if id in line:
return True
@bot.message_handler(content_types=['text'])
def start(m):
if(read_user_list(str(m.chat.id))):
msg = bot.send_message(m.chat.id, "1")
bot.register_next_step_handler(msg, command)
else:
bot.send_message(m.chat.id, '1')
def command(m):
if(read_user_list(str(m.chat.id))):
r = srv.execute("{}".format(m.text))
if len(r) > 0:
print(r)
msg = bot.send_message(m.chat.id, r, disable_web_page_preview = True)
else:
msg = bot.send_message(m.chat.id, '1')
bot.register_next_step_handler(msg, command)
else:
bot.send_message(m.chat.id, '1!')
def infinity_polling(self, *args, **kwargs):
while not self.__stop_polling.is_set():
try:
self.polling(*args, **kwargs)
except Exception as e:
time.sleep(5)
pass
logger.info("Break infinity polling")
Thread(target=bot.infinity_polling, args=(True,)).start()