We have made you a wrapper you can't refuse

Overview
python-telegram-bot Logo

We have made you a wrapper you can't refuse

We have a vibrant community of developers helping each other in our Telegram group. Join us!

Stay tuned for library updates and new releases on our Telegram Channel.

PyPi Package Version Supported Python versions Supported Bot API versions PyPi Package Monthly Download Documentation Status LGPLv3 License Github Actions workflow Code coverage Median time to resolve an issue Code quality: Codacy Code quality: DeepSource Telegram Group

Table of contents

Introduction

This library provides a pure Python interface for the Telegram Bot API. It's compatible with Python versions 3.6.8+. PTB might also work on PyPy, though there have been a lot of issues before. Hence, PyPy is not officially supported.

In addition to the pure API implementation, this library features a number of high-level classes to make the development of bots easy and straightforward. These classes are contained in the telegram.ext submodule.

A pure API implementation without telegram.ext is available as the standalone package python-telegram-bot-raw. See here for details.

Note

Installing both python-telegram-bot and python-telegram-bot-raw in conjunction will result in undesired side-effects, so only install one of both.

Telegram API support

All types and methods of the Telegram Bot API 5.6 are supported.

Installing

You can install or upgrade python-telegram-bot with:

$ pip install python-telegram-bot --upgrade

Or you can install from source with:

$ git clone https://github.com/python-telegram-bot/python-telegram-bot --recursive
$ cd python-telegram-bot
$ python setup.py install

In case you have a previously cloned local repository already, you should initialize the added urllib3 submodule before installing with:

$ git submodule update --init --recursive

Optional Dependencies

PTB can be installed with optional dependencies:

  • pip install python-telegram-bot[passport] installs the cryptography library. Use this, if you want to use Telegram Passport related functionality.
  • pip install python-telegram-bot[ujson] installs the ujson library. It will then be used for JSON de- & encoding, which can bring speed up compared to the standard json library.
  • pip install python-telegram-bot[socks] installs the PySocks library. Use this, if you want to work behind a Socks5 server.

Getting started

Our Wiki contains a lot of resources to get you started with python-telegram-bot:

Other references:

Learning by example

We believe that the best way to learn this package is by example. Here are some examples for you to review. Even if it is not your approach for learning, please take a look at echobot.py, it is the de facto base for most of the bots out there. Best of all, the code for these examples are released to the public domain, so you can start by grabbing the code and building on top of it.

Visit this page to discover the official examples or look at the examples on the wiki to see other bots the community has built.

Logging

This library uses the logging module. To set up logging to standard output, put:

import logging
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')

at the beginning of your script.

You can also use logs in your application by calling logging.getLogger() and setting the log level you want:

logger = logging.getLogger()
logger.setLevel(logging.INFO)

If you want DEBUG logs instead:

logger.setLevel(logging.DEBUG)

Documentation

python-telegram-bot's documentation lives at readthedocs.io.

Getting help

You can get help in several ways:

  1. We have a vibrant community of developers helping each other in our Telegram group. Join us!
  2. Report bugs, request new features or ask questions by creating an issue or a discussion.
  3. Our Wiki pages offer a growing amount of resources.
  4. You can even ask for help on Stack Overflow using the python-telegram-bot tag.

Contributing

Contributions of all sizes are welcome. Please review our contribution guidelines to get started. You can also help by reporting bugs.

Donating

Occasionally we are asked if we accept donations to support the development. While we appreciate the thought, maintaining PTB is our hobby and we have almost no running costs for it. We therefore have nothing set up to accept donations. If you still want to donate, we kindly ask you to donate to another open source project/initiative of your choice instead.

License

You may copy, distribute and modify the software provided that modifications are described and licensed for free under LGPL-3. Derivatives works (including modifications or anything statically linked to the library) can only be redistributed under LGPL-3, but applications that use the library don't have to be.

