Compare commits

..

No commits in common. "61b5bd6edb46497ac7247e7137eb070aec7320dd" and "432f2854d5f486f89bc24ee06ee700695a7c0037" have entirely different histories.

2 changed files with 2 additions and 59 deletions

View File

@ -22,17 +22,6 @@ def get_boolean(prompt, default):
return default
def get_choice(choices, prompt, error="Invalid Choice", *,
lowercase_input=False):
while True:
inp = input(prompt)
if lowercase_input:
inp = inp.lower()
if inp in choices:
return inp
print(error)
config = {}
# Master password
@ -104,42 +93,6 @@ username/password)
print("Message sent, if you did not recieve a message, check the " +
"credentials")
# Email
print("\nDo you want to enable email messages?\n")
config["email"] = {}
email_enable = get_boolean("y/N ", False)
config["email"]["enabled"] = email_enable
if email_enable:
print("\nEnter SMTP root URL\n")
config["email"]["url"] = input("> ")
print("\nEnter port\n")
config["email"]["port"] = get_number("> ")
print("\nDo you want to enable SSL/TLS/None\n")
enc = get_choice(["ssl", "tls", "none"], "> ", lowercase_input=True)
if enc == "ssl":
config["email"]["ssl"] = True
config["email"]["tls"] = False
elif enc == "tls":
config["email"]["ssl"] = False
config["email"]["tls"] = True
else:
config["email"]["ssl"] = False
config["email"]["tls"] = False
print("\nEnter login username\n")
config["email"]["login"] = input("> ")
print("\nEnter login password\n")
config["email"]["password"] = input("> ")
print("\nEnter from email\n")
config["email"]["from"] = input("> ")
print("\nEnter comma seperated list of emails to send the email to\n")
config["email"]["tos"] = input("> ")
from backends import mail
print("\nAttempting to send a test message")
mail.send(config["email"], "Test Message from The Long Night")
print("Message sent, if you did not recieve a message, check the " +
"config")
print("\nStoring config.")
with open('config.json', 'w') as f:

View File

@ -1,5 +1,4 @@
#!/usr/bin/env python3
"Server for the-long-night"
import subprocess
import json
@ -12,7 +11,6 @@ app = Flask(__name__)
@app.route('/login', methods=['POST'])
def en_login():
"/login"
try:
password = request.values['password']
except KeyError:
@ -37,34 +35,26 @@ def en_login():
"and run `cancel-adding-key.sh` in The Long Night installation"
"directory.")
if "matrix" in config and config["matrix"]["enabled"]:
if config["matrix"]["enabled"]:
from backends import matrix
try:
matrix.send(config["matrix"], message)
except:
pass
if "telegram" in config and config["telegram"]["enabled"]:
if config["telegram"]["enabled"]:
from backends import telegram
try:
telegram.send(config["telegram"], message)
except:
pass
if "email" in config and config["email"]["enabled"]:
from backends import mail
try:
mail.send(config["email"], message)
except:
pass
return ("Logged In. The ssh key will be added " + str(config["days"]) +
" day(s) later.")
@app.route('/')
def en_root():
"/"
return """
<!DOCTYPE html>
<html>