Answer the question
In order to leave comments, you need to log in
How to send message through TELEBOT proxy?
Good afternoon.
Please help me figure out how to send messages to TG using PROXY
My code is below
import telebot
from telebot import apihelper
apihelper.proxy = {'https':'socks5://login:[email protected]:port'}
TOKEN = 'token'
bot = telebot.TeleBot(TOKEN)
id_group_chat = -123
msg = 'test'
def sent_to_telegram(msg):
bot.send_message(id_group_chat, msg, parse_mode='HTML')
sent_to_telegram(msg)
Traceback (most recent call last):
File "C:/Users/Матвей/PycharmProjects/motya/sent_to_telegram.py", line 25, in <module>
sent_to_telegram(msg)
File "C:/Users/Матвей/PycharmProjects/motya/sent_to_telegram.py", line 23, in sent_to_telegram
bot.send_message(id_group_chat, msg, parse_mode='HTML')
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\telebot\__init__.py", line 598, in send_message
reply_markup, parse_mode, disable_notification))
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\telebot\apihelper.py", line 140, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\telebot\apihelper.py", line 54, in _make_request
timeout=(connect_timeout, read_timeout), proxies=proxy)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\adapters.py", line 337, in send
conn = self.get_connection(request.url, proxies)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\adapters.py", line 245, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\adapters.py", line 155, in proxy_manager_for
**proxy_kwargs)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\packages\urllib3\poolmanager.py", line 280, in proxy_from_url
return ProxyManager(proxy_url=url, **kw)
File "C:\Users\Матвей\PycharmProjects\motya\venv\lib\site-packages\requests\packages\urllib3\poolmanager.py", line 231, in __init__
'Not supported proxy scheme %s' % proxy.scheme
AssertionError: Not supported proxy scheme socks5
Answer the question
In order to leave comments, you need to log in
https://www.youtube.com/watch?v=CDFFfWOqVKs
see here how everything should be set up.
Find a working proxy, you may have to sort through a few pieces.
And the requests library should not be the latest, but versions like 2.10.0, the video says more precisely.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question