]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/commitdiff
Add Coffeebot Getter module
authorJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 21 Mar 2019 08:00:16 +0000 (09:00 +0100)
committerJiri Vlasak <hubacji1@fel.cvut.cz>
Thu, 21 Mar 2019 08:00:16 +0000 (09:00 +0100)
- Basic interfacing to config, db.
- Printing current message.
- Sending the message to Slack.

cbgetter.py [new file with mode: 0644]

diff --git a/cbgetter.py b/cbgetter.py
new file mode 100644 (file)
index 0000000..391e2dd
--- /dev/null
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+"""Get data from database and publish them."""
+from json import dumps
+from requests import post
+from cbconf import Conf
+from cbdb import Db
+
+class CoffeebotGetter:
+    """This class connects configuration, database access and publishing."""
+    def __init__(self):
+        self.cfg = Conf()
+        self.db = Db(self.cfg.getCoffeeDbPath())
+        self.msg = ""
+        return None
+
+    def getMsg(self):
+        """Return message."""
+        return self.msg
+
+    def sendMsgToSlack(self):
+        """Send message to Slack Bot."""
+        return post(self.cfg.getCoffeebotURL(), dumps({"text": self.msg}))