@@ -20,13 +20,14 @@ def __init__(self):
20
20
self .urls = cfg .urls
21
21
22
22
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 )
24
24
25
25
self .raw_data = {
26
26
"status" : {"data" : [], "update_time" : 0 , "auth" : True },
27
27
"war_info" : {"data" : [], "update_time" : 0 , "auth" : True },
28
28
"planet_stats" : {"data" : [], "update_time" : 0 , "auth" : True },
29
29
"major_order" : {"data" : [], "update_time" : 0 , "auth" : True },
30
+ "personal_order" : {"data" : [], "update_time" : 0 , "auth" : True },
30
31
"news_feed" : {"data" : [], "update_time" : 0 , "auth" : True },
31
32
"updates" : {"data" : [], "update_time" : 0 , "auth" : False },
32
33
"level_spec" : {"data" : [], "update_time" : 0 , "auth" : True },
@@ -39,6 +40,12 @@ def __init__(self):
39
40
"season_pass_sv" : {"data" : [], "update_time" : 0 , "auth" : True },
40
41
"season_pass_ce" : {"data" : [], "update_time" : 0 , "auth" : True },
41
42
"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 },
42
49
"score_calc" : {"data" : [], "update_time" : 0 , "auth" : True },
43
50
"election_candidates" : {"data" : [], "update_time" : 0 , "auth" : True },
44
51
"election_terms" : {"data" : [], "update_time" : 0 , "auth" : True },
@@ -66,9 +73,12 @@ async def update_all(self):
66
73
self .raw_data [key ]["data" ] = responses [i ]
67
74
self .raw_data [key ]["update_time" ] = int (time ())
68
75
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
+ )
72
82
self .update_time = int (time ())
73
83
74
84
async def fetch_all (self ):
@@ -94,7 +104,7 @@ async def fetch_data(self, info_name: str = ""):
94
104
)
95
105
)
96
106
if update_needed :
97
- authed = self .raw_data .get (info_name )["auth" ]
107
+ authed = self .raw_data .get (info_name , {} )["auth" ]
98
108
url = self .urls [info_name ]
99
109
self .raw_data [info_name ]["update_time" ] = int (time ())
100
110
self .raw_data [info_name ]["data" ] = await self .get_url (url , authed )
@@ -164,7 +174,8 @@ async def format_steam_news(self, all_news):
164
174
news ["contents" ] = sub (r"\[b](.+?)\[/b]" , r"\n**\1**" , news ["contents" ])
165
175
news ["contents" ] = sub (r"\[i](.+?)\[/i]" , r"*\1*" , news ["contents" ])
166
176
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" ])
169
180
news ["contents" ] = news ["contents" ].replace ("\n \n " , "\n " )
170
181
return all_news
0 commit comments