Guest User

Untitled

a guest
Dec 13th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.20 KB | None | 0 0
  1. Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
  2. Type "copyright", "credits" or "license()" for more information.
  3. >>> from telegram.ext import Updater
  4. >>> updater = Updater(token = "400375324:AAHViaYS702JsUxgGomla7O_i4sDhMH1IBo")
  5. >>> dispatcher = updater.dispacher
  6. Traceback (most recent call last):
  7. File "<pyshell#2>", line 1, in <module>
  8. dispatcher = updater.dispacher
  9. AttributeError: 'Updater' object has no attribute 'dispacher'
  10. >>> dispatcher = updater.dispatcher
  11. >>> import logging
  12. >>> logging.basicConfig(format="%(asctime)s - %(name) - %(levelname)s - %(message)s", level = logging.info)
  13. Traceback (most recent call last):
  14. File "<pyshell#5>", line 1, in <module>
  15. logging.basicConfig(format="%(asctime)s - %(name) - %(levelname)s - %(message)s", level = logging.info)
  16. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 1799, in basicConfig
  17. root.setLevel(level)
  18. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 1282, in setLevel
  19. self.level = _checkLevel(level)
  20. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 198, in _checkLevel
  21. raise TypeError("Level not an integer or a valid string: %r" % level)
  22. TypeError: Level not an integer or a valid string: <function info at 0x039878A0>
  23. >>> logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level = logging.info)
  24. >>> def start(bot, update):
  25. bot.send_message(chat_id = update.message.chat_id, text = "I'm a bot, please talk to me!")
  26.  
  27.  
  28. >>> from telegram.ext import CommandHandler
  29. >>> start_handler = CommandHandler("start", start)
  30. >>> dispatcher.add_handler(start_handler)
  31. >>> updater.start_polling()
  32. <queue.Queue object at 0x03BD0C30>
  33. >>> def echo(bot, update):
  34. bot.send_message(chat_id = update.message.chat_id, text = update.message.text)
  35.  
  36.  
  37. >>> from telegram.ext import MessageHandler, Filters
  38. >>> echo_handler = MessageHandler(Filters.text, echo)
  39. >>> dispatcher.add_handler(echo_handler)
  40. >>> def caps(bot, update,args):
  41. text_caps = " ".join(args).upper()
  42. bot.send_message(chat_id = update.message.chat_id, text = text_caps)
  43.  
  44.  
  45. >>> caps_handler = CommandHandler("caps", caps, pass_args = True)
  46. >>> dispatcher.add_handler(caps_handler)
  47. >>> 2017-12-11 17:31:53,993 - %(levelname)s - A TelegramError was raised while processing the Update
  48. 2017-12-11 17:31:54,030 - %(levelname)s - No error handlers are registered, logging exception...
  49. Traceback (most recent call last):
  50. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\ext\dispatcher.py", line 279, in process_update
  51. handler.handle_update(update, self)
  52. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\ext\commandhandler.py", line 171, in handle_update
  53. return self.callback(dispatcher.bot, update, **optional_args)
  54. File "<pyshell#23>", line 3, in caps
  55. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\bot.py", line 60, in decorator
  56. result = func(self, *args, **kwargs)
  57. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\bot.py", line 85, in decorator
  58. result = self._request.post(url, data, timeout=kwargs.get('timeout'))
  59. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\utils\request.py", line 272, in post
  60. **urlopen_kwargs)
  61. File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\utils\request.py", line 210, in _request_wrapper
  62. raise BadRequest(message)
  63. telegram.error.BadRequest: Message text is empty
  64.  
  65. >>> from telegram import InlineQueryResultArticle, InputTextMessageContent
  66. >>> def inline_caps(bot,update):
  67. query = update.inline_query.query
  68. if not query:
  69. return
  70. results = list()
  71. results.append(
  72. InlineQueryResultArticle(
  73. id = query.upper(),
  74. title = "Caps",
  75. input_message_content = InputTextMessageContent(query.upper())
  76. )
  77. )
  78. bot.answer_inline_query(update.inline_query.id, results)
  79.  
  80.  
  81. >>> from telegram.ext import InlineQueryHandler
  82. >>> inline_caps_handler = InlineQueryHandler(inline_caps)
  83. >>> dispatcher.add_handler(inline_caps_handler)
  84. >>> updater.stop()
  85. >>>
Add Comment
Please, Sign In to add comment