-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlookout_result.py
More file actions
46 lines (39 loc) · 1.51 KB
/
lookout_result.py
File metadata and controls
46 lines (39 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# lookout_result.py
"""Lookout Result Module - Sexy Terminal Output for Username Checking"""
from enum import Enum
from datetime import datetime
from colorama import Fore, Style, init
init(autoreset=True)
class QueryStatus(Enum):
CLAIMED = "Claimed"
AVAILABLE = "Available"
UNKNOWN = "Unknown"
ILLEGAL = "Illegal"
BLOCKED = "Blocked"
def __str__(self):
return self.value
class QueryResult:
"""A single username query result with extra flair."""
def __init__(self, username, site, url, status, query_time=None, context=None):
self.username = username
self.site = site
self.url = url
self.status = status
self.query_time = query_time
self.context = context
self.timestamp = datetime.now()
def __str__(self):
color_map = {
QueryStatus.CLAIMED: Fore.RED + Style.BRIGHT,
QueryStatus.AVAILABLE: Fore.GREEN + Style.BRIGHT,
QueryStatus.UNKNOWN: Fore.YELLOW + Style.BRIGHT,
QueryStatus.ILLEGAL: Fore.MAGENTA + Style.BRIGHT,
QueryStatus.BLOCKED: Fore.CYAN + Style.BRIGHT,
}
color = color_map.get(self.status, "")
base = f"[{self.timestamp.strftime('%H:%M:%S')}] {self.site}: {self.username} → {self.status}"
if self.context:
base += f" ({self.context})"
if self.query_time:
base += f" | {self.query_time:.2f}s"
return color + base + Style.RESET_ALL