-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
57 lines (43 loc) · 1.32 KB
/
utils.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import json
import requests
import xmltodict
import datetime
from datetime import timedelta
from database import update_json
def get_date(after=0):
today = datetime.datetime.now()
today = today + timedelta(days=after)
today = today + timedelta(hours=3)
return today.strftime("%d.%m.%Y")
def read_token():
with open("DISCORD_TOKEN", "r") as f:
return f.readline()
def read_channelID():
with open("channel_id", "r") as f:
return f.readline()
def read_channelIDs():
with open("channel_id", "r") as f:
channel_ids = f.readlines()
channel_ids = [i.strip("\n") for i in channel_ids]
return channel_ids
def print_menu(menu):
string_to_send = ""
for i in menu[0]:
if i == None:
continue
string_to_send += "• " + i + "\n"
string_to_send += "\nKalori : " + menu[1]
return string_to_send
def update_yemekhane():
url = "http://www.sksdb.hacettepe.edu.tr/YemekListesi.xml"
response = requests.get(url)
data = xmltodict.parse(response.content)
data = data["gunler"]["gun"]
yemekhane = {}
for i in data:
tarih = i["tarih"].split()[0]
yemekler = i["yemekler"]["yemek"]
kalori = i["kalori"]
yemekhane[tarih] = [yemekler, kalori]
updated_json = update_json(yemekhane)
return updated_json