GiveYouAMail 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- giveyouamail-1.0.0/GiveYouAMail.egg-info/PKG-INFO +9 -0
- giveyouamail-1.0.0/GiveYouAMail.egg-info/SOURCES.txt +10 -0
- giveyouamail-1.0.0/GiveYouAMail.egg-info/dependency_links.txt +1 -0
- giveyouamail-1.0.0/GiveYouAMail.egg-info/entry_points.txt +2 -0
- giveyouamail-1.0.0/GiveYouAMail.egg-info/requires.txt +1 -0
- giveyouamail-1.0.0/GiveYouAMail.egg-info/top_level.txt +1 -0
- giveyouamail-1.0.0/PKG-INFO +9 -0
- giveyouamail-1.0.0/README.md +1 -0
- giveyouamail-1.0.0/gyam/30MMCLI.py +98 -0
- giveyouamail-1.0.0/gyam/__init__.py +1 -0
- giveyouamail-1.0.0/setup.cfg +4 -0
- giveyouamail-1.0.0/setup.py +2 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
setup.py
|
|
3
|
+
GiveYouAMail.egg-info/PKG-INFO
|
|
4
|
+
GiveYouAMail.egg-info/SOURCES.txt
|
|
5
|
+
GiveYouAMail.egg-info/dependency_links.txt
|
|
6
|
+
GiveYouAMail.egg-info/entry_points.txt
|
|
7
|
+
GiveYouAMail.egg-info/requires.txt
|
|
8
|
+
GiveYouAMail.egg-info/top_level.txt
|
|
9
|
+
gyam/30MMCLI.py
|
|
10
|
+
gyam/__init__.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
requests
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
gyam
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# GiveYouAMail
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
import requests, time, os, sys, tty, termios, json, re
|
|
3
|
+
|
|
4
|
+
API_URL = "https://api.mail.tm"
|
|
5
|
+
|
|
6
|
+
class TUI:
|
|
7
|
+
def __init__(self, email, token, name):
|
|
8
|
+
self.email, self.token, self.name = email, token, name
|
|
9
|
+
self.messages, self.selected, self.action_idx, self.running = [], 0, 0, True
|
|
10
|
+
|
|
11
|
+
def fetch(self):
|
|
12
|
+
try:
|
|
13
|
+
h = {"Authorization": f"Bearer {self.token}"}
|
|
14
|
+
res = requests.get(f"{API_URL}/messages", headers=h).json()
|
|
15
|
+
self.messages = res.get('hydra:member', [])
|
|
16
|
+
except: pass
|
|
17
|
+
|
|
18
|
+
def read_msg(self, msg_id):
|
|
19
|
+
h = {"Authorization": f"Bearer {self.token}"}
|
|
20
|
+
res = requests.get(f"{API_URL}/messages/{msg_id}", headers=h).json()
|
|
21
|
+
os.system('clear')
|
|
22
|
+
print(f"\033[1;33m--- Message Content ---\033[0m\n\n{res.get('text', 'Empty')}")
|
|
23
|
+
print("\n\033[1;31mPress any key to go back...\033[0m")
|
|
24
|
+
self.get_key()
|
|
25
|
+
|
|
26
|
+
def delete_msg(self, msg_id):
|
|
27
|
+
h = {"Authorization": f"Bearer {self.token}"}
|
|
28
|
+
requests.delete(f"{API_URL}/messages/{msg_id}", headers=h)
|
|
29
|
+
self.fetch()
|
|
30
|
+
|
|
31
|
+
def draw(self):
|
|
32
|
+
os.system('clear')
|
|
33
|
+
print(f"\033[1;44m GiveYouAMail CLI \033[0m\nADDR: {self.email}\n" + "-"*50)
|
|
34
|
+
if not self.messages: print("\n Empty Inbox...")
|
|
35
|
+
for i, m in enumerate(self.messages):
|
|
36
|
+
sel = (i == self.selected)
|
|
37
|
+
pre = "\033[1;37m>\033[0m " if sel else " "
|
|
38
|
+
line = f"{pre}{m['from']['address'][:20]:<20} | {m['subject'][:20]}"
|
|
39
|
+
if sel:
|
|
40
|
+
o = "\033[1;42m OPEN \033[0m" if self.action_idx==0 else " OPEN "
|
|
41
|
+
d = "\033[1;41m DEL \033[0m" if self.action_idx==1 else " DEL "
|
|
42
|
+
line += f" {o} {d}"
|
|
43
|
+
print(line)
|
|
44
|
+
print("-"*50 + "\n[ARROWS] Nav | [ENTER] Exec | [Q] Quit")
|
|
45
|
+
|
|
46
|
+
def get_key(self):
|
|
47
|
+
fd = sys.stdin.fileno()
|
|
48
|
+
old = termios.tcgetattr(fd)
|
|
49
|
+
try:
|
|
50
|
+
tty.setraw(fd)
|
|
51
|
+
ch = sys.stdin.read(1)
|
|
52
|
+
if ch == '\x1b': return ch + sys.stdin.read(2)
|
|
53
|
+
return ch
|
|
54
|
+
finally: termios.tcsetattr(fd, termios.TCSADRAIN, old)
|
|
55
|
+
|
|
56
|
+
def run(self):
|
|
57
|
+
self.fetch()
|
|
58
|
+
while self.running:
|
|
59
|
+
self.draw()
|
|
60
|
+
k = self.get_key()
|
|
61
|
+
if k == 'q': self.running = False
|
|
62
|
+
elif k == '\x1b[A' and self.selected > 0: self.selected -= 1
|
|
63
|
+
elif k == '\x1b[B' and self.selected < len(self.messages)-1: self.selected += 1
|
|
64
|
+
elif k == '\x1b[D': self.action_idx = 0
|
|
65
|
+
elif k == '\x1b[C': self.action_idx = 1
|
|
66
|
+
elif k == '\r' and self.messages:
|
|
67
|
+
mid = self.messages[self.selected]['id']
|
|
68
|
+
if self.action_idx == 0: self.read_msg(mid)
|
|
69
|
+
else: self.delete_msg(mid)
|
|
70
|
+
|
|
71
|
+
def main():
|
|
72
|
+
raw = " ".join(sys.argv)
|
|
73
|
+
if "-Login" in raw:
|
|
74
|
+
try:
|
|
75
|
+
# Regex sagrado: busca o que está entre aspas ou logo após o prefixo
|
|
76
|
+
m_mail = re.search(r'M:\s*"?([^"\s]+)"?', raw)
|
|
77
|
+
m_pswd = re.search(r'pswd:\s*"?([^"\s]+)"?', raw)
|
|
78
|
+
m_nome = re.search(r'nm\s*"?([^"]+)"?', raw)
|
|
79
|
+
|
|
80
|
+
email, pswd, nome = m_mail.group(1), m_pswd.group(1), m_nome.group(1)
|
|
81
|
+
|
|
82
|
+
requests.post(f"{API_URL}/accounts", json={"address": email, "password": pswd})
|
|
83
|
+
with open("session.json", "w") as f:
|
|
84
|
+
json.dump({"email": email, "password": pswd, "name": nome}, f)
|
|
85
|
+
print(f"Session generated for {nome}.")
|
|
86
|
+
except Exception as e:
|
|
87
|
+
print(f"Syntax Error: {e}")
|
|
88
|
+
|
|
89
|
+
elif "-oauth" in raw:
|
|
90
|
+
if not os.path.exists("session.json"): return
|
|
91
|
+
with open("session.json", "r") as f: s = json.load(f)
|
|
92
|
+
res = requests.post(f"{API_URL}/token", json={"address": s['email'], "password": s['password']})
|
|
93
|
+
if res.status_code == 200:
|
|
94
|
+
TUI(s['email'], res.json()['token'], s['name']).run()
|
|
95
|
+
else: print("Auth Error.")
|
|
96
|
+
|
|
97
|
+
if __name__ == "__main__":
|
|
98
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .30MMCLI import main
|