-
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: ahora se guarda el estado de noticias_automaticas y si estaba p…
…rendido, al revivir el bot se setean automaticamente; otros cambios menores
- Loading branch information
Showing
9 changed files
with
86 additions
and
31 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
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,30 @@ | ||
import os | ||
import json | ||
|
||
ESTADO_DEFAULT_JSON = { | ||
"noticias_automaticas": False | ||
} | ||
|
||
|
||
class EstadoRepository: | ||
def __init__(self, path: str = "estado.json"): | ||
if not os.path.exists(path): | ||
with open(path, "w", encoding='utf-8') as f: | ||
json.dump(ESTADO_DEFAULT_JSON, f, indent=4) | ||
|
||
self.path = path | ||
|
||
def noticias_automaticas(self) -> bool: | ||
estado = {} | ||
with open(self.path, 'r', encoding='utf-8') as f: | ||
estado = json.load(f) | ||
|
||
return estado.get("noticias_automaticas", False) | ||
|
||
def guardar(self, noticias_automaticas) -> None: | ||
estado = { | ||
"noticias_automaticas": noticias_automaticas | ||
} | ||
|
||
with open(self.path, "w", encoding='utf-8') as f: | ||
json.dump(estado, f, indent=4) |
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