add removing quotes
This commit is contained in:
+20
-20
@@ -36,7 +36,8 @@ def act(message: types.Message):
|
|||||||
@bot.message_handler(func=is_white, commands=["add"])
|
@bot.message_handler(func=is_white, commands=["add"])
|
||||||
def add_stan_quote(message: types.Message):
|
def add_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:
|
||||||
if message.reply_to_message.text not in [i[0] for i in session.query(Quote.text).all()]:
|
if message.reply_to_message.text not in [i[0] for i in session.query(Quote.text).filter(
|
||||||
|
Quote.chat_id == message.chat.id).all()]:
|
||||||
session.add(Quote(chat_id=message.chat.id, text=message.reply_to_message.text.replace("\n", " ")))
|
session.add(Quote(chat_id=message.chat.id, text=message.reply_to_message.text.replace("\n", " ")))
|
||||||
session.commit()
|
session.commit()
|
||||||
bot.send_message(
|
bot.send_message(
|
||||||
@@ -52,25 +53,24 @@ def add_stan_quote(message: types.Message):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# @bot.message_handler(func=is_white, commands=["remove"])
|
@bot.message_handler(func=is_white, commands=["remove"])
|
||||||
# def remove_stan_quote(message):
|
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:
|
||||||
# if message.reply_to_message.text in (
|
quote = session.query(Quote).filter_by(text=message.reply_to_message.text,
|
||||||
# i.rstrip() for i in open("Stan.txt", "r", encoding="utf8")
|
chat_id=message.chat.id).first()
|
||||||
# ):
|
if quote:
|
||||||
# quotes = list(open("Stan.txt", "r", encoding="utf8"))
|
session.delete(quote)
|
||||||
# with open("Stan.txt", "w", encoding="utf8") as stan_quotes:
|
session.commit()
|
||||||
# quotes.remove(message.reply_to_message.text + "\n")
|
|
||||||
# stan_quotes.writelines(quotes)
|
bot.send_message(
|
||||||
# bot.send_message(
|
message.chat.id,
|
||||||
# message.chat.id,
|
f"✅ <b>Удалил</b>\n └ <i>{message.reply_to_message.text}</i>",
|
||||||
# f"✅ <b>Удалил</b>\n └ <i>{message.reply_to_message.text}</i>",
|
)
|
||||||
# )
|
else:
|
||||||
# else:
|
bot.send_message(
|
||||||
# bot.send_message(
|
message.chat.id,
|
||||||
# message.chat.id,
|
f"⛔️ <b>Нет такого</b>\n └ <i>{message.reply_to_message.text}</i>",
|
||||||
# f"⛔️ <b>Нет такого</b>\n └ <i>{message.reply_to_message.text}</i>",
|
)
|
||||||
# )
|
|
||||||
|
|
||||||
|
|
||||||
@bot.message_handler(func=is_nongrata)
|
@bot.message_handler(func=is_nongrata)
|
||||||
|
|||||||
Reference in New Issue
Block a user