11from notifypy import Notify
22from datetime import date
33import pyfiglet
4+ import requests
45import os .path
56import time
67import sys
910user_choice = - 1
1011user_choice_block_website = ""
1112user_choice_unlock_website = ""
13+ user_confirm_choice = ""
14+
15+ current_version = "1.0"
16+
17+ version_url = "https://raw.githubusercontent.com/Rabixx/updater/main/version.txt"
1218
1319win_path = "C:\\ Windows\\ System32\\ drivers\\ etc\\ hosts"
1420
2935
3036 os .remove ("start.tmp" )
3137
32- def main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path ):
33- while user_choice != 6 :
38+ def main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path , version_url , current_version , user_confirm_choice ):
39+ while user_choice != 7 :
3440 if user_choice == 1 :
3541 try :
3642 os .system ('cls' )
@@ -103,6 +109,37 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
103109 os .system ('cls' )
104110
105111 if user_choice == 5 :
112+ try :
113+ os .system ('cls' )
114+
115+ url = requests .get (version_url )
116+
117+ version = url .text
118+
119+ if float (version ) > float (current_version ):
120+ os .system ('cls' )
121+
122+ print ("New version {}is avaliable do you want to download it?" .format (version ))
123+ print ()
124+
125+ user_confirm_choice = str (input ("(yes,no): " ))
126+
127+ if user_confirm_choice == "yes" :
128+ os .system ('start https://cutt.ly/wWoOWvb' )
129+ os .system ('cls' )
130+ elif user_confirm_choice == "no" :
131+ os .system ('cls' )
132+ else :
133+ print ("Great no updates were found!" )
134+ time .sleep (2 )
135+ os .system ('cls' )
136+ except Exception as ex_5 :
137+ os .system ('cls' )
138+ print (f"[ERROR] { ex_5 } " )
139+ time .sleep (2 )
140+ os .system ('cls' )
141+
142+ if user_choice == 6 :
106143 os .system ('cls' )
107144 print ("Turning program off..." )
108145 time .sleep (2 )
@@ -114,8 +151,9 @@ def main(user_choice,user_choice_block_website,user_choice_unlock_website,win_pa
114151 print ("2. Unlock website" )
115152 print ("3. Show all blocked websites" )
116153 print ("4. About app" )
117- print ("5. Exit" )
154+ print ("5. Check for updates" )
155+ print ("6. Exit" )
118156 user_choice = int (input (">>: " ))
119157
120158if __name__ == "__main__" :
121- main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path )
159+ main (user_choice ,user_choice_block_website ,user_choice_unlock_website ,win_path , version_url , current_version , user_confirm_choice )
0 commit comments