-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtimer.py
37 lines (27 loc) · 1.15 KB
/
timer.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
import msvcrt
import time
import datetime
# In theory, this method takes the input of a user and then you can post it to the Twitters through the terminal.
# In practice this one never allows the bot to progress past this, so I'm just gonna give up on it
#TODO: I finally found a solution for it! I can simply use the threading module, combined with a sleep timer to simulate a threaded scheduler.
# Something more I would like this method to have: Backspace doesn't move to the left, but deletes instead.
# Enter *should* clear the comment string, but does not for whatever reason.
def readInput():
start_time = time.time()
comment = ""
while True:
while True:
chrctr = msvcrt.getch().decode("utf-8")
if str(chrctr) == '\n':
return comment
else:
if str(chrctr) == "" and (time.time() - start_time) >= 4 and comment == "":
return
comment += str(chrctr)
break
timeOut = {
"startUp": time.time(),
"receivedQuoteTimer": "0"
}
def convertToTime(timeInSeconds):
return str(datetime.timedelta(seconds=int(timeInSeconds)))