-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: agrego comando para pasar url a noticia; refactor de la view, l…
…os mensaje internos los maneja CindyMoon
- Loading branch information
Showing
11 changed files
with
105 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class URLNoPerteneceADominioException(Exception): | ||
def __init__(self, dominio, url) -> None: | ||
self.message = "{url} no pertenece al dominio {dominio}".format(url=url, dominio=dominio) | ||
super().__init__(self.message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from view.interno import Interno | ||
from entities.noticia import Noticia | ||
from telegram import ParseMode, Chat | ||
from error_handler import logging | ||
from view.contants import * | ||
|
||
class CindyMoon(Interno): | ||
def __init__(self): | ||
self.logger = logging.getLogger(__class__.__name__) | ||
|
||
def notificar_noticias_automaticas(self, chat: Chat, estado_actual: bool = False, estado_anterior: bool = False) -> None: | ||
message = "Las noticias automáticas no están activadas." | ||
|
||
if estado_actual != estado_anterior: | ||
if estado_actual: | ||
message = "Se activaron las noticias automáticas." | ||
else: | ||
message = "Se desactivaron las noticias automáticas." | ||
elif estado_actual: | ||
message = "Las noticias automáticas ya están activadas." | ||
|
||
chat.send_message(message) | ||
|
||
def notificar_estado(self, chat: Chat, noticias_automaticas: bool) -> None: | ||
chat.send_message("Noticias automáticas: {noticias_automaticas}".format(noticias_automaticas=noticias_automaticas)) | ||
|
||
def enviar_noticia(self, chat: Chat, noticia: Noticia) -> None: | ||
chat.send_message(FORMATO_MENSAJE.format(titulo=noticia.titulo, | ||
descripcion=noticia.descripcion, | ||
url=noticia.url, | ||
texto_url=MAS_INFORMACION), | ||
parse_mode=ParseMode.HTML) | ||
|
||
def ayuda(self, chat: Chat) -> None: | ||
chat.send_message("/noticias <n> - trae las últimas 'n' noticias\n" | ||
+ "/convertir <url> - convierte la noticia\n" | ||
+ "/empezar - activa las noticias automáticas en el canal de noticias\n" | ||
+ "/terminar - desactiva las noticias automáticas en el canal de noticias\n" | ||
+ "/estado - muestra el estado del bot\n" | ||
+ "/ayuda - imprime este mensaje\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from emoji import emojize | ||
|
||
MAS_INFORMACION = emojize(":information: Más información") | ||
FORMATO_MENSAJE = "<b>{titulo}</b>\n\n{descripcion}\n\n<a href=\"{url}\">{texto_url}</a>\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,20 @@ | ||
# Cindy Moon | ||
from abc import ABC, abstractclassmethod | ||
from telegram import Chat | ||
from entities.noticia import Noticia | ||
|
||
class Interno(ABC): | ||
@abstractclassmethod | ||
def notificar_noticias_automaticas(self, chat: Chat, estado_actual: bool, estado_anterior: bool) -> None: | ||
pass | ||
|
||
@abstractclassmethod | ||
def notificar_estado(self, chat: Chat, noticias_automaticas: bool) -> None: | ||
pass | ||
|
||
@abstractclassmethod | ||
def enviar_noticia(self, chat: Chat, noticia: Noticia) -> None: | ||
pass | ||
|
||
@abstractclassmethod | ||
def ayuda(self, chat: Chat) -> None: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters