I am developing a bot telegram, for the company that I work, the problem is that I can not have an input or output, because the connection is conditioned by proxy, but from browsers if I have access to the internet.
Now try to configure the ip of the proxy, next to the port and the user, but it is conditioned access only to browsers.
Note: The Python app must be running on the company's internal server, so an external server is not feasible.
Edit:
Here is a piece of code with which I try to make a request to an external server:
from django.shortcuts import render
from django.http import HttpResponse
import telebot
# import socket
import urllib.request
proxy = urllib.request.ProxyHandler({'http': 'http://USUARIO:PASS#@IP:PUERTO_CONEXIÓN'})
auth = urllib.request.HTTPBasicAuthHandler()
opener = urllib.request.build_opener(proxy, auth, urllib.request.HTTPHandler)
urllib.request.install_opener(opener)
conn = urllib.request.urlopen('http://telegram.org')
return_str = conn.read()
# Ponemos nuestro TOKEN generado con el @BotFather
TOKEN = 'TOKEN DEL BOT'
# Creamos nuestra instancia "mi_bot" a partir de ese TOKEN
mi_bot = telebot.TeleBot(TOKEN)
def listener(*mensajes): # #Cuando llega un mensaje se ejecuta esta función
for m in mensajes:
chat_id = m.chat.id
if m.content_type == 'text':
text = m.text
mi_bot.send_message(ID_CHAT, "envio un mensaje al azar")
mi_bot.send_message(ID_CHAT, text)
mi_bot.set_update_listener(listener) # registrar la funcion listener
mi_bot.polling()
while True: # No terminamos nuestro programa
pass
The result:
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 407: Proxy Autentication Required ( Forefront TMG requires authorization to fulfill the request. Acces to the Web proxy filter is denied. )