Skip to content

Commit

Permalink
Merge pull request #59 from ZhuchkaTriplesix/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ZhuchkaTriplesix authored Nov 7, 2023
2 parents f680e57 + 9f2d38f commit 44a2321
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
26 changes: 26 additions & 0 deletions handlers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@
router = Router()


# test commit

class ChangeAccessState(StatesGroup):
get_user_id_state = State()
add_admin_id_state = State()
delete_admin_state = State()
del_item_state = State()


@router.message(F.text == "/admin")
Expand Down Expand Up @@ -124,3 +127,26 @@ async def admin_list(message: Message):
x = f"@{admin.username}: {admin.telegram_id} Admin\n"
bot_message += x
await message.answer(bot_message)


@router.message(F.text == "/del_item")
async def del_item(message: Message, state: FSMContext):
if models.Users.check_admin(message.from_user.id) is True:
await message.answer("Введите айди.хешнейм")
await state.set_state(ChangeAccessState.del_item_state)
else:
await message.answer("У вас нет доступа.")


@router.message(ChangeAccessState.del_item_state, F.text)
async def del_item_state(message: Message, state: FSMContext):
mes = message.text.split(".")
hash_name = mes[1]
try:
telegram_id = int(mes[0])
models.Items.delete_item(telegram_id, hash_name)
await message.answer("Вы удалили предмет у пользователя.")
await state.clear()
except ValueError:
await message.answer("Неверный ввод.")
await state.clear()
3 changes: 2 additions & 1 deletion models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Items(Base):
__tablename__ = "items"
id = Column(Integer, primary_key=True)
user_id = Column(Integer)
hash_name = Column(String(length=30))
hash_name = Column(String(length=60))
item_count = Column(Integer)

def add_item(telegram_id: int, hash_name: str, item_count: int):
Expand Down Expand Up @@ -130,6 +130,7 @@ def delete_item(telegram_id: int, hash_name: str):
item = session.query(Items).filter(Items.hash_name == hash_name).where(Items.user_id == user_id).first()
session.delete(item)
session.commit()
session.close()


# noinspection PyShadowingNames,PyMethodParameters
Expand Down
31 changes: 31 additions & 0 deletions user_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,36 @@
"Clutch Case",
"Danger Zone Case",
"CS20 Case"
],
"1312583149": [
"CS:GO Weapon Case",
"eSports 2013 Case",
"Operation Bravo Case",
"CS:GO Weapon Case 2",
"eSports 2013 Winter Case",
"Winter Offensive Weapon Case",
"Operation Phoenix Weapon Case",
"Huntsman Weapon Case",
"Operation Breakout Weapon Case",
"CS:GO Weapon Case 3",
"eSports 2014 Summer Case",
"Shadow Case",
"Revolver Case",
"Chroma 3 Case",
"Operation Wildfire Case",
"Gamma Case",
"Operation Hydra Case",
"Spectrum 2 Case",
"Clutch Case",
"Spectrum Case",
"Glove Case",
"Horizon Case",
"Prisma Case",
"Danger Zone Case",
"CS20 Case",
"Shattered Web Case",
"Dreams & Nightmares Case",
"Recoil Case",
"Revolution Case"
]
}

0 comments on commit 44a2321

Please sign in to comment.