-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstop_bots.py
More file actions
31 lines (23 loc) · 796 Bytes
/
stop_bots.py
File metadata and controls
31 lines (23 loc) · 796 Bytes
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
import subprocess
def stop_bots():
try:
with open('api_keys.txt', 'r') as file:
tokens = file.readlines()
except FileNotFoundError:
print("File api_keys.txt not found!")
return
for token in tokens:
token = token.strip()
if not token:
print("Token cannot be empty!")
continue
safe_token = token.replace(':', '_')
container_name = f"bot_{safe_token}"
command = ['docker', 'stop', container_name]
try:
subprocess.run(command, check=True)
print(f"Container {container_name} stopped.")
except subprocess.CalledProcessError as e:
print(f"Error stopping container {container_name}: {e}")
if __name__ == "__main__":
stop_bots()