forked from GramAddict/bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
29 lines (25 loc) · 736 Bytes
/
run.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
import GramAddict
import time
def run_gramaddict(**kwargs):
try:
GramAddict.run(**kwargs)
return True
except SystemExit as e:
print(f"Somehow it finished with code: {e.code}")
return e.code
except Exception as e:
print(f"Error during GramAddict run: {e}")
return 0
except KeyboardInterrupt:
print("Program interrupted by user. Exiting...")
return -1
def main(**kwargs):
while True:
start_time = time.time()
res = run_gramaddict(**kwargs)
elapsed_time = time.time() - start_time
print(f"GramAddict session lasted {elapsed_time:.2f} s")
if res == -1:
break
if __name__ == "__main__":
main()