File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change 11import requests
22import subprocess
3+ import schedule
34import time
45import json
56import tempfile
67import os
78import socket
89import base64
10+ import time
911from urllib .parse import urlparse
1012from config import *
1113
1214# -------------------------
1315# Rocket.Chat webhook
1416# -------------------------
1517def 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+
Original file line number Diff line number Diff line change 1+ schedule
You can’t perform that action at this time.
0 commit comments