diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..73f69e0
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..deb38e6
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+groupme-facts-bot
\ No newline at end of file
diff --git a/.idea/groupme-facts-bot.iml b/.idea/groupme-facts-bot.iml
new file mode 100644
index 0000000..d5733cf
--- /dev/null
+++ b/.idea/groupme-facts-bot.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..b5f1628
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..4267c41
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/__init__.py b/app/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/app/fact_bot.py b/app/fact_bot.py
new file mode 100644
index 0000000..a22db72
--- /dev/null
+++ b/app/fact_bot.py
@@ -0,0 +1,8 @@
+from app import fact_service, groupme
+
+if __name__ == '__main__':
+ # Get Groupme api token to post with
+ groupme_client = groupme.get_client()
+
+ # Get Random Fact
+ fact = fact_service.get_random_fact()
diff --git a/app/fact_service.py b/app/fact_service.py
new file mode 100644
index 0000000..01b1205
--- /dev/null
+++ b/app/fact_service.py
@@ -0,0 +1,4 @@
+def get_random_fact():
+ ret_fact = None
+
+ return ret_fact
diff --git a/app/groupme.py b/app/groupme.py
new file mode 100644
index 0000000..c828513
--- /dev/null
+++ b/app/groupme.py
@@ -0,0 +1,18 @@
+from groupy import Client
+
+from util import api_keys
+
+GROUPME_CLIENT = None
+
+
+def get_client():
+ if GROUPME_CLIENT is None:
+ init_client()
+ return GROUPME_CLIENT
+
+
+def init_client():
+ global GROUPME_CLIENT
+ GROUPME_CLIENT = Client.from_token(api_keys.GROUPME)
+ if not list(GROUPME_CLIENT.groups.list_all()):
+ raise Exception("Invalid groupme token or not apart of any groups.")
diff --git a/model/__init__.py b/model/__init__.py
new file mode 100644
index 0000000..b62f6ca
--- /dev/null
+++ b/model/__init__.py
@@ -0,0 +1,3 @@
+from model import db_service
+
+from model import text_db
diff --git a/model/db_service.py b/model/db_service.py
new file mode 100644
index 0000000..7450cee
--- /dev/null
+++ b/model/db_service.py
@@ -0,0 +1,15 @@
+from abc import abstractmethod
+
+
+class DbService:
+
+ def __init__(self) -> None:
+ super().__init__()
+
+ @abstractmethod
+ def get_fact(self):
+ pass
+
+ @abstractmethod
+ def get_multiple_facts(self, count=5):
+ pass
diff --git a/model/text_db.py b/model/text_db.py
new file mode 100644
index 0000000..2815796
--- /dev/null
+++ b/model/text_db.py
@@ -0,0 +1,26 @@
+import random
+
+from model.db_service import DbService
+from util import common
+
+
+class TextDb(DbService):
+
+ def __init__(self) -> None:
+ super().__init__()
+ self.FACTS_LIST = None
+
+ def load_facts_from_file(self):
+ facts_file = open(f"{common.get_project_root()}/resources/facts.txt", mode="r+")
+ self.FACTS_LIST = facts_file.readlines()
+ assert self.FACTS_LIST
+
+ def get_fact(self):
+ if self.FACTS_LIST is None:
+ self.load_facts_from_file()
+ return random.choice(self.FACTS_LIST)
+
+ def get_multiple_facts(self, count=5):
+ if self.FACTS_LIST is None:
+ self.load_facts_from_file()
+ return random.sample(self.FACTS_LIST, k=count)
diff --git a/resources/facts_sample.txt b/resources/facts_sample.txt
new file mode 100644
index 0000000..03ae83f
--- /dev/null
+++ b/resources/facts_sample.txt
@@ -0,0 +1,11 @@
+Charles Darwin's personal pet tortoise didn't die until recently.
+The average person will spend six months of their life waiting for red lights to turn green.
+A bolt of lightning contains enough energy to toast 100,000 slices of bread.
+President Lyndon B. Johnson owned a water-surfing car.
+Cherophobia is the word for the irrational fear of being happy.
+You can hear a blue whale's heartbeat from two miles away.
+Nearly 30,000 rubber ducks were lost a sea in 1992 and are still being discovered today.
+There's a Manhattan-specific ant.
+The inventor of the frisbee was turned into a frisbee after he died.
+There's a bridge exclusively for squirrels.
+Subway footlongs aren't always a foot long.
diff --git a/tests/__init__.py b/tests/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test_text_db.py b/tests/test_text_db.py
new file mode 100644
index 0000000..52c2b1a
--- /dev/null
+++ b/tests/test_text_db.py
@@ -0,0 +1,15 @@
+from model.text_db import TextDb
+
+
+class TestTestDb:
+ def test_get_fact(self):
+ text_db_service = TextDb()
+ random_fact = text_db_service.get_fact()
+ assert random_fact is not None
+ assert random_fact != ""
+
+ def test_get_multiple_facts(self):
+ text_db_service = TextDb()
+ random_facts_list = text_db_service.get_multiple_facts()
+ assert random_facts_list is not None
+ assert len(random_facts_list) > 0
diff --git a/util/__init__.py b/util/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/util/api_keys.py b/util/api_keys.py
new file mode 100644
index 0000000..3d3d03d
--- /dev/null
+++ b/util/api_keys.py
@@ -0,0 +1,3 @@
+import os
+
+GROUPME = os.environ.get("GROUPME_KEY")
diff --git a/util/common.py b/util/common.py
new file mode 100644
index 0000000..593b45d
--- /dev/null
+++ b/util/common.py
@@ -0,0 +1,6 @@
+from pathlib import Path
+
+
+def get_project_root() -> Path:
+ """Returns project root folder."""
+ return Path(__file__).parent.parent