@admin_router.message(Command('proportions'))
@check_is_admin
async def proportions(
message: Message,
state: FSMContext,
keep_last_msg: bool = False
):
"""
Handles the 'proportions' command. Receive a str value from admin and
triggers the calculate_proportion function.
:param state:
:param keep_last_msg:
:param message:
:return: None
"""
if not keep_last_msg:
await message.delete()
await sleep(DEL_TIME)
await state.set_state(ProportionStates.waiting_for_proportion_input)
sent_message = await message.answer(
text='Введите через пробел: '
'\nПропорции компонентов '
'<b>A</b> и <b>B</b>, '
'и общую массу - <b>C</b>'
)
await record_message_id_to_db(sent_message)
@admin_router.callback_query(F.data == 'another_proportion')
async def callback_proportion(callback: CallbackQuery, state: FSMContext):
await callback.answer()
await proportions(callback.message, state=state, keep_last_msg=True)
9. Termination
Failure to comply with these Terms or the Telegram Terms of Service may result in a temporary or a permanent ban from Bot Platform or Telegram apps. In such instances, your TPA will be removed from Bot Platform and become partially or fully inaccessible to some or all users. Should we have reason to do so, at our sole discretion, the Telegram account tied to your TPA may also be banned from the Telegram platform. You will not be compensated for any direct or indirect losses resulting from your termination.
9.1. Unilateral Termination
Telegram can decide to fully or partially discontinue TPA or Bot Platform at any time, including in response to unforeseen circumstances beyond our control. This includes but is not limited to discontinuation in specific regions, for certain users, or removing a subset of services and features. For clarity, we make no guarantee of ongoing or continued support for this program.
9.2. Survivability
If any part of these Bot Developer Terms is found to be void, invalid, or unenforceable, that provision will be enforced to the maximum extent allowed under applicable law, and will not impact the rest of the terms herein.
The following paragraphs will continue to apply and survive the termination of Bot Platform and, by extension, of these Bot Developer Terms: 2.1., 4.2., 4.4., 5, 5.1., 5.2., 6.1., 6.2., 6.3., 6.4., 7., 7.2., 8., 8.1., 11. and 11.2..
def morning_routine():
"""
Delete old message IDs from the DB. Telegram's policy doesn't allow bots
to delete messages that are older than 48 hours. Wake's up a little bit
slow, to give the database time to fully load.
:return: Nothing
"""
sleep(5)
session = Session(engine)
threshold = datetime.now() - timedelta(hours=48)
stmt = delete(Message).where(
Message.date_added < threshold.strftime('%Y-%m-%d %H:%M:%S')
)
try:
session.execute(stmt)
session.commit()
except ProgrammingError:
subprocess.run(
'alembic revision --autogenerate -m "Initial migration"',
shell=True
)
subprocess.run('alembic upgrade head', shell=True)
finally:
session.close()