From 32fa2302aa565c859b348d9997378b75f5c043eb Mon Sep 17 00:00:00 2001
From: Lynne <lynne@bune.city>
Date: Wed, 10 Jul 2019 21:25:07 +1000
Subject: [PATCH] handle empty database

---
 functions.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/functions.py b/functions.py
index 96f0a32..419c8d8 100755
--- a/functions.py
+++ b/functions.py
@@ -26,10 +26,15 @@ def make_sentence(output):
 	for toot in toots: # TODO: find a more efficient way to do this
 		toots_str += "\n{}".format(toot[0])
 	model = nlt_fixed(toots_str)
-	toots_str = None
 	db.close()
 	os.remove("toots-copy.db")
 
+	if toots_str.rstrip("\n") == "":
+		output.send("Database is empty! Try running main.py.")
+		return
+
+	toots_str = None
+
 	sentence = None
 	tries = 0
 	while sentence is None and tries < 10: