D
D
Dmitry2019-08-07 19:09:23
Python
Dmitry, 2019-08-07 19:09:23

The telegram bot does not rise, is the reason for blocking?

Hello everyone
The bot does not rise on my PC, I suspect that the problem is in the provider
In any case, after googling, I came to this conclusion I threw a
proxy, but the proxy still does not work
, I used socks5 - socks5://132.456.789.012:25565 user pass

Log
2019-08-07 16:24:02,836 - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x03661BB0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:02,870 - WARNING - Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0C30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:02,904 - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0D30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:02,939 - ERROR - Error while bootstrap del webhook: urllib3 HTTPError SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot<TOKEN>/deleteWebhook (Caused by NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0E90>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
2019-08-07 16:24:02,939 - WARNING - Failed bootstrap phase; try=1 max_retries=-1
2019-08-07 16:24:10,475 - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0E30>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:10,519 - WARNING - Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x03661FB0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:10,566 - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0EB0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed')': /bot<TOKEN>/deleteWebhook
2019-08-07 16:24:10,601 - ERROR - Error while bootstrap del webhook: urllib3 HTTPError SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot<TOKEN>/deleteWebhook (Caused by NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x038B0DF0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed'))
2019-08-07 16:24:10,601 - WARNING - Failed bootstrap phase; try=2 max_retries=-1
2019-08-07 16:24:17,931 - INFO - Received signal 2 (SIGINT), stopping...
">

the code
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters

import logging

PROXY = {
    'proxy_url': 'my socks5 proxy url',
    'urllib3_proxy_kwargs': {
        'username': 'proxy user',
         'password': 'proxy pass'
    }
}

logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s',
    level=logging.INFO,
    filename='bot.log'
    )

def greet_user(bot, update):
    text = 'все работает!'
    logging.info(text)
    update.message.reply_text(text)

def talk_to_me(bot, updater):
    user_text = 'Привет {}! Ты написал : {}'.format(update.message.chat.first_name, update.message.text)
    logging.info('User: %s, Chat id: %s, Message: %s',
                update.message.chat.username,
                update.message.chat.id,
                update.message.text)
    update.message.replay_text(user_text)

def main():
    my_bot = Updater('token', request_kwargs=PROXY)
    
    #logging.info('bot is run')

    dp = my_bot.dispatcher
    dp.add_handler(CommandHandler('start', greet_user))
    dp.add_hendler(MessageHandler(Filters.text, talk_to_me))

    my_bot.start_polling()
    my_bot.idle()

main()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MainDel, 2019-08-07
@MainDel

You can use free VPN for computer.
If you want to put your bot on hosting, then most likely it will work there without a VPN and without a proxy

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question