-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathktm-billing.py
More file actions
28 lines (19 loc) · 839 Bytes
/
Copy pathktm-billing.py
File metadata and controls
28 lines (19 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from classes.Config import Config
from classes.KTM import KTM
from classes.Database import Database as DB
from classes.TelegramBot import TelegramBot
from datetime import date
def compareDateToday(dt):
return date.today().strftime("%Y-%m-%d") == dt[:10]
for item in Config(__file__, "config.json").read():
db = DB(item["sqlite"])
lastRow = db.getLastHistoryRow()
overview = KTM(item["ktm-account"]).getOverview()
if overview["balance"] == lastRow["balance"]:
continue
db.insert(overview)
overviewCopy = overview.copy()
overviewCopy["username"] = item["ktm-account"]["username"]
overviewCopy["diff"] = round(lastRow["balance"] - overview["balance"], 2) if lastRow else 0
bot = TelegramBot(item["telegram"]["bot-token"])
bot.sendMessage(item["telegram"]["chat_id"], overviewCopy)