34 lines
830 B
Python
Executable File
34 lines
830 B
Python
Executable File
#!/usr/local/bin/python3
|
|
import utils,sys,subprocess,json
|
|
utils.setcwd("/home/dowel/gophercomments")
|
|
|
|
def load_json_file(fn):
|
|
with utils.open(fn) as f: return json.load(f)
|
|
|
|
def dump_json_file(obj,fn):
|
|
with utils.open(fn,"w") as f: json.dump(obj,f)
|
|
|
|
|
|
email = utils.input()
|
|
|
|
def log(x):
|
|
with utils.open("log.txt","a") as f:
|
|
f.write(x+"\n")
|
|
|
|
box = email.get("Subject")
|
|
payload = email.get_payload()
|
|
|
|
if type(payload)==list:
|
|
sender = email.get("From")
|
|
with utils.open("wallofshame.json") as f: wos = json.load(f)
|
|
if sender not in wos["members"]:
|
|
wos["members"].append(email.get("From"))
|
|
with utils.open("wallofshame.json","w") as f: json.dump(wos,f)
|
|
|
|
if "\r\n" in payload:
|
|
payload = payload.replace("\r\n","\n")
|
|
if payload==payload.rstrip():
|
|
payload+="\n"
|
|
|
|
log("box = {}".format(box))
|
|
log("payload = {}".format(payload)) |