Add async

This commit is contained in:
Rykov7
2023-10-28 22:34:20 +03:00
parent 588949e2b4
commit e8dbbfe5c5
2 changed files with 11 additions and 18 deletions
+8 -8
View File
@@ -12,29 +12,29 @@ from .get import me, my_ip
@bot.message_handler(commands=["me"]) @bot.message_handler(commands=["me"])
def command_me(message): async def command_me(message):
"""Send info about user and chat id [Service].""" """Send info about user and chat id [Service]."""
bot.send_message(message.chat.id, me(message)) await bot.send_message(message.chat.id, me(message))
@bot.message_handler(func=is_admin, commands=["ip"]) @bot.message_handler(func=is_admin, commands=["ip"])
def get_ip(message): async def get_ip(message):
bot.send_message(message.chat.id, my_ip()) await bot.send_message(message.chat.id, my_ip())
@bot.message_handler(commands=["remind"]) @bot.message_handler(commands=["remind"])
def remind_manually(message): async def remind_manually(message):
"""Remind holidays manually.""" """Remind holidays manually."""
args = message.text.split() args = message.text.split()
if len(args) > 1: if len(args) > 1:
try: try:
today = dt.strptime(args[1], "%m-%d-%Y") today = dt.strptime(args[1], "%m-%d-%Y")
except ValueError as ve: except ValueError as ve:
bot.send_message(message.chat.id, f"Не удалось разобрать дату!\n{ve}") await bot.send_message(message.chat.id, f"Не удалось разобрать дату!\n{ve}")
else: else:
reminder.remind(message.chat.id, today) await reminder.remind(message.chat.id, today)
else: else:
bot.send_message( await bot.send_message(
message.chat.id, message.chat.id,
f"<b>Формат даты: MM-DD-YYYY</b>\n\n" f"<b>Формат даты: MM-DD-YYYY</b>\n\n"
f"Примеры:\n" f"Примеры:\n"
+3 -10
View File
@@ -59,22 +59,15 @@ async def remove_stan_quote(message: types.Message):
if message.reply_to_message and message.reply_to_message.text: if message.reply_to_message and message.reply_to_message.text:
quote = html.escape(message.reply_to_message.text) quote = html.escape(message.reply_to_message.text)
already_exist = session.query(Quote).filter_by(text=quote, already_exist = session.query(Quote).filter_by(text=quote, chat_id=message.chat.id).first()
chat_id=message.chat.id).first()
if already_exist: if already_exist:
session.delete(already_exist) session.delete(already_exist)
session.commit() session.commit()
await bot.send_message( await bot.send_message(message.chat.id, f"✅ <b>Удалил</b>\n └ <i>{quote}</i>",)
message.chat.id,
f"✅ <b>Удалил</b>\n └ <i>{quote}</i>",
)
await bot.delete_message(message.chat.id, message.id) await bot.delete_message(message.chat.id, message.id)
else: else:
await bot.send_message( await bot.send_message(message.chat.id, f"⛔️ <b>Нет такого</b>\n └ <i>{quote}</i>",)
message.chat.id,
f"⛔️ <b>Нет такого</b>\n └ <i>{quote}</i>",
)
@bot.message_handler(func=is_nongrata) @bot.message_handler(func=is_nongrata)