Comments
  • Type-hinting for IDEs

    Type-hinting for IDEs

    Hi there,

    I like to use the Message.reply_* functions but it's kind of annoying to always look up the parameters manually. There is a lack of type-hinting here. And with python stub files (or type hinting in the python files directly this would not be a problem at all.

    The Problem is, if I have a update instance and I call update.message it doesn't know that this is a Message instance. If I tell my IDE using message = update.message # type: Message it works so far. But when I then type message.reply_text( there is no type-hinting (or variable hinting for that matter) for the named parameters. This is annoying.

    I started to create python stub files like this: message-type-hint

    But it would be awesome if type-hinting a la PEP-484 would be integrated in the project itself.

    I know that python 2 compatibility (at least until EOL) is still a thing, but type-hinting with comments like described above (and at some place in PEP-484) is always possible for both python versions. update-type-hint

    enhancement documentation 
    opened by TiiFuchs 39
  • Refactor how InputMedia* subclasses handle inits

    Refactor how InputMedia* subclasses handle inits

    Currently all the subclasses handle the init completely on their own, while it would make more sense to move all attributes shared between the subclasses to InputMedia, i.e. call super().__init__ like we do for InlineQueryResult*. This includes the attributes caption_entities, parse_mode, type, media & caption

    See https://t.me/c/1494805131/16382 + replies for discussion.

    good first issue hacktoberfest refactor :gear: 
    opened by Bibo-Joshi 36
  • Socks proxy error

    Socks proxy error

    Steps to reproduce

    The code compares behaviour of two libs: urllib3 and python-telegram-bot:

    TOKEN = '<your_api_token>'
    SOCKS_URL = 'socks5://<your_sock5_proxy_host>:1080/'
    SOCKS_USER = '<your_sock5_proxy_user>'
    SOCKS_PASS = '<your_sock5_proxy_password>'
    
    ################## urllib3 ##################
    
    import urllib3
    urllib3.disable_warnings()
    from urllib3.contrib.socks import SOCKSProxyManager
    
    manager = SOCKSProxyManager(
    	SOCKS_URL,
    	username = SOCKS_USER,
    	password = SOCKS_PASS,
    )
    response = manager.request('GET', 'https://api.telegram.org/bot' + TOKEN + '/getMe')
    print response.data
    
    ############ python-telegram-bot ############
    
    from telegram.utils.request import Request
    from telegram import Bot
    
    bot = Bot(
    	TOKEN,
    	request = Request(
    		proxy_url = SOCKS_URL,
    		urllib3_proxy_kwargs = {
    				'username': SOCKS_USER,
    				'password': SOCKS_PASS,
    		},
    	)
    )
    print str(bot.get_me().id)
    

    Expected behaviour

    I expect the same behaviour of both libraries: urllib3 and python-telegram-bot.

    Actual behaviour

    urllib3 works well, but python-telegram-bot raises telegram.error.NetworkError.

    Configuration

    Operating System: Linux test 4.14.30-v7+ #1102 SMP Mon Mar 26 16:45:49 BST 2018 armv7l GNU/Linux Raspbian GNU/Linux 9 (stretch)

    Version of Python, python-telegram-bot & dependencies: python-telegram-bot 10.0.2 certifi 2018.01.18 future 0.16.0 urllib3 1.22 PySocks 1.6.8 Python 2.7.13 (default, Nov 24 2017, 17:33:09) [GCC 6.3.0 20170516]

    Logs

    Output of the code:

    {"ok":true,"result":{"id":584331883,"is_bot":true,"first_name":"Test","username":"TestSocksBot"}}
    Traceback (most recent call last):
      File "/usr/lib/test/test.py", line 33, in <module>
    	print str(bot.get_me().id)
      File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 60, in decorator
    	result = func(self, *args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/telegram/bot.py", line 191, in get_me
    	result = self._request.get(url, timeout=timeout)
      File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 245, in get
    	result = self._request_wrapper('GET', url, **urlopen_kwargs)
      File "/usr/local/lib/python2.7/dist-packages/telegram/utils/request.py", line 201, in _request_wrapper
    	raise NetworkError('urllib3 HTTPError {0}'.format(error))
    telegram.error.NetworkError: urllib3 HTTPError SOCKSHTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot<your_api_token>/getMe (Caused by NewConnectionError('<telegram.vendor.ptb_urllib3.urllib3.contrib.socks.SOCKSHTTPSConnection object at 0x7624d7f0>: Failed to establish a new connection: 0x02: Connection not allowed by ruleset',))
    
    bug :bug: 
    opened by maxgrechnev 31
  • [Suggestion] Add mention_XXX to Chat class

    [Suggestion] Add mention_XXX to Chat class

    XXX means .html and .markdown(_v2). It is supposed to mention the Chat in the picked markup. Use title or first_name + space + Lastname as the text if the input parameter name is not set (otherwise use that), and the inline mention of the chat.id.

    The logic will be close to the User one, have a look at it here: https://github.com/python-telegram-bot/python-telegram-bot/blob/master/telegram/_user.py#L222

    Also check out our contrib document to get started with this project, and don't forget to unit test your changes!

    enhancement good first issue hacktoberfest 
    opened by Poolitzer 27
  • Bot stops responding after network fluctuation

    Bot stops responding after network fluctuation

    Steps to reproduce

    1. Start the bot as usual and commands sent from telegram work.

    2. Reboot the modem (internet goes down) and wait for internet to work again (internet goes up again after some time).

    3. Send some command to the bot.

    Expected behaviour

    Commands sent should work after internet goes up again.

    Actual behaviour

    Commands won't work after internet is up again and are totally ignored by bot.

    Configuration

    Operating System: Raspbian Jessie on Raspberry Pi 2 B

    output of uname -a: Linux raspberrypi 4.4.34-v7+ #930 SMP Wed Nov 23 15:20:41 GMT 2016 armv7l GNU/Linux

    Version of Python, python-telegram-bot & dependencies:

    python-telegram-bot 5.3.0 urllib3 1.20 certifi 2017.01.23 future 0.16.0 Python 2.7.9 (default, Sep 17 2016, 20:26:04) [GCC 4.9.2]

    Logs

    2017-01-29 20:10:36,943 - JobQueue - DEBUG - JobQueue thread started 2017-01-29 20:10:36,947 - telegram.ext.updater - DEBUG - dispatcher - started 2017-01-29 20:10:36,953 - telegram.ext.updater - DEBUG - updater - started 2017-01-29 20:10:36,954 - telegram.ext.updater - DEBUG - Updater thread started 2017-01-29 20:10:36,954 - telegram.bot - DEBUG - Entering: setWebhook 2017-01-29 20:10:36,961 - telegram.ext.dispatcher - DEBUG - Dispatcher started 2017-01-29 20:10:43,864 - telegram.bot - DEBUG - True 2017-01-29 20:10:43,865 - telegram.bot - DEBUG - Exiting: setWebhook 2017-01-29 20:10:43,866 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:10:51,350 - telegram.bot - DEBUG - Getting updates: [642177351] 2017-01-29 20:10:51,352 - telegram.bot - DEBUG - [<telegram.update.Update object at 0x760a5110>] 2017-01-29 20:10:51,353 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:10:51,354 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:10:51,384 - telegram.ext.dispatcher - DEBUG - Processing Update: {'message': {'migrate_to_chat_id': 0, 'delete_chat_photo': False, 'new_chat_photo': [], 'entities': [{'length': 9, 'type': u'bot_command', 'offset': 0}], 'text': u'/snapshot', 'migrate_from_chat_id': 0, 'channel_chat_created': False, 'from': {'username': u'Ritiek', 'first_name': u'Ritiek', 'last_name': u'Malhotra', 'type': '', 'id': 329187815}, 'supergroup_chat_created': False, 'chat': {'username': u'Ritiek', 'first_name': u'Ritiek', 'all_members_are_admins': False, 'title': '', 'last_name': u'Malhotra', 'type': u'private', 'id': 329187815}, 'photo': [], 'date': 1485700851, 'group_chat_created': False, 'caption': '', 'message_id': 728, 'new_chat_title': ''}, 'update_id': 642177351}

    (i send command now)

    2017-01-29 20:10:51,385 - telegram.bot - DEBUG - Entering: sendChatAction 2017-01-29 20:10:53,243 - telegram.bot - DEBUG - True 2017-01-29 20:10:53,244 - telegram.bot - DEBUG - Exiting: sendChatAction 2017-01-29 20:10:53,284 - requests.packages.urllib3.connectionpool - INFO - Starting new HTTP connection (1): localhost 2017-01-29 20:10:53,290 - requests.packages.urllib3.connectionpool - DEBUG - "GET /0/action/snapshot HTTP/1.1" 200 None 2017-01-29 20:10:53,447 - telegram.bot - DEBUG - Entering: sendPhoto 2017-01-29 20:10:54,752 - telegram.bot - DEBUG - {'migrate_to_chat_id': 0, 'delete_chat_photo': False, 'new_chat_photo': [], 'entities': [], 'text': '', 'migrate_from_chat_id': 0, 'channel_chat_created': False, 'from': {'username': u'PersonalPiBot', 'first_name': u'Raspberry Pi', 'last_name': '', 'type': '', 'id': 285030080}, 'supergroup_chat_created': False, 'chat': {'username': u'Ritiek', 'first_name': u'Ritiek', 'all_members_are_admins': False, 'title': '', 'last_name': u'Malhotra', 'type': u'private', 'id': 329187815}, 'photo': [{'width': 90, 'height': 67, 'file_id': 'AgADBQADsacxG6a0cFTxrx6XSJxhJPdKyjIABF6A6kVR2cpsI-gAAgI', 'file_size': 745}, {'width': 320, 'height': 240, 'file_id': 'AgADBQADsacxG6a0cFTxrx6XSJxhJPdKyjIABALoKINajKI-JOgAAgI', 'file_size': 7484}, {'width': 640, 'height': 480, 'file_id': 'AgADBQADsacxG6a0cFTxrx6XSJxhJPdKyjIABdTFtlGmu00l6AACAg', 'file_size': 15483}], 'date': 1485700854, 'group_chat_created': False, 'caption': '', 'message_id': 729, 'new_chat_title': ''} 2017-01-29 20:10:54,755 - telegram.bot - DEBUG - Exiting: sendPhoto 2017-01-29 20:11:01,803 - telegram.bot - DEBUG - No new updates found. 2017-01-29 20:11:01,804 - telegram.bot - DEBUG - [] 2017-01-29 20:11:01,805 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:11:01,806 - telegram.bot - DEBUG - Entering: getUpdates

    (i reboot my modem here)

    2017-01-29 20:11:16,840 - telegram.ext.updater - ERROR - Error while getting Updates: Timed out 2017-01-29 20:11:16,891 - telegram.ext.dispatcher - DEBUG - Processing Update: Timed out 2017-01-29 20:11:17,842 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:11:37,868 - urllib3.connectionpool - WARNING - Retrying (Retry(total=2, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x760a53d0>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /bot285030xxx:xxx2tuY0lzjxwP_FGgNebD9L_Wuc_R0Hipo/getUpdates 2017-01-29 20:11:57,889 - urllib3.connectionpool - WARNING - Retrying (Retry(total=1, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x760a5530>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /bot285030xxx:xxx2tuY0lzjxwP_FGgNebD9L_Wuc_R0Hipo/getUpdates 2017-01-29 20:12:17,911 - urllib3.connectionpool - WARNING - Retrying (Retry(total=0, connect=None, read=None, redirect=None)) after connection broken by 'NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x76085110>: Failed to establish a new connection: [Errno -2] Name or service not known',)': /bot285030xxx:xxx2tuY0lzjxwP_FGgNebD9L_Wuc_R0Hipo/getUpdates 2017-01-29 20:12:31,098 - telegram.bot - DEBUG - No new updates found. 2017-01-29 20:12:31,099 - telegram.bot - DEBUG - [] 2017-01-29 20:12:31,100 - telegram.bot - DEBUG - Exiting: getUpdates

    (my modem is up again and i send another command now)

    2017-01-29 20:12:31,101 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:12:34,704 - telegram.bot - DEBUG - Getting updates: [642177352] 2017-01-29 20:12:34,706 - telegram.bot - DEBUG - [<telegram.update.Update object at 0x760a57b0>] 2017-01-29 20:12:34,707 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:12:34,708 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:12:34,741 - telegram.ext.dispatcher - DEBUG - Processing Update: {'message': {'migrate_to_chat_id': 0, 'delete_chat_photo': False, 'new_chat_photo': [], 'entities': [{'length': 9, 'type': u'bot_command', 'offset': 0}], 'text': u'/snapshot', 'migrate_from_chat_id': 0, 'channel_chat_created': False, 'from': {'username': u'Ritiek', 'first_name': u'Ritiek', 'last_name': u'Malhotra', 'type': '', 'id': 329187815}, 'supergroup_chat_created': False, 'chat': {'username': u'Ritiek', 'first_name': u'Ritiek', 'all_members_are_admins': False, 'title': '', 'last_name': u'Malhotra', 'type': u'private', 'id': 329187815}, 'photo': [], 'date': 1485700954, 'group_chat_created': False, 'caption': '', 'message_id': 730, 'new_chat_title': ''}, 'update_id': 642177352} 2017-01-29 20:12:34,742 - telegram.bot - DEBUG - Entering: sendChatAction 2017-01-29 20:12:45,013 - telegram.bot - DEBUG - No new updates found. 2017-01-29 20:12:45,014 - telegram.bot - DEBUG - [] 2017-01-29 20:12:45,015 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:12:45,016 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:12:50,452 - telegram.bot - DEBUG - Getting updates: [642177353] 2017-01-29 20:12:50,454 - telegram.bot - DEBUG - [<telegram.update.Update object at 0x76c23d90>] 2017-01-29 20:12:50,455 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:12:50,456 - telegram.bot - DEBUG - Entering: getUpdates 2017-01-29 20:13:00,773 - telegram.bot - DEBUG - No new updates found. 2017-01-29 20:13:00,775 - telegram.bot - DEBUG - [] 2017-01-29 20:13:00,776 - telegram.bot - DEBUG - Exiting: getUpdates 2017-01-29 20:13:00,777 - telegram.bot - DEBUG - Entering: getUpdates

    bug :bug: pending reply 
    opened by ritiek 27
  • [QUESTION] raise InvalidToken()telegram.error.InvalidToken: Invalid token

    [QUESTION] raise InvalidToken()telegram.error.InvalidToken: Invalid token

    I'm using a local bot api running with --local, but I can't download anything

    Steps to reproduce

    1. Use self-host bot api, with --local.

    2. Get any file via

    image_file = context.bot.get_file(file_id)
    image_file.download(imagename) 
    

    from telegram server. (Sent by user in my case.)

    Expected behaviour

    It was supposed to download the media, which in this case is a photo

    Actual behaviour

    The API simply cannot download the media

    Configuration

    Operating System: Ubuntu 20.04.2 LTS Python 3.8 Version of Python, python-telegram-bot & dependencies: PTB 13.4.1

    Logs

    2021-04-17 02:34:35,754 - telegram.ext.dispatcher - ERROR - No error handlers are registered, logging exception.
    Traceback (most recent call last):                                                          
    File "/home/ubuntu/.local/lib/python3.8/site-packages/telegram/ext/utils/promise.py", line 79, in run
        self._result = self.pooled_function(*self.args, **self.kwargs)
    File "/home/ubuntu/SmudgePTB13/smudge/modules/searchimage.py", line 60, in reverse
        image_file.download(imagename)
    File "/home/ubuntu/.local/lib/python3.8/site-packages/telegram/files/file.py", line 159, in download
        buf = self.bot.request.retrieve(url, timeout=timeout)                                   
    File "/home/ubuntu/.local/lib/python3.8/site-packages/telegram/utils/request.py", line 373, in retrieve                                                                               
        return self._request_wrapper('GET', url, **urlopen_kwargs)                              
    File "/home/ubuntu/.local/lib/python3.8/site-packages/telegram/utils/request.py", line 274, in _request_wrapper
        raise InvalidToken()
    telegram.error.InvalidToken: Invalid token
    
    question 
    opened by ruizlenato 24
  • [BUG]How can I make the bot ignore the invalid UTF-8 response?

    [BUG]How can I make the bot ignore the invalid UTF-8 response?

    Steps to reproduce

    1. I think it is a small probability event, so I don't know how to reproduce it.

    Expected behaviour

    Run perfectly.

    Actual behaviour

    Bot raise error.

    2019-11-15 12:50:38,048 - telegram.ext.updater - ERROR - Error while getting Updates: Server response could not be decoded using UTF-8
    2019-11-15 12:50:38,048 - xxbot.__main__ - WARNING - Update None caused error Server response could not be decoded using UTF-8
    2019-11-15 12:50:39,220 - telegram.ext.updater - ERROR - Error while getting Updates: Server response could not be decoded using UTF-8
    2019-11-15 12:50:39,221 - xxbot.__main__ - WARNING - Update None caused error Server response could not be decoded using UTF-8
    

    Those error message has been constantly appearing and repeating, causing the program to not work properly.

    And I change the logging module form INFO to DEBUG, the more error details show like this.

    2019-11-15 11:02:44,710 - telegram.ext.dispatcher - DEBUG - Setting singleton dispatcher as <telegram.ext.dispatcher.Dispatcher object at 0x7ff7b973f358>
    2019-11-15 11:02:44,714 - JobQueue - DEBUG - Putting job repeat_submission with t=1573815764.714072
    2019-11-15 11:02:44,714 - JobQueue - DEBUG - Putting job repeat_submission_list_clear with t=1573815764.714721
    2019-11-15 11:02:44,714 - JobQueue - DEBUG - Putting job repeat_table_name with t=1573815764.714840
    2019-11-15 11:02:44,714 - JobQueue - DEBUG - Putting job repeat_table_name_ugly with t=1573815764.714952
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_database_process with t=1573815764.715042
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_repeat_list_delete_one with t=1573815764.715124
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_appreciate_list_delete_one with t=1573815764.715253
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_rest_list_delete_one with t=1573815764.715346
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_sort_by_date_list_delete_one with t=1573815764.715449
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_pic_pool_complete with t=1573815764.715537
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_pic_pool_check with t=1573815764.715622
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_non_pic_pool_complete with t=1573815764.715753
    2019-11-15 11:02:44,715 - JobQueue - DEBUG - Putting job repeat_non_pic_pool_check with t=1573815764.715847
    2019-11-15 11:02:44,716 - JobQueue - DEBUG - Ticking jobs with t=1573815764.716447
    2019-11-15 11:02:44,716 - JobQueue - DEBUG - JobQueue thread started
    2019-11-15 11:02:44,716 - JobQueue - DEBUG - Peeked at repeat_submission with t=1573815764.714072
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Running job repeat_submission
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Putting job repeat_submission with t=1573815770.714072
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Peeked at repeat_submission_list_clear with t=1573815764.714721
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Running job repeat_submission_list_clear
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Putting job repeat_submission_list_clear with t=1573816124.714721
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Peeked at repeat_table_name with t=1573815764.714840
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Running job repeat_table_name
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Putting job repeat_table_name with t=1573815770.714840
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Peeked at repeat_table_name_ugly with t=1573815764.714952
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Running job repeat_table_name_ugly
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Putting job repeat_table_name_ugly with t=1573815770.714952
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Peeked at repeat_database_process with t=1573815764.715042
    2019-11-15 11:02:44,717 - JobQueue - DEBUG - Running job repeat_database_process
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Putting job repeat_database_process with t=1573815767.715042
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Peeked at repeat_repeat_list_delete_one with t=1573815764.715124
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Running job repeat_repeat_list_delete_one
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Putting job repeat_repeat_list_delete_one with t=1573816364.715124
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Peeked at repeat_appreciate_list_delete_one with t=1573815764.715253
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Running job repeat_appreciate_list_delete_one
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Putting job repeat_appreciate_list_delete_one with t=1573815824.715253
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Peeked at repeat_rest_list_delete_one with t=1573815764.715346
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Running job repeat_rest_list_delete_one
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Putting job repeat_rest_list_delete_one with t=1573815824.715346
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Peeked at repeat_sort_by_date_list_delete_one with t=1573815764.715449
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Running job repeat_sort_by_date_list_delete_one
    2019-11-15 11:02:44,718 - JobQueue - DEBUG - Putting job repeat_sort_by_date_list_delete_one with t=1573816364.715449
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Peeked at repeat_pic_pool_complete with t=1573815764.715537
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Running job repeat_pic_pool_complete
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Putting job repeat_pic_pool_complete with t=1573815824.715537
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Peeked at repeat_pic_pool_check with t=1573815764.715622
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Running job repeat_pic_pool_check
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Putting job repeat_pic_pool_check with t=1573815765.715622
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Peeked at repeat_non_pic_pool_complete with t=1573815764.715753
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Running job repeat_non_pic_pool_complete
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Putting job repeat_non_pic_pool_complete with t=1573815824.715753
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Peeked at repeat_non_pic_pool_check with t=1573815764.715847
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Running job repeat_non_pic_pool_check
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Putting job repeat_non_pic_pool_check with t=1573815765.715847
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Peeked at repeat_pic_pool_check with t=1573815765.715622
    2019-11-15 11:02:44,719 - JobQueue - DEBUG - Next task isn't due yet. Finished!
    2019-11-15 11:02:44,720 - telegram.ext.updater - DEBUG - dispatcher - started
    2019-11-15 11:02:44,723 - telegram.ext.updater - DEBUG - updater - started
    2019-11-15 11:02:44,723 - telegram.ext.updater - DEBUG - Updater thread started (polling)
    2019-11-15 11:02:44,723 - telegram.ext.updater - DEBUG - Start network loop retry bootstrap del webhook
    2019-11-15 11:02:44,724 - telegram.bot - DEBUG - Entering: delete_webhook
    2019-11-15 11:02:44,724 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): api.telegram.org
    2019-11-15 11:02:44,787 - telegram.ext.dispatcher - DEBUG - Dispatcher started
    2019-11-15 11:02:45,435 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /bot627323681:AAHBB-8QBgyu7wPhR_GHIrbbH40YjT5kB2I/deleteWebhook HTTP/1.1" 200 68
    2019-11-15 11:02:45,435 - telegram.bot - DEBUG - True
    2019-11-15 11:02:45,435 - telegram.bot - DEBUG - Exiting: delete_webhook
    2019-11-15 11:02:45,435 - telegram.ext.updater - DEBUG - Bootstrap done
    2019-11-15 11:02:45,435 - telegram.ext.updater - DEBUG - Start network loop retry getting Updates
    2019-11-15 11:02:45,436 - telegram.bot - DEBUG - Entering: get_updates
    2019-11-15 11:02:45,593 - telegram.vendor.ptb_urllib3.urllib3.connectionpool - DEBUG - https://api.telegram.org:443 "POST /bot627323681:AAHBB-8QBgyu7wPhR_GHIrbbH40YjT5kB2I/getUpdates HTTP/1.1" 200 5909
    2019-11-15 11:02:45,593 - telegram.utils.request - DEBUG - Logging raw invalid UTF-8 response:
    b'{"ok":true,"result":[{"update_id":XXXXXXXXX,\n"message":{"message_id":79819,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","last_name":"XXXXXXXXX","username":"XXXXXXXXX"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573803803,"reply_to_message":{"message_id":79818,"from":{"id":XXXXXXXXX,"is_bot":true,"first_name":"XXXXXXXXX","username":"XXXXXXXXX"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573803744,"photo":[{"file_id":"XXXXXXXXX","file_size":3620,"width":200,"height":70}],"caption":"XXXXXXXXX","caption_entities":[{"offset":3,"length":4,"type":"text_mention","user":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","last_name":"XXXXXXXXX","username":"XXXXXXXXX"}}],"reply_markup":{"inline_keyboard":[[{"text":"XXXXXXXXX","callback_data":"XXXXXXXXX"}],[{"text":"XXXXXXXXX","callback_data":"XXXXXXXXX"},{"text":"XXXXXXXXX","callback_data":"XXXXXXXXX"}]]}},"text":"XXXXXXXXX"}},{"update_id":XXXXXXXXX,\n"message":{"message_id":1807,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573804787,"new_chat_participant":{"id":XXXXXXXXX,"is_bot":false,"first_name":" XXXXXXXXX"},"new_chat_member":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX"},"new_chat_members":[{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129646,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","language_code":"zh-hans"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573805383,"text":"XXXXXXXXX","entities":[{"offset":0,"length":5,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129647,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","language_code":"zh-hans"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573805420,"text":"XXXXXXXXX","entities":[{"offset":0,"length":2,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129648,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573810865,"text":"XXXXXXXXX","entities":[{"offset":0,"length":24,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129649,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573810886,"text":"XXXXXXXXX","entities":[{"offset":0,"length":24,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129650,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573810890,"text":"XXXXXXXXX","entities":[{"offset":0,"length":17,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":109851,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":XXXXXXXXX,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","type":"private"},"date":1573811048,"text":"XXXXXXXXX","entities":[{"offset":0,"length":12,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":XXXXXXXXX,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":366039180,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","type":"private"},"date":1573811339,"text":"XXXXXXXXX","entities":[{"offset":0,"length":12,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":XXXXXXXXX,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","language_code":"en"},"chat":{"id":XXXXXXXXX,"first_name":"XXXXXXXXX","username":"XXXXXXXXX","type":"private"},"date":1573811393,"text":"XXXXXXXXX","entities":[{"offset":0,"length":12,"type":"bot_command"}]}},{"update_id":XXXXXXXXX,\n"message":{"message_id":129651,"from":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX"},"chat":{"id":-XXXXXXXXX,"title":"XXXXXXXXX","username":"XXXXXXXXX","type":"supergroup"},"date":1573813538,"new_chat_participant":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX"},"new_chat_member":{"id":XXXXXXXXX,"is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX"},"new_chat_members":[{"id":XXXXXXXXX,is_bot":false,"first_name":"XXXXXXXXX","username":"XXXXXXXXX"}]}}]}'
    2019-11-15 11:02:45,593 - telegram.ext.updater - ERROR - Error while getting Updates: Server response could not be decoded using UTF-8
    2019-11-15 11:02:45,593 - telegram.ext.dispatcher - DEBUG - Processing Update: Server response could not be decoded using UTF-8
    2019-11-15 11:02:45,594 - xxbot.__main__ - WARNING - Update None caused error Server response could not be decoded using UTF-8
    

    I have replaced some sensitive information with xxxxx.

    Configuration

    Operating System: Linux Debian10-1 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64 GNU/Linux

    Version of Python, python-telegram-bot & dependencies:

    $ python -m telegram

    Output.

    >>> python3 -m telegram
    python-telegram-bot 11.1.0
    certifi 2018.08.24
    future 0.17.1
    Python 3.7.3 (default, Apr  3 2019, 05:39:12)  [GCC 8.3.0]
    

    So how to make the program ignore this unresolvable data without affecting other processing?

    THX.

    Logs

    Insert logs here (if necessary)

    bug :bug: good first issue 
    opened by rikonaka 24
  • clean pending update based on Timedelta or datetime

    clean pending update based on Timedelta or datetime

    Follow-up of #1978

    Add option to pass a timedelta or datetime as var clean to .start_polling() or .start_webhook(). Updates with a timestamp before now - timedelta will be ignored. Updates before datetime will be ignored.

    I'm not familiar with the test-module to write these from scratch as this is not a 'direct' function to test. Can put in some time if y'all can point me to similar examples?

    Maybe needs some cleanup but need the gh test bot results for that.

    pending review 
    opened by ikkemaniac 22
  • [BUG] Message.photo is set to an empty list when not provided

    [BUG] Message.photo is set to an empty list when not provided

    Steps to reproduce

    1. Generate a Message object without photo set.

    2. Check the photo parameter

    Expected behaviour

    .photo should be None

    Actual behaviour

    .photo is an empty list

    Wrong line: https://github.com/python-telegram-bot/python-telegram-bot/blob/1fdaaac8094c9d76c34c8c8e8c9add16080e75e7/telegram/message.py#L515

    bug :bug: API 
    opened by Poolitzer 21
  • Add default values

    Add default values

    Supersedes/Closes #1226 and closes #1527

    To meet the requirements stated by @Eldinnie in #1226, I added a new class DefaultValue to the helpers module. It's purpose is to allow to differentiate check if a value is just the default or was set specifically:

    With def f(arg=None) we don't know, if arg is None results from f() or from f(None). With def f(arg=DefaultValue(None), we can handle those differently.

    This makes it necessary to add some stuff to the InlineQueryResult* for bot.answer_inline_query to parse the new default_parse_mode correctly. But it does the job :) Maybe DefaultValue also comes in handy with a future use case … How do the @python-telegram-bot/maintainers feel about this?

    For the tests, I tried and added them for the send_* and edit_message_* methods. I'm still not too familiar with pytest, so please tell if those can be improved. However, I couldn't find a clever way to test the default_parse_mode for answer_inline_query since I'd somehow have to get hold of the resulting message. Any idea is appreciated :)

    enhancement pending review 
    opened by Bibo-Joshi 21
  • Bot API 2.0

    Bot API 2.0

    Official announcement: https://core.telegram.org/bots/2-0-intro Changelog: https://core.telegram.org/bots/api-changelog

    • [x] New inline keyboards with callback and URL buttons. Added new objects InlineKeyboardMarkup, InlineKeyboardButton and CallbackQuery, added reply_markup fields to all InlineQueryResult objects. Added field callback_query to the Update object, new method answerCallbackQuery.
    • [x] Bots can now edit their messages. Added methods editMessageText, editMessageCaption, editMessageReplyMarkup.
    • [x] Bots can request location and phone number from the user. The keyboard field in the object ReplyKeyboardMarkup now supports KeyboardButton, a new object that can have the fields request_location and request_contact.
    • [x] Added support for all content types available on Telegram. 19 types of InlineQueryResult objects are now supported.
    • [x] Inline bots can now subsitute all kinds of content with text. Added 4 types of InputMessageContent objects.
    • [x] You inline bot can also ask users for permission to use their location. Added the new Botfather command /setinlinegeo, added field location to the InlineQuery object, added fields location and inline_message_id to the ChosenInlineResult object.
    • [x] Added an easy way to switch between inline mode and a private chat with the bot – useful for settings, establishing external connections and teaching users how to use your bot in inline mode. Added parameters switch_pm_text and switch_pm_parameter to the method answerInlineQuery.
    • [x] Added group administration tools. New methods kickChatMember and unbanChatMember.
    • [x] Added fields venue, pinned_message and entities to the Message object. Added new objects MessageEntity and Venue, new methods sendVenue and sendContact.
    • [x] Renamed the fields new_chat_participant and left_chat_participant of the Message object to new_chat_member and left_chat_member.
    enhancement API 
    opened by leandrotoledo 21
  • [QUESTION]httpx.RemoteProtocolError: Server disconnected without sending a response.

    [QUESTION]httpx.RemoteProtocolError: Server disconnected without sending a response.

    Issue I am facing

    I'm writing a very simple bot app. The only difference is I'm using HTTP proxy.

    Here is my code:

    #!/usr/bin/python
    #coding: utf-8
    
    TOKEN = "***:***"
    PROXY="http://127.0.0.1:3128"
    
    from telegram import Update
    from telegram.ext import ApplicationBuilder, ContextTypes, CommandHandler,MessageHandler, filters
    from telegram.error import NetworkError
    
    import logging
    logging.basicConfig(
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
        level=logging.INFO
    )
    logger = logging.getLogger(__name__)
    
    
    async def start(update: Update, context: ContextTypes.context):
        logger.info(msg="Start():")
        await context.bot.send_message(chat_id=update.effective_chat.id, text="yes!")
    
    async def error_handler(update: Update, context: ContextTypes.context):
        logger.error(msg=">>>>>>>>>>>", exc_info=context.error)
    
    
    if __name__ == '__main__':
    
        application = ApplicationBuilder().token(TOKEN).build()
        start_handler = CommandHandler('start', start)
        application.add_handler(start_handler)
    
        application.add_error_handler(error_handler)
        application.run_polling()
        
    

    This application got network errors every 15 seconds.

    The main error message is :telegram.error.NetworkError: httpx HTTPError: Server disconnected without sending a response.

    Even though, this app can process the update messages got from user. When user send /start to tgbot, it responses correctly.

    Traceback to the issue

    2023-01-09 19:16:06,939 - apscheduler.scheduler - INFO - Scheduler started
    2023-01-09 19:16:06,939 - telegram.ext._application - INFO - Application started
    2023-01-09 19:16:27,739 - telegram.ext._updater - ERROR - Error while getting Updates: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:16:27,739 - __main__ - ERROR - >>>>>>>>>>>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
        yield
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
        resp = await self._pool.handle_async_request(req)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
        response = await connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
        return await self._connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 112, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 91, in handle_async_request
        ) = await self._receive_response_headers(**kwargs)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 155, in _receive_response_headers
        event = await self._receive_event(timeout=timeout)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 205, in _receive_event
        raise RemoteProtocolError(msg)
    httpcore.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 183, in do_request
        res = await self._client.request(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
        return await self.send(request, auth=auth, follow_redirects=follow_redirects)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1620, in send
        response = await self._send_handling_auth(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1648, in _send_handling_auth
        response = await self._send_handling_redirects(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1685, in _send_handling_redirects
        response = await self._send_single_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1722, in _send_single_request
        response = await transport.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
        with map_httpcore_exceptions():
      File "/usr/local/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
        self.gen.throw(typ, value, traceback)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
    httpx.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 600, in _network_loop_retry
        if not await action_cb():
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 327, in polling_action_cb
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 312, in polling_action_cb
        updates = await self.bot.get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 524, in get_updates
        updates = await super().get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 334, in decorator
        result = await func(*args, **kwargs)  # skipcq: PYL-E1102
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 3584, in get_updates
        await self._post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 422, in _post
        return await self._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 306, in _do_post
        return await super()._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 453, in _do_post
        return await request.post(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
        result = await self._request_wrapper(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 288, in _request_wrapper
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 274, in _request_wrapper
        code, payload = await self.do_request(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 204, in do_request
        raise NetworkError(f"httpx HTTPError: {err}") from err
    telegram.error.NetworkError: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:16:39,501 - telegram.ext._updater - ERROR - Error while getting Updates: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:16:39,501 - __main__ - ERROR - >>>>>>>>>>>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
        yield
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
        resp = await self._pool.handle_async_request(req)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
        response = await connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
        return await self._connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 112, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 91, in handle_async_request
        ) = await self._receive_response_headers(**kwargs)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 155, in _receive_response_headers
        event = await self._receive_event(timeout=timeout)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 205, in _receive_event
        raise RemoteProtocolError(msg)
    httpcore.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 183, in do_request
        res = await self._client.request(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
        return await self.send(request, auth=auth, follow_redirects=follow_redirects)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1620, in send
        response = await self._send_handling_auth(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1648, in _send_handling_auth
        response = await self._send_handling_redirects(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1685, in _send_handling_redirects
        response = await self._send_single_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1722, in _send_single_request
        response = await transport.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
        with map_httpcore_exceptions():
      File "/usr/local/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
        self.gen.throw(typ, value, traceback)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
    httpx.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 600, in _network_loop_retry
        if not await action_cb():
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 327, in polling_action_cb
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 312, in polling_action_cb
        updates = await self.bot.get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 524, in get_updates
        updates = await super().get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 334, in decorator
        result = await func(*args, **kwargs)  # skipcq: PYL-E1102
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 3584, in get_updates
        await self._post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 422, in _post
        return await self._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 306, in _do_post
        return await super()._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 453, in _do_post
        return await request.post(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
        result = await self._request_wrapper(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 288, in _request_wrapper
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 274, in _request_wrapper
        code, payload = await self.do_request(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 204, in do_request
        raise NetworkError(f"httpx HTTPError: {err}") from err
    telegram.error.NetworkError: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:16:51,741 - telegram.ext._updater - ERROR - Error while getting Updates: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:16:51,741 - __main__ - ERROR - >>>>>>>>>>>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
        yield
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
        resp = await self._pool.handle_async_request(req)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
        response = await connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
        return await self._connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 112, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 91, in handle_async_request
        ) = await self._receive_response_headers(**kwargs)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 155, in _receive_response_headers
        event = await self._receive_event(timeout=timeout)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 205, in _receive_event
        raise RemoteProtocolError(msg)
    httpcore.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 183, in do_request
        res = await self._client.request(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
        return await self.send(request, auth=auth, follow_redirects=follow_redirects)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1620, in send
        response = await self._send_handling_auth(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1648, in _send_handling_auth
        response = await self._send_handling_redirects(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1685, in _send_handling_redirects
        response = await self._send_single_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1722, in _send_single_request
        response = await transport.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
        with map_httpcore_exceptions():
      File "/usr/local/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
        self.gen.throw(typ, value, traceback)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
    httpx.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 600, in _network_loop_retry
        if not await action_cb():
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 327, in polling_action_cb
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 312, in polling_action_cb
        updates = await self.bot.get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 524, in get_updates
        updates = await super().get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 334, in decorator
        result = await func(*args, **kwargs)  # skipcq: PYL-E1102
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 3584, in get_updates
        await self._post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 422, in _post
        return await self._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 306, in _do_post
        return await super()._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 453, in _do_post
        return await request.post(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
        result = await self._request_wrapper(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 288, in _request_wrapper
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 274, in _request_wrapper
        code, payload = await self.do_request(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 204, in do_request
        raise NetworkError(f"httpx HTTPError: {err}") from err
    telegram.error.NetworkError: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:17:04,708 - telegram.ext._updater - ERROR - Error while getting Updates: httpx HTTPError: Server disconnected without sending a response.
    2023-01-09 19:17:04,708 - __main__ - ERROR - >>>>>>>>>>>
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 60, in map_httpcore_exceptions
        yield
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
        resp = await self._pool.handle_async_request(req)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 253, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection_pool.py", line 237, in handle_async_request
        response = await connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/connection.py", line 90, in handle_async_request
        return await self._connection.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 112, in handle_async_request
        raise exc
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 91, in handle_async_request
        ) = await self._receive_response_headers(**kwargs)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 155, in _receive_response_headers
        event = await self._receive_event(timeout=timeout)
      File "/usr/local/lib/python3.10/site-packages/httpcore/_async/http11.py", line 205, in _receive_event
        raise RemoteProtocolError(msg)
    httpcore.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 183, in do_request
        res = await self._client.request(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1533, in request
        return await self.send(request, auth=auth, follow_redirects=follow_redirects)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1620, in send
        response = await self._send_handling_auth(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1648, in _send_handling_auth
        response = await self._send_handling_redirects(
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1685, in _send_handling_redirects
        response = await self._send_single_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_client.py", line 1722, in _send_single_request
        response = await transport.handle_async_request(request)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 352, in handle_async_request
        with map_httpcore_exceptions():
      File "/usr/local/Cellar/[email protected]/3.10.6_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/contextlib.py", line 153, in __exit__
        self.gen.throw(typ, value, traceback)
      File "/usr/local/lib/python3.10/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
        raise mapped_exc(message) from exc
    httpx.RemoteProtocolError: Server disconnected without sending a response.
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 600, in _network_loop_retry
        if not await action_cb():
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 327, in polling_action_cb
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_updater.py", line 312, in polling_action_cb
        updates = await self.bot.get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 524, in get_updates
        updates = await super().get_updates(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 334, in decorator
        result = await func(*args, **kwargs)  # skipcq: PYL-E1102
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 3584, in get_updates
        await self._post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 422, in _post
        return await self._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/ext/_extbot.py", line 306, in _do_post
        return await super()._do_post(
      File "/usr/local/lib/python3.10/site-packages/telegram/_bot.py", line 453, in _do_post
        return await request.post(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 165, in post
        result = await self._request_wrapper(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 288, in _request_wrapper
        raise exc
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_baserequest.py", line 274, in _request_wrapper
        code, payload = await self.do_request(
      File "/usr/local/lib/python3.10/site-packages/telegram/request/_httpxrequest.py", line 204, in do_request
        raise NetworkError(f"httpx HTTPError: {err}") from err
    telegram.error.NetworkError: httpx HTTPError: Server disconnected without sending a response.
    

    Related part of your code

    No response

    Operating System

    macOS Monterey 12.6.2

    Version of Python, python-telegram-bot & dependencies

    python3 -m telegram
    python-telegram-bot 20.0
    Bot API 6.4
    Python 3.10.6 (main, Aug 11 2022, 13:49:25) [Clang 13.1.6 (clang-1316.0.21.2.5)]
    
    python3 -V
    Python 3.10.6
    
    question 
    opened by shadu120 0
  • [QUESTION] Export GPG key to a key-server

    [QUESTION] Export GPG key to a key-server

    Issue I am facing

    When I try to install an Arch Linux package from AUR, I need to do a manual step to get the key from github content.

    A standard way to share the keys with the community is key servers. So the key owner should do something like:

    gpg --send-keys 4CBA518847044E289548BD9FA2B984A9073022B2 --keyserver https://pgp.mit.edu
    gpg --send-keys 4CBA518847044E289548BD9FA2B984A9073022B2 --keyserver hkps://keyserver.ubuntu.com
    

    Traceback to the issue

    No response

    Related part of your code

    No response

    Operating System

    Arch Linux

    Version of Python, python-telegram-bot & dependencies

    not relative
    
    question 
    opened by Felixoid 0
  • [DOCUMENTATION] Add copy button/icon to code snippets in docs

    [DOCUMENTATION] Add copy button/icon to code snippets in docs

    What kind of feature are you missing? Where do you notice a shortcoming of PTB?

    It is inconvenient to have to manually scroll through and select the entire code in the documentation, as there is no copy button or icon available for the code snippets and examples.

    Describe the solution you'd like

    A copy button can be added to the code snippets to make it easier to access the code without needing to scroll through the text. This can be done using the sphinx-copybutton extension, which can be installed by running pip install sphinx-copybutton. Don't forget to add this to the requirements-docs.txt file. To enable the extension, edit the This list and add sphinx_copybutton to it.

    Describe alternatives you've considered

    Scrolling through the entire code, particularly through the examples, to copy them is very inconvenient.

    Additional context

    Please have a look at the Contrib guide for details on how to submit a PR and also how to build the documentation locally.

    good first issue documentation 
    opened by clot27 2
  • Drop `telegram(.ext).` prefixes

    Drop `telegram(.ext).` prefixes

    As suggested in https://t.me/c/1494805131/32127. Build will be up soonish on rtd.

    URLs seem to be unchanged.

    Before a merge, I want to test if this would imply any changes for rulesbot.

    documentation 
    opened by Bibo-Joshi 4
  • [FEATURE] Time Picker Menu

    [FEATURE] Time Picker Menu

    What kind of feature are you missing? Where do you notice a shortcoming of PTB?

    Hi, it would be awesome if PTB is able to provide a menu for picking time (or date and time).

    Describe the solution you'd like

    There is already a scheduler menu in Telegram itself which can be triggered by scheduling a message or setting a reminder in the Scheduled messages. image image

    Maybe this can be triggered by some system calls, but I am not sure.

    Describe alternatives you've considered

    By a little googling, I have found a lot of awkward workarounds (e.g. inline keyboards), but none of them are really attractive from both UX and integrating into code point of view.

    Additional context

    Thank you in advance!

    enhancement 
    opened by perevale 2
Releases(v20.0)
Spam your friends and famly and when you do your famly will disown you and you will have no friends.

SpamBot9000 Spam your friends and family and when you do your family will disown you and you will have no friends. Terms of Use Disclaimer: Please onl

DJ15 0 Jun 9, 2022
Red Team tool for exfiltrating files from a target's Google Drive that you have access to, via Google's API.

GD-Thief Red Team tool for exfiltrating files from a target's Google Drive that you(the attacker) has access to, via the Google Drive API. This includ

Antonio Piazza 39 Dec 27, 2022
Discord-Protect is a simple discord bot allowing you to have some security on your discord server by ordering a captcha to the user who joins your server.

Discord-Protect Discord-Protect is a simple discord bot allowing you to have some security on your discord server by ordering a captcha to the user wh

Tir Omar 2 Oct 28, 2021
A customisable game where you have to quickly click on black tiles in order of appearance while avoiding clicking on white squares.

W.I.P-Aim-Memory-Game A customisable game where you have to quickly click on black tiles in order of appearance while avoiding clicking on white squar

dE_soot 1 Dec 8, 2021
Pseudo-rng-app - whos needs science to make a random number when you have pseudoscience?

Pseudo-random numbers with pseudoscience rng is so complicated! Why cant we have a horoscopic, vibe-y way of calculating a random number? Why cant rng

Andrew Blance 1 Dec 27, 2021
Warning: This project does not have any current developer. See bellow.

Pylearn2: A machine learning research library Warning : This project does not have any current developer. We will continue to review pull requests and

Laboratoire d’Informatique des Systèmes Adaptatifs 2.7k Dec 26, 2022
Allows including an action inside another action (by preprocessing the Yaml file). This is how composite actions should have worked.

actions-includes Allows including an action inside another action (by preprocessing the Yaml file). Instead of using uses or run in your action step,

Tim Ansell 70 Nov 4, 2022
Autotype on websites that have copy-paste disabled like Moodle, HackerEarth contest etc.

Autotype A quick and small python script that helps you autotype on websites that have copy paste disabled like Moodle, HackerEarth contests etc as it

Tushar 32 Nov 3, 2022
Learning To Have An Ear For Face Super-Resolution

Learning To Have An Ear For Face Super-Resolution [Project Page] This repository contains demo code of our CVPR2020 paper. Training and evaluation on

null 50 Nov 16, 2022
Corgis are the cutest creatures; have 30K of them!

corgi-net This is a dataset of corgi images scraped from the corgi subreddit. After filtering using an ImageNet classifier, the training set consists

Alex Nichol 6 Dec 24, 2022
Learning based AI for playing multi-round Koi-Koi hanafuda card games. Have fun.

Koi-Koi AI Learning based AI for playing multi-round Koi-Koi hanafuda card games. Platform Python PyTorch PySimpleGUI (for the interface playing vs AI

Sanghai Guan 10 Nov 20, 2022
arxiv-sanity, but very lite, simply providing the core value proposition of the ability to tag arxiv papers of interest and have the program recommend similar papers.

arxiv-sanity, but very lite, simply providing the core value proposition of the ability to tag arxiv papers of interest and have the program recommend similar papers.

Andrej 671 Dec 31, 2022
An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects different compression algorithms have.

ImageCompressionSimulation An Image compression simulator that uses Source Extractor and Monte Carlo methods to examine the post compressive effects o

James Park 1 Dec 11, 2021
Patient-Survival - Using Python, I developed a Machine Learning model using classification techniques such as Random Forest and SVM classifiers to predict a patient's survival status that have undergone breast cancer surgery.

Patient-Survival - Using Python, I developed a Machine Learning model using classification techniques such as Random Forest and SVM classifiers to predict a patient's survival status that have undergone breast cancer surgery.

Nafis Ahmed 1 Dec 28, 2021
Diabet Feature Engineering - Predict whether people have diabetes when their characteristics are specified

Diabet Feature Engineering - Predict whether people have diabetes when their characteristics are specified

Şebnem 6 Jan 18, 2022
Özlem Taşkın 0 Feb 23, 2022