mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-08 17:13:56 +00:00
Merge pull request #74 from heyyyoyy/dev-2.x
Fixed update_data and update_bucket methods if dict is None
This commit is contained in:
commit
61f3e3c8a1
1 changed files with 4 additions and 0 deletions
|
|
@ -141,6 +141,8 @@ class RedisStorage(BaseStorage):
|
|||
|
||||
async def update_data(self, *, chat: typing.Union[str, int, None] = None, user: typing.Union[str, int, None] = None,
|
||||
data: typing.Dict = None, **kwargs):
|
||||
if data is None:
|
||||
data = {}
|
||||
record = await self.get_record(chat=chat, user=user)
|
||||
record_data = record.get('data', {})
|
||||
record_data.update(data, **kwargs)
|
||||
|
|
@ -195,6 +197,8 @@ class RedisStorage(BaseStorage):
|
|||
bucket: typing.Dict = None, **kwargs):
|
||||
record = await self.get_record(chat=chat, user=user)
|
||||
record_bucket = record.get('bucket', {})
|
||||
if bucket is None:
|
||||
bucket = {}
|
||||
record_bucket.update(bucket, **kwargs)
|
||||
await self.set_record(chat=chat, user=user, state=record['state'], data=record_bucket, bucket=bucket)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue