Skip to content

Commit 9df16a2

Browse files
authored
Made Cipheys output more friendly and fixed the what bug (#632)
1 parent 35e3de8 commit 9df16a2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

ciphey/basemods/Checkers/human.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
from typing import Dict, Optional
2+
import os
3+
from rich.console import Console
4+
5+
console = Console()
26

37
from ciphey.iface import Checker, Config, ParamSpec, registry
48

@@ -11,8 +15,9 @@ def getParams() -> Optional[Dict[str, ParamSpec]]:
1115

1216
def check(self, text: str) -> Optional[str]:
1317
with self._config().pause_spinner_handle():
14-
response = input(f"Result {text.__repr__()} (y/N): ").lower()
18+
response = console.input(f"Result [blue bold]{text.__repr__()}[/blue bold] ([green]y[/green]/[red]N[/red]): ")
1519
if response == "y":
20+
self.clear_terminal()
1621
return ""
1722
elif response in ("n", ""):
1823
return None
@@ -24,3 +29,7 @@ def getExpectedRuntime(self, text: str) -> float:
2429

2530
def __init__(self, config: Config):
2631
super().__init__(config)
32+
33+
def clear_terminal(self):
34+
# https://stackoverflow.com/a/2084628
35+
os.system('cls' if os.name == 'nt' else 'clear')

ciphey/basemods/Checkers/what.py

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
from ciphey.iface import Checker, Config, ParamSpec, T, registry
44
from loguru import logger
55
from pywhat import identifier
6+
from rich.console import Console
7+
8+
console = Console()
69

710

811
@registry.register
@@ -16,6 +19,7 @@ def check(self, ctext: T) -> Optional[str]:
1619
logger.trace("Trying PyWhat checker")
1720
returned_regexes = self.id.identify(ctext, api=True)
1821
if len(returned_regexes["Regexes"]) > 0:
22+
console.print(f'\nI think the plaintext is a [yellow]{returned_regexes["Regexes"][0]["Regex Pattern"]["Name"]}[/yellow]')
1923
return returned_regexes["Regexes"][0]["Regex Pattern"]["Name"]
2024
return None
2125

0 commit comments

Comments
 (0)