22import json
33import random
44import re
5- from typing import Any , Dict , Optional , Tuple
5+ from typing import Any , Dict , Tuple
66
77import requests
88
@@ -107,18 +107,6 @@ def get_trivia_payload() -> Dict[str, Any]:
107107 return payload
108108
109109
110- def fix_quotes (s : str ) -> Optional [str ]:
111- # opentdb is nice enough to escape HTML for us, but
112- # we are sending this to code that does that already :)
113- #
114- # Meanwhile Python took until version 3.4 to have a
115- # simple html.unescape function.
116- try :
117- return html .unescape (s )
118- except Exception :
119- raise Exception ("Please use python3.4 or later for this bot." )
120-
121-
122110def get_quiz_from_payload (payload : Dict [str , Any ]) -> Dict [str , Any ]:
123111 result = payload ["results" ][0 ]
124112 question = result ["question" ]
@@ -129,9 +117,9 @@ def get_quiz_from_payload(payload: Dict[str, Any]) -> Dict[str, Any]:
129117 answers [correct_letter ] = result ["correct_answer" ]
130118 for i in range (3 ):
131119 answers [letters [i + 1 ]] = result ["incorrect_answers" ][i ]
132- answers = {letter : fix_quotes (answer ) for letter , answer in answers .items ()}
120+ answers = {letter : html . unescape (answer ) for letter , answer in answers .items ()}
133121 quiz : Dict [str , Any ] = dict (
134- question = fix_quotes (question ),
122+ question = html . unescape (question ),
135123 answers = answers ,
136124 answered_options = [],
137125 pending = True ,
0 commit comments