Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. from django.shortcuts import render
  2. from django.http import HttpResponse
  3. import telebot
  4. # import socket
  5. import urllib.request
  6.  
  7. proxy = urllib.request.ProxyHandler({'http': 'http://USUARIO:PASS#@IP:PUERTO_CONEXIÓN'})
  8. auth = urllib.request.HTTPBasicAuthHandler()
  9. opener = urllib.request.build_opener(proxy, auth, urllib.request.HTTPHandler)
  10. urllib.request.install_opener(opener)
  11.  
  12. conn = urllib.request.urlopen('http://telegram.org')
  13. return_str = conn.read()
  14.  
  15. # Ponemos nuestro TOKEN generado con el @BotFather
  16. TOKEN = 'TOKEN DEL BOT'
  17. # Creamos nuestra instancia "mi_bot" a partir de ese TOKEN
  18. mi_bot = telebot.TeleBot(TOKEN)
  19.  
  20.  
  21. def listener(*mensajes): # #Cuando llega un mensaje se ejecuta esta función
  22. for m in mensajes:
  23. chat_id = m.chat.id
  24. if m.content_type == 'text':
  25. text = m.text
  26. mi_bot.send_message(ID_CHAT, "envio un mensaje al azar")
  27. mi_bot.send_message(ID_CHAT, text)
  28.  
  29.  
  30. mi_bot.set_update_listener(listener) # registrar la funcion listener
  31. mi_bot.polling()
  32.  
  33. while True: # No terminamos nuestro programa
  34. pass
  35.  
  36. raise HTTPError(req.full_url, code, msg, hdrs, fp)
  37. 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