Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:14:34) [MSC v.1900 32 bit (Intel)] on win32
- Type "copyright", "credits" or "license()" for more information.
- >>> from telegram.ext import Updater
- >>> updater = Updater(token = "400375324:AAHViaYS702JsUxgGomla7O_i4sDhMH1IBo")
- >>> dispatcher = updater.dispacher
- Traceback (most recent call last):
- File "<pyshell#2>", line 1, in <module>
- dispatcher = updater.dispacher
- AttributeError: 'Updater' object has no attribute 'dispacher'
- >>> dispatcher = updater.dispatcher
- >>> import logging
- >>> logging.basicConfig(format="%(asctime)s - %(name) - %(levelname)s - %(message)s", level = logging.info)
- Traceback (most recent call last):
- File "<pyshell#5>", line 1, in <module>
- logging.basicConfig(format="%(asctime)s - %(name) - %(levelname)s - %(message)s", level = logging.info)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 1799, in basicConfig
- root.setLevel(level)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 1282, in setLevel
- self.level = _checkLevel(level)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\logging\__init__.py", line 198, in _checkLevel
- raise TypeError("Level not an integer or a valid string: %r" % level)
- TypeError: Level not an integer or a valid string: <function info at 0x039878A0>
- >>> logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level = logging.info)
- >>> def start(bot, update):
- bot.send_message(chat_id = update.message.chat_id, text = "I'm a bot, please talk to me!")
- >>> from telegram.ext import CommandHandler
- >>> start_handler = CommandHandler("start", start)
- >>> dispatcher.add_handler(start_handler)
- >>> updater.start_polling()
- <queue.Queue object at 0x03BD0C30>
- >>> def echo(bot, update):
- bot.send_message(chat_id = update.message.chat_id, text = update.message.text)
- >>> from telegram.ext import MessageHandler, Filters
- >>> echo_handler = MessageHandler(Filters.text, echo)
- >>> dispatcher.add_handler(echo_handler)
- >>> def caps(bot, update,args):
- text_caps = " ".join(args).upper()
- bot.send_message(chat_id = update.message.chat_id, text = text_caps)
- >>> caps_handler = CommandHandler("caps", caps, pass_args = True)
- >>> dispatcher.add_handler(caps_handler)
- >>> 2017-12-11 17:31:53,993 - %(levelname)s - A TelegramError was raised while processing the Update
- 2017-12-11 17:31:54,030 - %(levelname)s - No error handlers are registered, logging exception...
- Traceback (most recent call last):
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\ext\dispatcher.py", line 279, in process_update
- handler.handle_update(update, self)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\ext\commandhandler.py", line 171, in handle_update
- return self.callback(dispatcher.bot, update, **optional_args)
- File "<pyshell#23>", line 3, in caps
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\bot.py", line 60, in decorator
- result = func(self, *args, **kwargs)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\bot.py", line 85, in decorator
- result = self._request.post(url, data, timeout=kwargs.get('timeout'))
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\utils\request.py", line 272, in post
- **urlopen_kwargs)
- File "C:\Users\Rhys\AppData\Local\Programs\Python\Python36-32\lib\site-packages\telegram\utils\request.py", line 210, in _request_wrapper
- raise BadRequest(message)
- telegram.error.BadRequest: Message text is empty
- >>> from telegram import InlineQueryResultArticle, InputTextMessageContent
- >>> def inline_caps(bot,update):
- query = update.inline_query.query
- if not query:
- return
- results = list()
- results.append(
- InlineQueryResultArticle(
- id = query.upper(),
- title = "Caps",
- input_message_content = InputTextMessageContent(query.upper())
- )
- )
- bot.answer_inline_query(update.inline_query.id, results)
- >>> from telegram.ext import InlineQueryHandler
- >>> inline_caps_handler = InlineQueryHandler(inline_caps)
- >>> dispatcher.add_handler(inline_caps_handler)
- >>> updater.stop()
- >>>
Add Comment
Please, Sign In to add comment