1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Merge pull request #1550 from Badiboy/master

Poll type parameter parse fix
This commit is contained in:
Badiboy 2022-05-15 01:06:04 +03:00 committed by GitHub
commit 5d74e18d1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 13 deletions

View File

@ -10,6 +10,5 @@ OS:
## Checklist: ## Checklist:
- [ ] I added/edited example on new feature/change (if exists) - [ ] I added/edited example on new feature/change (if exists)
- [ ] My changes won't break backend compatibility - [ ] My changes won't break backward compatibility
- [ ] I made changes for async and sync - [ ] I made changes both for sync and async

View File

@ -35,7 +35,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to get record from database. Function to get record from database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
result = await self.redis.get(self.prefix+str(key)) result = await self.redis.get(self.prefix+str(key))
if result: return json.loads(result) if result: return json.loads(result)
@ -45,7 +45,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to set record to database. Function to set record to database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
await self.redis.set(self.prefix+str(key), json.dumps(value)) await self.redis.set(self.prefix+str(key), json.dumps(value))
@ -55,7 +55,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to delete record from database. Function to delete record from database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
await self.redis.delete(self.prefix+str(key)) await self.redis.delete(self.prefix+str(key))
return True return True

View File

@ -28,7 +28,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to get record from database. Function to get record from database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
connection = Redis(connection_pool=self.redis) connection = Redis(connection_pool=self.redis)
result = connection.get(self.prefix+str(key)) result = connection.get(self.prefix+str(key))
@ -40,7 +40,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to set record to database. Function to set record to database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
connection = Redis(connection_pool=self.redis) connection = Redis(connection_pool=self.redis)
connection.set(self.prefix+str(key), json.dumps(value)) connection.set(self.prefix+str(key), json.dumps(value))
@ -51,7 +51,7 @@ class StateRedisStorage(StateStorageBase):
""" """
Function to delete record from database. Function to delete record from database.
It has nothing to do with states. It has nothing to do with states.
Made for backend compatibility Made for backward compatibility
""" """
connection = Redis(connection_pool=self.redis) connection = Redis(connection_pool=self.redis)
connection.delete(self.prefix+str(key)) connection.delete(self.prefix+str(key))

View File

@ -2774,23 +2774,29 @@ class Poll(JsonDeserializable):
obj['explanation_entities'] = Message.parse_entities(obj['explanation_entities']) obj['explanation_entities'] = Message.parse_entities(obj['explanation_entities'])
return cls(**obj) return cls(**obj)
# noinspection PyShadowingBuiltins
def __init__( def __init__(
self, self,
question, options, question, options,
poll_id=None, total_voter_count=None, is_closed=None, is_anonymous=None, poll_type=None, poll_id=None, total_voter_count=None, is_closed=None, is_anonymous=None, type=None,
allows_multiple_answers=None, correct_option_id=None, explanation=None, explanation_entities=None, allows_multiple_answers=None, correct_option_id=None, explanation=None, explanation_entities=None,
open_period=None, close_date=None, **kwargs): open_period=None, close_date=None, poll_type=None, **kwargs):
self.id: str = poll_id self.id: str = poll_id
self.question: str = question self.question: str = question
self.options: List[PollOption] = options self.options: List[PollOption] = options
self.total_voter_count: int = total_voter_count self.total_voter_count: int = total_voter_count
self.is_closed: bool = is_closed self.is_closed: bool = is_closed
self.is_anonymous: bool = is_anonymous self.is_anonymous: bool = is_anonymous
self.type: str = poll_type self.type: str = type
if poll_type is not None:
# Wrong param name backward compatibility
logger.warning("Poll: poll_type parameter is deprecated. Use type instead.")
if type is None:
self.type: str = poll_type
self.allows_multiple_answers: bool = allows_multiple_answers self.allows_multiple_answers: bool = allows_multiple_answers
self.correct_option_id: int = correct_option_id self.correct_option_id: int = correct_option_id
self.explanation: str = explanation self.explanation: str = explanation
self.explanation_entities: List[MessageEntity] = explanation_entities # Default state of entities is None. if (explanation_entities is not None) else [] self.explanation_entities: List[MessageEntity] = explanation_entities
self.open_period: int = open_period self.open_period: int = open_period
self.close_date: int = close_date self.close_date: int = close_date