@@ -45,7 +45,7 @@ class Challenge(dict):
45
45
# fmt: off
46
46
"name" , "author" , "category" , "description" , "attribution" , "value" ,
47
47
"type" , "extra" , "image" , "protocol" , "host" ,
48
- "connection_info" , "healthcheck" , "attempts" , "flags" ,
48
+ "connection_info" , "healthcheck" , "attempts" , "logic" , " flags" ,
49
49
"files" , "topics" , "tags" , "files" , "hints" ,
50
50
"requirements" , "next" , "state" , "version" ,
51
51
# fmt: on
@@ -291,6 +291,10 @@ def _get_initial_challenge_payload(self, ignore: Tuple[str] = ()) -> Dict:
291
291
if "connection_info" not in ignore :
292
292
challenge_payload ["connection_info" ] = challenge .get ("connection_info" , None )
293
293
294
+ if "logic" not in ignore :
295
+ if challenge .get ("logic" ):
296
+ challenge_payload ["logic" ] = challenge .get ("logic" ) or "any"
297
+
294
298
if "extra" not in ignore :
295
299
challenge_payload = {** challenge_payload , ** challenge .get ("extra" , {})}
296
300
@@ -552,13 +556,16 @@ def _normalize_challenge(self, challenge_data: Dict[str, Any]):
552
556
"type" ,
553
557
"state" ,
554
558
"connection_info" ,
559
+ "logic" ,
555
560
]
556
561
for key in copy_keys :
557
562
if key in challenge_data :
558
563
challenge [key ] = challenge_data [key ]
559
564
560
565
challenge ["description" ] = challenge_data ["description" ].strip ().replace ("\r \n " , "\n " ).replace ("\t " , "" )
561
- challenge ["attribution" ] = challenge_data .get ("attribution" , "" ).strip ().replace ("\r \n " , "\n " ).replace ("\t " , "" )
566
+ challenge ["attribution" ] = challenge_data .get ("attribution" , "" )
567
+ if challenge ["attribution" ]:
568
+ challenge ["attribution" ] = challenge ["attribution" ].strip ().replace ("\r \n " , "\n " ).replace ("\t " , "" )
562
569
challenge ["attempts" ] = challenge_data ["max_attempts" ]
563
570
564
571
for key in ["initial" , "decay" , "minimum" ]:
@@ -685,6 +692,8 @@ def sync(self, ignore: Tuple[str] = ()) -> None:
685
692
686
693
# Update simple properties
687
694
r = self .api .patch (f"/api/v1/challenges/{ self .challenge_id } " , json = challenge_payload )
695
+ if r .ok is False :
696
+ click .secho (f"Failed to sync challenge: ({ r .status_code } ) { r .text } " , fg = "red" )
688
697
r .raise_for_status ()
689
698
690
699
# Update flags
@@ -809,6 +818,8 @@ def create(self, ignore: Tuple[str] = ()) -> None:
809
818
challenge_payload [p ] = ""
810
819
811
820
r = self .api .post ("/api/v1/challenges" , json = challenge_payload )
821
+ if r .ok is False :
822
+ click .secho (f"Failed to create challenge: ({ r .status_code } ) { r .text } " , fg = "red" )
812
823
r .raise_for_status ()
813
824
814
825
self .challenge_id = r .json ()["data" ]["id" ]
0 commit comments