Skip to content

Commit 8779186

Browse files
authored
🔥 init script
1 parent 4fef62e commit 8779186

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

bot.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
import requests
22
import subprocess
3+
import schedule
34
import time
45
import json
56
import tempfile
67
import os
78
import socket
89
import base64
10+
import time
911
from urllib.parse import urlparse
1012
from config import *
1113

1214
# -------------------------
1315
# Rocket.Chat webhook
1416
# -------------------------
1517
def send_to_rocketchat_webhook(message):
18+
print(f"sending new config to RocketChat server.")
1619
data = {"text": message}
1720
try:
21+
time.sleep(1)
1822
requests.post(ROCKET_WEBHOOK, json=data, timeout=5)
1923
except Exception as e:
2024
print("Failed to send message:", e)
@@ -100,10 +104,11 @@ def format_message(config, ping_info):
100104
ip = ping_info.get("ip", "N/A")
101105

102106
message = (
103-
f"✅ Working V2Ray Config!\n"
104-
f"Ping: {ping} ms\n"
105-
f"IP: {ip}\n"
106-
f"Config:\n```\n{config_str}\n```"
107+
f"Auto Config Bot {time.time()}\n"
108+
f"✅ Working V2Ray Config found!\n"
109+
f"🌐Ping: {ping} ms\n"
110+
f"🌐IP: {ip}\n"
111+
f"🚧 Config:\n```\n{config_str}\n```"
107112
)
108113
return message
109114

@@ -146,5 +151,13 @@ def main():
146151
print(f"Sleeping {FETCH_INTERVAL/60} minutes...")
147152
time.sleep(FETCH_INTERVAL)
148153

149-
if __name__ == "__main__":
150-
main()
154+
155+
main()
156+
schedule.every(3).hours.do(main)
157+
158+
while True:
159+
print(f"{time.time()}")
160+
schedule.run_pending()
161+
time.sleep(1)
162+
163+

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
schedule

0 commit comments

Comments
 (0)