Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- 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. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement