mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-08 21:15:46 +08:00
🐛 修复更新订阅方法
This commit is contained in:
parent
82272c3b19
commit
36e69aab0f
@ -1,4 +1,4 @@
|
|||||||
from typing import List, Literal, Optional
|
from typing import Dict, List, Union, Literal, Optional
|
||||||
|
|
||||||
from gsuid_core.models import Event
|
from gsuid_core.models import Event
|
||||||
from gsuid_core.utils.database.models import Subscribe
|
from gsuid_core.utils.database.models import Subscribe
|
||||||
@ -38,21 +38,19 @@ class GsCoreSubscribe:
|
|||||||
|
|
||||||
`await GsCoreSubscribe.add_subscribe('single', '签到', event)`
|
`await GsCoreSubscribe.add_subscribe('single', '签到', event)`
|
||||||
'''
|
'''
|
||||||
opt = {
|
opt: Dict[str, Union[str, int, None]] = {
|
||||||
'bot_id': event.bot_id,
|
'bot_id': event.bot_id,
|
||||||
'task_name': task_name,
|
'task_name': task_name,
|
||||||
}
|
}
|
||||||
if subscribe_type == 'session' and event.user_type == 'group':
|
if subscribe_type == 'session' and event.user_type == 'group':
|
||||||
condi = await Subscribe.data_exist(
|
opt['group_id'] = event.group_id
|
||||||
group_id=event.group_id,
|
opt['user_type'] = event.user_type
|
||||||
user_type=event.user_type,
|
|
||||||
**opt,
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
condi = await Subscribe.data_exist(
|
opt['user_id'] = event.user_id
|
||||||
user_id=event.user_id,
|
|
||||||
**opt,
|
condi = await Subscribe.data_exist(
|
||||||
)
|
**opt,
|
||||||
|
)
|
||||||
|
|
||||||
if not condi:
|
if not condi:
|
||||||
await Subscribe.full_insert_data(
|
await Subscribe.full_insert_data(
|
||||||
@ -65,14 +63,22 @@ class GsCoreSubscribe:
|
|||||||
extra_message=extra_message,
|
extra_message=extra_message,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
await Subscribe.update_data(
|
upd = {}
|
||||||
user_id=event.user_id,
|
for i in [
|
||||||
bot_id=event.bot_id,
|
'user_id',
|
||||||
group_id=event.group_id,
|
'bot_id',
|
||||||
task_name=task_name,
|
'group_id',
|
||||||
bot_self_id=event.bot_self_id,
|
'task_name',
|
||||||
user_type=event.user_type,
|
'bot_self_id',
|
||||||
extra_message=extra_message,
|
'user_type',
|
||||||
|
'extra_message',
|
||||||
|
]:
|
||||||
|
if i not in opt:
|
||||||
|
upd[i] = event.__getattribute__(i)
|
||||||
|
|
||||||
|
await Subscribe.update_data_by_data(
|
||||||
|
opt,
|
||||||
|
upd,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def get_subscribe(self, task_name: str):
|
async def get_subscribe(self, task_name: str):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user