async def create_handler(message: Message): title = message.text[8:] if title.replace(" ", "") == "": await message.reply("Empty title. Use /create [text]\n", reply=False) return session = Session() time = datetime.now() chat = get_chat(session, message.chat.id) delta = timedelta(minutes=chat.default_time) time += delta seconds = timedelta(time.second) time -= seconds queue = Queue(creator_id=message.from_user.id, message_id=message.message_id, pin_date=time, title=title, chat_id=message.chat.id) session.add(queue) session.commit() session.close() await message.reply( f"{title}\n\nPublication time: {time.strftime('%H:%M, %d.%m.%Y')}", reply=False)
import os from typing import List from telebot.types import Message from database import Queue from keyboard import * from scraping_habr import get_articles, add_new_articles bot = telebot.TeleBot(os.getenv("BOT_TOKEN")) queue = Queue() NAME_DB = 'habr.db' ARTICLE_TABLE = 'habr_db' NEWS_TABLE = 'news' ARTICLE_URL = "https://habr.com/ru/all/" NEWS_URL = 'https://habr.com/ru/news/' def main(message: Message) -> None: """ The main function of queue """ text = message.text.lower() if text == "удалить первого" and is_admin(message): delete_first(queue, message) if text == "очистить очередь" and is_admin(message): clear_queue(queue, message) if text == "стать в очередь": get_in_line(queue, message) if text == "посмотреть": view_queue(queue, message)