mirror of
https://github.com/dizedev/vk_lp.git
synced 2026-09-17 05:09:00 +00:00
edit achievements
This commit is contained in:
@@ -13,3 +13,19 @@ class UsersTokens(Base):
|
||||
primary_key=True)
|
||||
vkid = Column("vkid", BigInteger, nullable=False, unique=True)
|
||||
token = Column("token", Text, nullable=False)
|
||||
|
||||
|
||||
class UsersProfile(Base):
|
||||
__tablename__ = "users_profile"
|
||||
|
||||
# TODO: think about foreign_id
|
||||
id = Column("id", BigInteger, Identity(start=1, increment=1, minvalue=1, cycle=False, cache=1), nullable=False,
|
||||
primary_key=True)
|
||||
vkid = Column("vkid", BigInteger, nullable=False, unique=True)
|
||||
# TODO: fill items below
|
||||
achievements = Column()
|
||||
trusted_ids = Column()
|
||||
prefix = Column()
|
||||
prefix_d = Column()
|
||||
prefix_delete = Column()
|
||||
last_login = Column()
|
||||
|
||||
@@ -36,3 +36,19 @@ async def get_user_token(user_id: int) -> Optional[db.models.UsersTokens]:
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
return None
|
||||
|
||||
|
||||
async def get_user_profile(user_id: int) -> Optional[db.models.UsersProfile]:
|
||||
"""
|
||||
Получает профиль пользователя
|
||||
:param user_id: VKID
|
||||
"""
|
||||
|
||||
try:
|
||||
async with db.config.async_session() as session:
|
||||
result = await session.execute(select(db.models.UsersProfile).where(db.models.UsersProfile.vkid == user_id))
|
||||
return result.scalars().one_or_none()
|
||||
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
return None
|
||||
|
||||
+27
-5
@@ -1,14 +1,36 @@
|
||||
from vkbottle.user import Message, UserLabeler
|
||||
|
||||
import db
|
||||
import utils
|
||||
from config import edit_message, prefix_bot
|
||||
from custom_rules.permission import Permission
|
||||
import utils
|
||||
|
||||
|
||||
bl = UserLabeler()
|
||||
|
||||
|
||||
@bl.message(Permission(), text=[prefix_bot + " достижения"])
|
||||
async def rewards_cmd(message: Message):
|
||||
await edit_message(message,
|
||||
f"Вот список всех достижений 🏆:\n{utils.next_line_symbol.join(utils.rewards)}")
|
||||
async def rewards_cmd(ctx: Message):
|
||||
text = "Список всех достижений:\n\n"
|
||||
have_ = ""
|
||||
dont_have = ""
|
||||
info = await db.requests.get_user_profile(user_id=ctx.from_id)
|
||||
|
||||
# TODO: CHECK BEFORE DEPLOY!!
|
||||
# TODO: create table in db
|
||||
# TODO: fill items in models.py
|
||||
|
||||
for item in info.achievements:
|
||||
if item in utils.rewards.keys():
|
||||
have_ += f"{utils.rewards[item]}\n"
|
||||
else:
|
||||
dont_have += f"{utils.rewards[item]}\n"
|
||||
|
||||
if have_ != "":
|
||||
text += "Открытые:\n"
|
||||
text += have_
|
||||
|
||||
if dont_have != "":
|
||||
text += "Неоткрытые:\n"
|
||||
text += dont_have
|
||||
|
||||
await edit_message(ctx, text)
|
||||
|
||||
Reference in New Issue
Block a user