]> rtime.felk.cvut.cz Git - hubacji1/coffee-getter.git/blob - cbgetter.py
Add hero comment getter
[hubacji1/coffee-getter.git] / cbgetter.py
1 # -*- coding: utf-8 -*-
2 """Get data from database and publish them."""
3 from json import dumps
4 from random import randint
5 from requests import post
6 from cbconf import Conf
7 from cbdb import Db
8
9 class CoffeebotGetter:
10     """This class connects configuration, database access and publishing."""
11     def __init__(self):
12         self.cfg = Conf()
13         self.db = Db(self.cfg.getCoffeeDbPath())
14         self.msg = ""
15         return None
16
17     def getMsg(self):
18         """Return message."""
19         return self.msg
20
21     def sendMsgToSlack(self):
22         """Send message to Slack Bot."""
23         return post(self.cfg.getCoffeebotURL(), dumps({"text": self.msg}))
24
25     def getHeroComment(self):
26         """Return comment for hero."""
27         hsuff = [
28             " - yes",
29             " - no",
30             " - maybe",
31             #", oops",
32             #" - real hero",
33             #" because couldn't resist",
34             #" - drunken master",
35             #", woohoo",
36             #" - unbeatable",
37             #" - superultramaxidrinker",
38             #" and didn't sleep last week",
39             #" in last 604800 seconds",
40             #", no idea how",
41             #" and still drinking",
42         ]
43         ri = randint(0, len(hsuff) - 1)
44         return hsuff[ri]