From ad8679079e82747db8cc94658bdbbb9f6096734f Mon Sep 17 00:00:00 2001 From: Robi Date: Wed, 26 Oct 2022 18:46:33 +0300 Subject: [PATCH 01/10] Unified docs for the Poll class. --- telegram/_bot.py | 5 +++-- telegram/_poll.py | 37 +++++++++++++++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index 38f8f735c6a..94929b2f7d0 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -5951,8 +5951,9 @@ async def send_poll( :tg-const:`telegram.Poll.REGULAR`, defaults to :tg-const:`telegram.Poll.REGULAR`. allows_multiple_answers (:obj:`bool`, optional): :obj:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :obj:`False`. - correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer - option, required for polls in quiz mode. + correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer + option.Available only for closed polls in the quiz mode, which were sent (not + forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing. diff --git a/telegram/_poll.py b/telegram/_poll.py index a187d07d253..04b90540aa0 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -126,13 +126,18 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer option. - Available only for polls in the quiz mode, which are closed, or was sent (not - forwarded) by the bot or to the private chat with the bot. + correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer option. + Available only for closed polls in the quiz mode, which were sent (not + forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect - answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. - explanation_entities (List[:class:`telegram.MessageEntity`], optional): Special entities + answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most + 2 line feeds after entities parsing. + explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. + This list is empty if the message does not contain explanation entities. + + .. versionchanged:: 20.0 + This attribute is now always a (possibly empty) list and never :obj:`None`. open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active after creation. close_date (:obj:`datetime.datetime`, optional): Point in time (Unix timestamp) when the @@ -147,19 +152,27 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`): Optional. Identifier of the correct answer option. - explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect - answer or taps on the lamp icon in a quiz-style poll. + correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer option. + Available only for closed polls in the quiz mode, which were sent (not + forwarded), by the bot or to a private chat with the bot. + explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect + answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most + 2 line feeds after entities parsing. explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. This list is empty if the message does not contain explanation entities. .. versionchanged:: 20.0 This attribute is now always a (possibly empty) list and never :obj:`None`. - open_period (:obj:`int`): Optional. Amount of time in seconds the poll will be active - after creation. - close_date (:obj:`datetime.datetime`): Optional. Point in time when the poll will be - automatically closed. + open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active + after creation, 5-600. Can't be used together with :paramref:`close_date`. + close_date (:obj:`int` | :obj:`datetime.datetime`, optional): Point in time (Unix + timestamp) when the poll will be automatically closed. Must be at least 5 and no + more than 600 seconds in the future. Can't be used together with + :paramref:`open_period`. + For timezone naive :obj:`datetime.datetime` objects, the default timezone of the + bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is + used. """ From d531c2b36e47e4ae89dac90707c10167cf2d2564 Mon Sep 17 00:00:00 2001 From: Robi Date: Wed, 26 Oct 2022 18:57:40 +0300 Subject: [PATCH 02/10] bit of spacing --- telegram/_bot.py | 2 +- telegram/_poll.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index 94929b2f7d0..a0abf3b1bcb 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -5952,7 +5952,7 @@ async def send_poll( allows_multiple_answers (:obj:`bool`, optional): :obj:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :obj:`False`. correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer - option.Available only for closed polls in the quiz mode, which were sent (not + option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most diff --git a/telegram/_poll.py b/telegram/_poll.py index 04b90540aa0..ee7fe815fa3 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -126,7 +126,7 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer option. + correct_option_id (:obj:`int`, optional)): A zero based identifier of the correct answer option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect From 9c6ff67da1cba9a0527d2ae07b6ad5eac73ba05f Mon Sep 17 00:00:00 2001 From: Robi Date: Wed, 26 Oct 2022 23:02:52 +0300 Subject: [PATCH 03/10] reverts bot edit --- telegram/_bot.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/telegram/_bot.py b/telegram/_bot.py index a0abf3b1bcb..38f8f735c6a 100644 --- a/telegram/_bot.py +++ b/telegram/_bot.py @@ -5951,9 +5951,8 @@ async def send_poll( :tg-const:`telegram.Poll.REGULAR`, defaults to :tg-const:`telegram.Poll.REGULAR`. allows_multiple_answers (:obj:`bool`, optional): :obj:`True`, if the poll allows multiple answers, ignored for polls in quiz mode, defaults to :obj:`False`. - correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer - option. Available only for closed polls in the quiz mode, which were sent (not - forwarded), by the bot or to a private chat with the bot. + correct_option_id (:obj:`int`, optional): 0-based identifier of the correct answer + option, required for polls in quiz mode. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing. From e9c253bf2d6abe49839b5c86aa17042f7746b24d Mon Sep 17 00:00:00 2001 From: Robi Date: Wed, 26 Oct 2022 23:05:33 +0300 Subject: [PATCH 04/10] removes sentence and corrects optional --- telegram/_poll.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index ee7fe815fa3..cdbcc0c131c 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -130,8 +130,7 @@ class Poll(TelegramObject): Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect - answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most - 2 line feeds after entities parsing. + answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. This list is empty if the message does not contain explanation entities. @@ -155,7 +154,7 @@ class Poll(TelegramObject): correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. - explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect + explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most 2 line feeds after entities parsing. explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities From ea3e898403933378c0d5a16e2ee12ca9fd588775 Mon Sep 17 00:00:00 2001 From: Robi Date: Wed, 26 Oct 2022 23:08:53 +0300 Subject: [PATCH 05/10] reverts send_poll doc unification --- telegram/_poll.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index cdbcc0c131c..c1b6a45fef3 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -163,15 +163,10 @@ class Poll(TelegramObject): .. versionchanged:: 20.0 This attribute is now always a (possibly empty) list and never :obj:`None`. - open_period (:obj:`int`, optional): Amount of time in seconds the poll will be active - after creation, 5-600. Can't be used together with :paramref:`close_date`. - close_date (:obj:`int` | :obj:`datetime.datetime`, optional): Point in time (Unix - timestamp) when the poll will be automatically closed. Must be at least 5 and no - more than 600 seconds in the future. Can't be used together with - :paramref:`open_period`. - For timezone naive :obj:`datetime.datetime` objects, the default timezone of the - bot will be used, which is UTC unless :attr:`telegram.ext.Defaults.tzinfo` is - used. + open_period (:obj:`int`): Optional. Amount of time in seconds the poll will be active + after creation. + close_date (:obj:`datetime.datetime`): Optional. Point in time when the poll will be + automatically closed. """ From cb1496608fecdde74681e72f6e4e1f366aa7bcc6 Mon Sep 17 00:00:00 2001 From: Robi <53259730+RobiMez@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:59:18 +0300 Subject: [PATCH 06/10] Update telegram/_poll.py Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com> --- telegram/_poll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index c1b6a45fef3..f7f296d5369 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -126,7 +126,7 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`, optional)): A zero based identifier of the correct answer option. + correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect From 92ffff2a8f5a779c8acb0007e30d542568a88539 Mon Sep 17 00:00:00 2001 From: Robi <53259730+RobiMez@users.noreply.github.com> Date: Wed, 26 Oct 2022 23:59:45 +0300 Subject: [PATCH 07/10] Update telegram/_poll.py Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com> --- telegram/_poll.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index f7f296d5369..d567dd27cf3 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -131,7 +131,7 @@ class Poll(TelegramObject): forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. - explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities + explanation_entities (List[:class:`telegram.MessageEntity`], optional): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. This list is empty if the message does not contain explanation entities. From aab1490f3f3479caf75eb133e2ba3c87828b9dea Mon Sep 17 00:00:00 2001 From: Robi Date: Thu, 27 Oct 2022 00:01:40 +0300 Subject: [PATCH 08/10] remove line feed --- telegram/_poll.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index c1b6a45fef3..567ed2b13a0 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -155,8 +155,7 @@ class Poll(TelegramObject): Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect - answer or taps on the lamp icon in a quiz-style poll, 0-200 characters with at most - 2 line feeds after entities parsing. + answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities like usernames, URLs, bot commands, etc. that appear in the :attr:`explanation`. This list is empty if the message does not contain explanation entities. From 49a8d3037eca13173971589a009adc583360521a Mon Sep 17 00:00:00 2001 From: Robi Date: Thu, 27 Oct 2022 00:12:39 +0300 Subject: [PATCH 09/10] line breaks --- telegram/_poll.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index e003ebeb472..9c5d505cda2 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -126,9 +126,9 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer option. - Available only for closed polls in the quiz mode, which were sent (not - forwarded), by the bot or to a private chat with the bot. + correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer + option. Available only for closed polls in the quiz mode, which were sent + (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. explanation_entities (List[:class:`telegram.MessageEntity`], optional): Special entities @@ -151,9 +151,9 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`): Optional. A zero based identifier of the correct answer option. - Available only for closed polls in the quiz mode, which were sent (not - forwarded), by the bot or to a private chat with the bot. + correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer + option. Available only for closed polls in the quiz mode, which were sent + (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. explanation_entities (List[:class:`telegram.MessageEntity`]): Special entities From 37a6d6bf787663ec6376597a3cdea750049dcf91 Mon Sep 17 00:00:00 2001 From: Robi Date: Thu, 27 Oct 2022 00:19:13 +0300 Subject: [PATCH 10/10] whitespace --- telegram/_poll.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/telegram/_poll.py b/telegram/_poll.py index 9c5d505cda2..5b2102b56f0 100644 --- a/telegram/_poll.py +++ b/telegram/_poll.py @@ -126,8 +126,8 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer - option. Available only for closed polls in the quiz mode, which were sent + correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer + option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`, optional): Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters. @@ -151,8 +151,8 @@ class Poll(TelegramObject): is_anonymous (:obj:`bool`): :obj:`True`, if the poll is anonymous. type (:obj:`str`): Poll type, currently can be :attr:`REGULAR` or :attr:`QUIZ`. allows_multiple_answers (:obj:`bool`): :obj:`True`, if the poll allows multiple answers. - correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer - option. Available only for closed polls in the quiz mode, which were sent + correct_option_id (:obj:`int`, optional): A zero based identifier of the correct answer + option. Available only for closed polls in the quiz mode, which were sent (not forwarded), by the bot or to a private chat with the bot. explanation (:obj:`str`): Optional. Text that is shown when a user chooses an incorrect answer or taps on the lamp icon in a quiz-style poll, 0-200 characters.