inline keyboard and move to channel with threads
Signed-off-by: Omar Sánchez Pizarro <omar.sanchez@pistacero.net>
This commit is contained in:
@@ -19,14 +19,14 @@ class QueueManager:
|
||||
self._processor_thread = threading.Thread(target=self._process_queue, daemon=True)
|
||||
self._processor_thread.start()
|
||||
|
||||
def add_to_queue(self, article, search_name=None):
|
||||
def add_to_queue(self, article, search_name=None, thread_id=None):
|
||||
# Verificar si el artículo ya ha sido enviado
|
||||
if article in self._notified_articles:
|
||||
return
|
||||
|
||||
if search_name is None:
|
||||
search_name = "Unknown"
|
||||
self._queue.put((search_name, article))
|
||||
self._queue.put((search_name, article, thread_id))
|
||||
self.logger.debug(f"Artículo añadido a la cola: {article.get_title()}")
|
||||
|
||||
self.add_to_notified_articles(article)
|
||||
@@ -45,14 +45,13 @@ class QueueManager:
|
||||
try:
|
||||
# Esperar hasta que haya un elemento en la cola (timeout de 1 segundo)
|
||||
try:
|
||||
search_name, article = self._queue.get(timeout=1.0)
|
||||
search_name, article, thread_id = self._queue.get(timeout=1.0)
|
||||
except queue.Empty:
|
||||
continue
|
||||
|
||||
# Procesar el artículo
|
||||
try:
|
||||
self._telegram_manager.send_telegram_article(search_name, article)
|
||||
self.logger.info(f"Artículo enviado a Telegram: {article.get_title()} de {search_name}")
|
||||
self._telegram_manager.send_telegram_article(search_name, article, thread_id)
|
||||
|
||||
# Mantener solo los primeros NOTIFIED_ARTICLES_LIMIT artículos después de enviar
|
||||
if len(self._notified_articles) > NOTIFIED_ARTICLES_LIMIT:
|
||||
|
||||
Reference in New Issue
Block a user