def isTriviaGameEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'triviaGameEnabled', True)
def isFuntoonApiEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'funtoonApiEnabled', True)
def isTamalesEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'tamalesEnabled', True)
def isDebugLoggingEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'debugLoggingEnabled', True)
def isEventSubEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'eventSubEnabled', False)
def isAnalogueEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'analogueEnabled', True)
def isChatBandEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'chatBandEnabled', False)
def isPokepediaEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'pokepediaEnabled', True)
def isPubSubPongLoggingEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'pubSubPongLoggingEnabled', False)
def isJishoEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'jishoEnabled', True)
def isPersistAllUsersEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'persistAllUsersEnabled', False)
def isImytSlurpMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'imytSlurpMessageEnabled', False)
def isGiftSubscriptionThanksMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'giftSubscriptionThanksMessageEnabled', True)
def isFuntoonTwitchChatFallbackEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'funtoonTwitchChatFallbackEnabled', True)
def isWeatherEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'weatherEnabled', True)
def isRaidLinkMessagingEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'raidLinkMessagingEnabled', True)
def isWordOfTheDayEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'wordOfTheDayEnabled', True)
def isRatJamMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'ratJamMessageEnabled', False)
def isCatJamMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'catJamMessageEnabled', True)
def isRewardIdPrintingEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'rewardIdPrintingEnabled', False)
def isCynanMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'cynanMessageEnabled', False)
def isSubGiftThankingEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'subGiftThankingEnabled', True)
def isDeerForceMessageEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'deerForceMessageEnabled', False)
def isSuperTriviaGameEnabled(self) -> bool: return utils.getBoolFromDict(self.__jsonContents, 'superTriviaGameEnabled', False)
def __refreshJoke(self) -> JokeResponse: print(f'Refreshing joke... ({utils.getNowTimeText()})') rawResponse = None try: rawResponse = requests.get(url=self.__apiUrl, timeout=utils.getDefaultTimeout()) except (ConnectionError, HTTPError, MaxRetryError, NewConnectionError, Timeout) as e: print(f'Exception occurred when attempting to fetch new joke: {e}') raise RuntimeError( f'Exception occurred when attempting to fetch new joke: {e}') jsonResponse = None try: jsonResponse = rawResponse.json() except JSONDecodeError as e: print( f'Exception occurred when attempting to decode joke\'s response into JSON: {e}' ) raise RuntimeError( f'Exception occurred when attempting to decode joke\'s response into JSON: {e}' ) if utils.getBoolFromDict(jsonResponse, 'error', True): print(f'Rejecting joke due to bad \"error\" value: {jsonResponse}') raise ValueError( f'Rejecting joke due to bad \"error\" value: {jsonResponse}') elif utils.getBoolFromDict(jsonResponse, 'safe', False): print(f'Rejecting joke due to bad \"safe\" value: {jsonResponse}') raise ValueError( f'Rejecting joke due to bad \"safe\" value: {jsonResponse}') flagsJson = jsonResponse['flags'] isExplicit = flagsJson['explicit'] isNsfw = flagsJson['nsfw'] isPolitical = flagsJson['political'] isRacist = flagsJson['racist'] isReligious = flagsJson['religious'] isSexist = flagsJson['sexist'] if isExplicit or isNsfw or isPolitical or isRacist or isReligious or isSexist: print( f'Rejecting joke due to one or more bad flags: {jsonResponse}') raise ValueError( f'Rejecting joke due to one or more bad flags: {jsonResponse}') jokeText = None if jsonResponse['type'] == 'twopart': setup = utils.cleanStr(jsonResponse['setup']) delivery = utils.cleanStr(jsonResponse['delivery']) jokeText = f'{setup} {delivery}' elif jsonResponse['type'] == 'single': jokeText = utils.cleanStr(jsonResponse['joke']) else: print(f'Rejecting joke due to unknown \"type\": {jsonResponse}') raise ValueError( f'Rejecting joke due to unknown \"type\": {jsonResponse}') return JokeResponse(text=jokeText)
def __createUser(self, handle: str, userJson: Dict[str, Any]) -> User: if not utils.isValidStr(handle): raise ValueError(f'handle argument is malformed: \"{handle}\"') elif userJson is None: raise ValueError(f'userJson argument is malformed: \"{userJson}\"') isAnalogueEnabled = utils.getBoolFromDict(userJson, 'analogueEnabled', False) isCatJamEnabled = utils.getBoolFromDict(userJson, 'catJamEnabled', False) isChatBandEnabled = utils.getBoolFromDict(userJson, 'chatBandEnabled', False) isChatLoggingEnabled = utils.getBoolFromDict(userJson, 'chatLoggingEnabled', False) isCutenessEnabled = utils.getBoolFromDict(userJson, 'cutenessEnabled', False) isCynanMessageEnabled = utils.getBoolFromDict(userJson, 'cynanMessageEnabled', False) isCynanSourceEnabled = utils.getBoolFromDict(userJson, 'cynanSourceEnabled', True) isDeerForceMessageEnabled = utils.getBoolFromDict( userJson, 'deerForceMessageEnabled', False) isEyesMessageEnabled = utils.getBoolFromDict(userJson, 'eyesMessageEnabled', False) isGiftSubscriptionThanksMessageEnabled = utils.getBoolFromDict( userJson, 'isGiftSubscriptionThanksMessageEnabled', True) isGiveCutenessEnabled = utils.getBoolFromDict(userJson, 'giveCutenessEnabled', False) isImytSlurpEnabled = utils.getBoolFromDict(userJson, 'imytSlurpEnabled', False) isJamCatEnabled = utils.getBoolFromDict(userJson, 'jamCatEnabled', False) isJishoEnabled = utils.getBoolFromDict(userJson, 'jishoEnabled', False) isJokeTriviaRepositoryEnabled = utils.getBoolFromDict( userJson, 'jokeTriviaRepositoryEnabled', False) isLoremIpsumEnabled = utils.getBoolFromDict(userJson, 'loremIpsumEnabled', True) isPicOfTheDayEnabled = utils.getBoolFromDict(userJson, 'picOfTheDayEnabled', False) isPkmnEnabled = utils.getBoolFromDict(userJson, 'pkmnEnabled', False) isPokepediaEnabled = utils.getBoolFromDict(userJson, 'pokepediaEnabled', False) isRaceEnabled = utils.getBoolFromDict(userJson, 'raceEnabled', False) isRaidLinkMessagingEnabled = utils.getBoolFromDict( userJson, 'raidLinkMessagingEnabled', False) isRatJamEnabled = utils.getBoolFromDict(userJson, 'ratJamEnabled', False) isRewardIdPrintingEnabled = utils.getBoolFromDict( userJson, 'rewardIdPrintingEnabled', False) isStarWarsQuotesEnabled = utils.getBoolFromDict( userJson, 'starWarsQuotesEnabled', False) isSubGiftThankingEnabled = utils.getBoolFromDict( userJson, 'subGiftThankingEnabled', True) isTamalesEnabled = utils.getBoolFromDict(userJson, 'tamalesEnabled', False) isTranslateEnabled = utils.getBoolFromDict(userJson, 'translateEnabled', False) isTriviaEnabled = utils.getBoolFromDict(userJson, 'triviaEnabled', False) isTriviaGameEnabled = utils.getBoolFromDict(userJson, 'triviaGameEnabled', False) isWeatherEnabled = utils.getBoolFromDict(userJson, 'weatherEnabled', False) isWordOfTheDayEnabled = utils.getBoolFromDict(userJson, 'wordOfTheDayEnabled', False) discord = utils.getStrFromDict(userJson, 'discord', '') instagram = utils.getStrFromDict(userJson, 'instagram', '') locationId = utils.getStrFromDict(userJson, 'locationId', '') speedrunProfile = utils.getStrFromDict(userJson, 'speedrunProfile', '') twitter = utils.getStrFromDict(userJson, 'twitter', '') timeZones: List[tzinfo] = None if 'timeZones' in userJson: timeZones = self.__timeZoneRepository.getTimeZones( userJson['timeZones']) elif 'timeZone' in userJson: timeZones = list() timeZones.append( self.__timeZoneRepository.getTimeZone(userJson['timeZone'])) cutenessBoosterPacks: List[CutenessBoosterPack] = None if isCutenessEnabled: cutenessBoosterPacksJson: List[Dict] = userJson.get( 'cutenessBoosterPacks') cutenessBoosterPacks = self.__parseCutenessBoosterPacksFromJson( cutenessBoosterPacksJson) picOfTheDayFile: str = None picOfTheDayRewardId: str = None if isPicOfTheDayEnabled: picOfTheDayFile = userJson.get('picOfTheDayFile') picOfTheDayRewardId = userJson.get('picOfTheDayRewardId') if not utils.isValidStr(picOfTheDayFile): raise ValueError( f'POTD is enabled for {handle} but picOfTheDayFile is malformed: \"{picOfTheDayFile}\"' ) isSuperTriviaGameEnabled: bool = isTriviaGameEnabled superTriviaGameControllers: List[str] = None superTriviaGameMultiplier: int = None triviaGameRewardId: str = None triviaGamePoints: int = None triviaGameTutorialCutenessThreshold: int = None waitForSuperTriviaAnswerDelay: int = None waitForTriviaAnswerDelay: int = None if isTriviaGameEnabled: isSuperTriviaGameEnabled = utils.getBoolFromDict( userJson, 'superTriviaGameEnabled', isSuperTriviaGameEnabled) superTriviaGameControllers = userJson.get( 'superTriviaGameControllers') superTriviaGameMultiplier = userJson.get( 'superTriviaGameMultiplier') triviaGameRewardId = userJson.get('triviaGameRewardId') triviaGamePoints = userJson.get('triviaGamePoints') triviaGameTutorialCutenessThreshold = userJson.get( 'triviaGameTutorialCutenessThreshold') waitForSuperTriviaAnswerDelay = userJson.get( 'waitForSuperTriviaAnswerDelay') waitForTriviaAnswerDelay = userJson.get('waitForTriviaAnswerDelay') pkmnBattleRewardId: str = None pkmnEvolveRewardId: str = None pkmnShinyRewardId: str = None pkmnCatchBoosterPacks: List[PkmnCatchBoosterPack] = None if isPkmnEnabled: pkmnBattleRewardId = userJson.get('pkmnBattleRewardId') pkmnEvolveRewardId = userJson.get('pkmnEvolveRewardId') pkmnShinyRewardId = userJson.get('pkmnShinyRewardId') pkmnCatchBoosterPacksJson: List[Dict] = userJson.get( 'pkmnCatchBoosterPacks') pkmnCatchBoosterPacks = self.__parsePkmnCatchBoosterPacksFromJson( pkmnCatchBoosterPacksJson) return User( isAnalogueEnabled=isAnalogueEnabled, isCatJamEnabled=isCatJamEnabled, isChatBandEnabled=isChatBandEnabled, isChatLoggingEnabled=isChatLoggingEnabled, isCutenessEnabled=isCutenessEnabled, isCynanMessageEnabled=isCynanMessageEnabled, isCynanSourceEnabled=isCynanSourceEnabled, isDeerForceMessageEnabled=isDeerForceMessageEnabled, isEyesMessageEnabled=isEyesMessageEnabled, isGiftSubscriptionThanksMessageEnabled= isGiftSubscriptionThanksMessageEnabled, isGiveCutenessEnabled=isGiveCutenessEnabled, isImytSlurpEnabled=isImytSlurpEnabled, isJamCatEnabled=isJamCatEnabled, isJishoEnabled=isJishoEnabled, isJokeTriviaRepositoryEnabled=isJokeTriviaRepositoryEnabled, isLoremIpsumEnabled=isLoremIpsumEnabled, isPicOfTheDayEnabled=isPicOfTheDayEnabled, isPkmnEnabled=isPkmnEnabled, isPokepediaEnabled=isPokepediaEnabled, isRaceEnabled=isRaceEnabled, isRaidLinkMessagingEnabled=isRaidLinkMessagingEnabled, isRatJamEnabled=isRatJamEnabled, isRewardIdPrintingEnabled=isRewardIdPrintingEnabled, isStarWarsQuotesEnabled=isStarWarsQuotesEnabled, isSubGiftThankingEnabled=isSubGiftThankingEnabled, isSuperTriviaGameEnabled=isSuperTriviaGameEnabled, isTamalesEnabled=isTamalesEnabled, isTranslateEnabled=isTranslateEnabled, isTriviaEnabled=isTriviaEnabled, isTriviaGameEnabled=isTriviaGameEnabled, isWeatherEnabled=isWeatherEnabled, isWordOfTheDayEnabled=isWordOfTheDayEnabled, superTriviaGameMultiplier=superTriviaGameMultiplier, triviaGamePoints=triviaGamePoints, triviaGameTutorialCutenessThreshold= triviaGameTutorialCutenessThreshold, waitForSuperTriviaAnswerDelay=waitForSuperTriviaAnswerDelay, waitForTriviaAnswerDelay=waitForTriviaAnswerDelay, discord=discord, handle=handle, instagram=instagram, locationId=locationId, picOfTheDayFile=picOfTheDayFile, picOfTheDayRewardId=picOfTheDayRewardId, pkmnBattleRewardId=pkmnBattleRewardId, pkmnEvolveRewardId=pkmnEvolveRewardId, pkmnShinyRewardId=pkmnShinyRewardId, speedrunProfile=speedrunProfile, triviaGameRewardId=triviaGameRewardId, twitter=twitter, cutenessBoosterPacks=cutenessBoosterPacks, pkmnCatchBoosterPacks=pkmnCatchBoosterPacks, superTriviaGameControllers=superTriviaGameControllers, timeZones=timeZones)