Skip to content

Commit 5d74e18

Browse files
authored
Merge pull request eternnoir#1550 from Badiboy/master
Poll type parameter parse fix
2 parents 6e4c63b + 91b665e commit 5d74e18

File tree

4 files changed

+18
-13
lines changed

4 files changed

+18
-13
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,5 @@ OS:
1010

1111
## Checklist:
1212
- [ ] I added/edited example on new feature/change (if exists)
13-
- [ ] My changes won't break backend compatibility
14-
- [ ] I made changes for async and sync
15-
13+
- [ ] My changes won't break backward compatibility
14+
- [ ] I made changes both for sync and async

telebot/asyncio_storage/redis_storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ async def get_record(self, key):
3535
"""
3636
Function to get record from database.
3737
It has nothing to do with states.
38-
Made for backend compatibility
38+
Made for backward compatibility
3939
"""
4040
result = await self.redis.get(self.prefix+str(key))
4141
if result: return json.loads(result)
@@ -45,7 +45,7 @@ async def set_record(self, key, value):
4545
"""
4646
Function to set record to database.
4747
It has nothing to do with states.
48-
Made for backend compatibility
48+
Made for backward compatibility
4949
"""
5050

5151
await self.redis.set(self.prefix+str(key), json.dumps(value))
@@ -55,7 +55,7 @@ async def delete_record(self, key):
5555
"""
5656
Function to delete record from database.
5757
It has nothing to do with states.
58-
Made for backend compatibility
58+
Made for backward compatibility
5959
"""
6060
await self.redis.delete(self.prefix+str(key))
6161
return True

telebot/storage/redis_storage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_record(self, key):
2828
"""
2929
Function to get record from database.
3030
It has nothing to do with states.
31-
Made for backend compatibility
31+
Made for backward compatibility
3232
"""
3333
connection = Redis(connection_pool=self.redis)
3434
result = connection.get(self.prefix+str(key))
@@ -40,7 +40,7 @@ def set_record(self, key, value):
4040
"""
4141
Function to set record to database.
4242
It has nothing to do with states.
43-
Made for backend compatibility
43+
Made for backward compatibility
4444
"""
4545
connection = Redis(connection_pool=self.redis)
4646
connection.set(self.prefix+str(key), json.dumps(value))
@@ -51,7 +51,7 @@ def delete_record(self, key):
5151
"""
5252
Function to delete record from database.
5353
It has nothing to do with states.
54-
Made for backend compatibility
54+
Made for backward compatibility
5555
"""
5656
connection = Redis(connection_pool=self.redis)
5757
connection.delete(self.prefix+str(key))

telebot/types.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,23 +2774,29 @@ def de_json(cls, json_string):
27742774
obj['explanation_entities'] = Message.parse_entities(obj['explanation_entities'])
27752775
return cls(**obj)
27762776

2777+
# noinspection PyShadowingBuiltins
27772778
def __init__(
27782779
self,
27792780
question, options,
2780-
poll_id=None, total_voter_count=None, is_closed=None, is_anonymous=None, poll_type=None,
2781+
poll_id=None, total_voter_count=None, is_closed=None, is_anonymous=None, type=None,
27812782
allows_multiple_answers=None, correct_option_id=None, explanation=None, explanation_entities=None,
2782-
open_period=None, close_date=None, **kwargs):
2783+
open_period=None, close_date=None, poll_type=None, **kwargs):
27832784
self.id: str = poll_id
27842785
self.question: str = question
27852786
self.options: List[PollOption] = options
27862787
self.total_voter_count: int = total_voter_count
27872788
self.is_closed: bool = is_closed
27882789
self.is_anonymous: bool = is_anonymous
2789-
self.type: str = poll_type
2790+
self.type: str = type
2791+
if poll_type is not None:
2792+
# Wrong param name backward compatibility
2793+
logger.warning("Poll: poll_type parameter is deprecated. Use type instead.")
2794+
if type is None:
2795+
self.type: str = poll_type
27902796
self.allows_multiple_answers: bool = allows_multiple_answers
27912797
self.correct_option_id: int = correct_option_id
27922798
self.explanation: str = explanation
2793-
self.explanation_entities: List[MessageEntity] = explanation_entities # Default state of entities is None. if (explanation_entities is not None) else []
2799+
self.explanation_entities: List[MessageEntity] = explanation_entities
27942800
self.open_period: int = open_period
27952801
self.close_date: int = close_date
27962802

0 commit comments

Comments
 (0)