-
Notifications
You must be signed in to change notification settings - Fork 3
/
utilities.py
63 lines (50 loc) · 1.26 KB
/
utilities.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
58
59
60
61
62
63
import json
from time import sleep
from datetime import datetime
import os
from threading import Timer
os.chdir(os.path.dirname(__file__))
class jsonOP:
"""
Class for JSON operations
"""
def __init__(self, JSONFILENAME: str):
self.json = JSONFILENAME
if not os.path.exists(self.json):
self.data = {}
self.saveJSON(self.data)
else:
self.data = self.loadJSON()
def saveJSON(self, data):
"""
Saves the data to the JSON file
"""
with open(self.json, "w") as f:
json.dump(data, f)
def loadJSON(self):
"""
Loads the JSON file
"""
with open(self.json, "r") as f:
data = json.load(f)
return data
def print_bot(message):
print(f"[{current_time()}] **Bot**: {message}")
def current_time():
"""
Acquires the current time and returns it
"""
now = datetime.now()
this = now.strftime("%d/%m/%Y %H:%M:%S")
return this
def isInteger(n):
x = int(n)
temp2 = float(n) - x
if (temp2) > 0:
return False
return True
def delayedCall(time, func, *args):
"""
Delays the call to the function
"""
Timer(interval=5, function=func, args=args).start()