@@ -20,13 +20,14 @@ def __init__(self):
2020 self .urls = cfg .urls
2121
2222 self .update_time = 0
23- self .time_delay = cfg .ahgs_api .get ("time_delay" )
23+ self .time_delay : int = cfg .ahgs_api .get ("time_delay" , 20 )
2424
2525 self .raw_data = {
2626 "status" : {"data" : [], "update_time" : 0 , "auth" : True },
2727 "war_info" : {"data" : [], "update_time" : 0 , "auth" : True },
2828 "planet_stats" : {"data" : [], "update_time" : 0 , "auth" : True },
2929 "major_order" : {"data" : [], "update_time" : 0 , "auth" : True },
30+ "personal_order" : {"data" : [], "update_time" : 0 , "auth" : True },
3031 "news_feed" : {"data" : [], "update_time" : 0 , "auth" : True },
3132 "updates" : {"data" : [], "update_time" : 0 , "auth" : False },
3233 "level_spec" : {"data" : [], "update_time" : 0 , "auth" : True },
@@ -39,6 +40,12 @@ def __init__(self):
3940 "season_pass_sv" : {"data" : [], "update_time" : 0 , "auth" : True },
4041 "season_pass_ce" : {"data" : [], "update_time" : 0 , "auth" : True },
4142 "season_pass_dd" : {"data" : [], "update_time" : 0 , "auth" : True },
43+ "season_pass_pp" : {"data" : [], "update_time" : 0 , "auth" : True },
44+ "season_pass_vc" : {"data" : [], "update_time" : 0 , "auth" : True },
45+ "season_pass_ff" : {"data" : [], "update_time" : 0 , "auth" : True },
46+ "season_pass_ca" : {"data" : [], "update_time" : 0 , "auth" : True },
47+ "season_pass_te" : {"data" : [], "update_time" : 0 , "auth" : True },
48+ "space_station_1" : {"data" : [], "update_time" : 0 , "auth" : False },
4249 "score_calc" : {"data" : [], "update_time" : 0 , "auth" : True },
4350 "election_candidates" : {"data" : [], "update_time" : 0 , "auth" : True },
4451 "election_terms" : {"data" : [], "update_time" : 0 , "auth" : True },
@@ -66,9 +73,12 @@ async def update_all(self):
6673 self .raw_data [key ]["data" ] = responses [i ]
6774 self .raw_data [key ]["update_time" ] = int (time ())
6875 if key == "updates" :
69- self .raw_data [key ]["data" ] = await self .format_steam_news (
70- self .raw_data [key ]["data" ]["appnews" ]["newsitems" ]
71- )
76+ if not isinstance (self .raw_data [key ]["data" ], list ):
77+ # If pulling from steam, we gotta format, otherwise you're probably using my shit, so it's already formatted
78+ # and we just leave it alone
79+ self .raw_data [key ]["data" ] = await self .format_steam_news (
80+ self .raw_data [key ]["data" ]["appnews" ]["newsitems" ]
81+ )
7282 self .update_time = int (time ())
7383
7484 async def fetch_all (self ):
@@ -94,7 +104,7 @@ async def fetch_data(self, info_name: str = ""):
94104 )
95105 )
96106 if update_needed :
97- authed = self .raw_data .get (info_name )["auth" ]
107+ authed = self .raw_data .get (info_name , {} )["auth" ]
98108 url = self .urls [info_name ]
99109 self .raw_data [info_name ]["update_time" ] = int (time ())
100110 self .raw_data [info_name ]["data" ] = await self .get_url (url , authed )
@@ -164,7 +174,8 @@ async def format_steam_news(self, all_news):
164174 news ["contents" ] = sub (r"\[b](.+?)\[/b]" , r"\n**\1**" , news ["contents" ])
165175 news ["contents" ] = sub (r"\[i](.+?)\[/i]" , r"*\1*" , news ["contents" ])
166176 news ["contents" ] = sub (r"\[u](.+?)\[/u]" , r"\n__\1__" , news ["contents" ])
167- news ["contents" ] = sub (r"\[list](.+?)\[/list]" , r"\1" , news ["contents" ])
168- news ["contents" ] = sub (r"\[\*]" , r" - " , news ["contents" ])
177+ news ["contents" ] = sub (r"\[list]" , r"" , news ["contents" ])
178+ news ["contents" ] = sub (r"\[/list]" , r"" , news ["contents" ])
179+ news ["contents" ] = sub (r"\[\*]" , r"- " , news ["contents" ])
169180 news ["contents" ] = news ["contents" ].replace ("\n \n " , "\n " )
170181 return all_news
0 commit comments