mirror of
https://github.com/Arrowar/StreamingCommunity.git
synced 2025-06-07 12:05:35 +00:00
Update site.py
This commit is contained in:
parent
7ace94ad92
commit
ec95185bac
@ -1,13 +1,13 @@
|
|||||||
# 19.06.24
|
# 19.06.24
|
||||||
# Modifiche per integrare l'input da Telegram Bot
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
# External library
|
# External library
|
||||||
from rich.console import Console # Usata per output console
|
from rich.console import Console
|
||||||
|
|
||||||
|
|
||||||
# Internal utilities
|
# Internal utilities
|
||||||
|
|
||||||
from StreamingCommunity.Api.Template.config_loader import site_constant
|
from StreamingCommunity.Api.Template.config_loader import site_constant
|
||||||
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
from StreamingCommunity.TelegramHelp.telegram_bot import get_bot_instance
|
||||||
|
|
||||||
@ -37,7 +37,6 @@ def get_select_title(table_show_manager, media_search_manager, num_results_avail
|
|||||||
|
|
||||||
if site_constant.TELEGRAM_BOT:
|
if site_constant.TELEGRAM_BOT:
|
||||||
bot = get_bot_instance()
|
bot = get_bot_instance()
|
||||||
|
|
||||||
prompt_message = f"Inserisci il numero del titolo che vuoi selezionare (da 0 a {num_results_available - 1}):"
|
prompt_message = f"Inserisci il numero del titolo che vuoi selezionare (da 0 a {num_results_available - 1}):"
|
||||||
|
|
||||||
user_input_str = bot.ask(
|
user_input_str = bot.ask(
|
||||||
@ -55,22 +54,26 @@ def get_select_title(table_show_manager, media_search_manager, num_results_avail
|
|||||||
if 0 <= chosen_index < num_results_available:
|
if 0 <= chosen_index < num_results_available:
|
||||||
selected_item = media_search_manager.get(chosen_index)
|
selected_item = media_search_manager.get(chosen_index)
|
||||||
if selected_item:
|
if selected_item:
|
||||||
# bot.send_message(f"Hai selezionato: {selected_item.name}", None) # Messaggio di conferma opzionale
|
|
||||||
return selected_item
|
return selected_item
|
||||||
|
|
||||||
else:
|
else:
|
||||||
bot.send_message(f"Errore interno: Impossibile recuperare il titolo con indice {chosen_index}.", None)
|
bot.send_message(f"Errore interno: Impossibile recuperare il titolo con indice {chosen_index}.", None)
|
||||||
return None
|
return None
|
||||||
else:
|
else:
|
||||||
bot.send_message(f"Selezione '{chosen_index}' non valida. Inserisci un numero compreso tra 0 e {num_results_available - 1}.", None)
|
bot.send_message(f"Selezione '{chosen_index}' non valida. Inserisci un numero compreso tra 0 e {num_results_available - 1}.", None)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
bot.send_message(f"Input '{user_input_str}' non valido. Devi inserire un numero.", None)
|
bot.send_message(f"Input '{user_input_str}' non valido. Devi inserire un numero.", None)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
bot.send_message(f"Si è verificato un errore durante la selezione: {e}", None)
|
bot.send_message(f"Si è verificato un errore durante la selezione: {e}", None)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
# Logica originale per la console
|
||||||
if not media_search_manager.media_list:
|
if not media_search_manager.media_list:
|
||||||
console.print("\n[red]No media items available.")
|
console.print("\n[red]No media items available.")
|
||||||
return None
|
return None
|
||||||
@ -111,12 +114,15 @@ def get_select_title(table_show_manager, media_search_manager, num_results_avail
|
|||||||
try:
|
try:
|
||||||
|
|
||||||
selected_index = int(last_command_str)
|
selected_index = int(last_command_str)
|
||||||
|
|
||||||
if 0 <= selected_index < len(media_search_manager.media_list):
|
if 0 <= selected_index < len(media_search_manager.media_list):
|
||||||
return media_search_manager.get(selected_index)
|
return media_search_manager.get(selected_index)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
console.print("\n[red]Indice errato o non valido.")
|
console.print("\n[red]Indice errato o non valido.")
|
||||||
# sys.exit(0)
|
# sys.exit(0)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
console.print("\n[red]Input non numerico ricevuto dalla tabella.")
|
console.print("\n[red]Input non numerico ricevuto dalla tabella.")
|
||||||
# sys.exit(0)
|
# sys.exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user