-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathboughtTokenTime.py
More file actions
40 lines (33 loc) · 1.35 KB
/
Copy pathboughtTokenTime.py
File metadata and controls
40 lines (33 loc) · 1.35 KB
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
import datetime
"""
Useless file, implemented it in ETH sniper but never used in SOL sniper
"""
def saveTokenTime():
current_time = datetime.datetime.now()
print(f"********* Bought at [{current_time}] *********")
with open("timestamp.txt", "w") as file:
file.write(current_time.strftime("%Y-%m-%d %H:%M:%S"))
def isTimePassed(timestr):
timeint = 0
if "m" in timestr:
timestr = int(timestr.replace("m",""))
timeint = timestr * 60 #minute x seconds
elif "h" in timestr:
timestr = int(timestr.replace("h",""))
timeint = timestr * 60 * 60 # hour x minute x seconds
elif "d" in timestr:
timestr = int(timestr.replace("d",""))
timeint = (timestr * 24) * 60 * 60 #(number of day x total hours in day) x minutes x seconds
# Read the timestamp from the file
with open("timestamp.txt", "r") as file:
timestamp_str = file.read()
# Convert the timestamp string to a datetime object
timestamp = datetime.datetime.strptime(timestamp_str, "%Y-%m-%d %H:%M:%S")
# Calculate the time difference between the current time and the stored timestamp
current_time = datetime.datetime.now()
time_difference = current_time - timestamp
# time has been passed by that limit
if time_difference.total_seconds() >= timeint:
return True
else:
return False