async def handlePointRedemption(self, twitchChannel: Channel, twitchUser: User, redemptionMessage: str, rewardId: str, userIdThatRedeemed: str, userNameThatRedeemed: str) -> bool: if twitchChannel is None: raise ValueError( f'twitchChannel argument is malformed: \"{twitchChannel}\"') elif twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif not utils.isValidStr(rewardId): raise ValueError(f'rewardId argument is malformed: \"{rewardId}\"') elif not utils.isValidStr(userIdThatRedeemed): raise ValueError( f'userIdThatRedeemed argument is malformed: \"{userIdThatRedeemed}\"' ) elif not utils.isValidStr(userNameThatRedeemed): raise ValueError( f'userNameThatRedeemed argument is malformed: \"{userNameThatRedeemed}\"' ) generalSettings = await self.__generalSettingsRepository.getAllAsync() if not generalSettings.isTriviaGameEnabled(): return False elif not twitchUser.isTriviaGameEnabled(): return False secondsToLive = generalSettings.getWaitForTriviaAnswerDelay() if twitchUser.hasWaitForTriviaAnswerDelay(): secondsToLive = twitchUser.getWaitForTriviaAnswerDelay() points = generalSettings.getTriviaGamePoints() if twitchUser.hasTriviaGamePoints(): points = twitchUser.getTriviaGamePoints() triviaFetchOptions = TriviaFetchOptions( twitchChannel=twitchUser.getHandle(), isJokeTriviaRepositoryEnabled=twitchUser. isJokeTriviaRepositoryEnabled(), questionAnswerTriviaConditions=QuestionAnswerTriviaConditions. NOT_ALLOWED) self.__triviaGameMachine.submitAction( StartNewTriviaGameAction(pointsForWinning=points, secondsToLive=secondsToLive, twitchChannel=twitchUser.getHandle(), userId=userIdThatRedeemed, userName=userNameThatRedeemed, triviaFetchOptions=triviaFetchOptions)) self.__timber.log( 'TriviaGameRedemption', f'Redeemed trivia game for {userNameThatRedeemed}:{userIdThatRedeemed} in {twitchUser.getHandle()}' ) return True
async def handleMessage(self, twitchUser: User, message: Message) -> bool: if twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif message is None: raise ValueError(f'message argument is malformed: \"{message}\"') generalSettings = await self.__generalSettingsRepository.getAllAsync() if not generalSettings.isChatBandEnabled(): return False elif not twitchUser.isChatBandEnabled(): return False if await self.__chatBandManager.playInstrumentForMessage( twitchChannel=twitchUser.getHandle(), author=message.author.name, message=utils.cleanStr(message.content)): self.__timber.log( 'ChatBandMessage', f'Handled chat band message for {message.author.name} in {twitchUser.getHandle()}' ) return True return False
async def handleMessage(self, twitchUser: User, message: Message) -> bool: if twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif message is None: raise ValueError(f'message argument is malformed: \"{message}\"') generalSettings = await self.__generalSettingsRepository.getAllAsync() if not generalSettings.isCatJamMessageEnabled(): return False elif not twitchUser.isCatJamEnabled(): return False splits = utils.getCleanedSplits(message.content) if self.__catJamMessage in splits and self.__lastCatJamMessageTimes.isReadyAndUpdate( twitchUser.getHandle()): await twitchUtils.safeSend(message.channel, self.__catJamMessage) self.__timber.log( 'CatJamMessage', f'Handled catJAM message for {message.author.name} in {twitchUser.getHandle()}' ) return True return False
async def handleMessage(self, twitchUser: User, message: Message) -> bool: if twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif message is None: raise ValueError(f'message argument is malformed: \"{message}\"') generalSettings = await self.__generalSettingsRepository.getAllAsync() if not generalSettings.isDeerForceMessageEnabled(): return False elif not twitchUser.isDeerForceMessageEnabled(): return False text = utils.cleanStr(message.content) if text.lower() == self.__deerForceMessage.lower( ) and self.__lastDeerForceMessageTimes.isReadyAndUpdate( twitchUser.getHandle()): await twitchUtils.safeSend(message.channel, self.__deerForceMessage) self.__timber.log( 'DeerForceMessage', f'Handled Deer Force message for {message.author.name} in {twitchUser.getHandle()}' ) return True return False
async def handlePointRedemption(self, twitchChannel: Channel, twitchUser: User, redemptionMessage: str, rewardId: str, userIdThatRedeemed: str, userNameThatRedeemed: str) -> bool: if twitchChannel is None: raise ValueError( f'twitchChannel argument is malformed: \"{twitchChannel}\"') elif twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif not utils.isValidStr(rewardId): raise ValueError(f'rewardId argument is malformed: \"{rewardId}\"') elif not utils.isValidStr(userIdThatRedeemed): raise ValueError( f'userIdThatRedeemed argument is malformed: \"{userIdThatRedeemed}\"' ) elif not utils.isValidStr(userNameThatRedeemed): raise ValueError( f'userNameThatRedeemed argument is malformed: \"{userNameThatRedeemed}\"' ) if not twitchUser.isPkmnEnabled(): return False splits = utils.getCleanedSplits(redemptionMessage) if not utils.hasItems(splits): await twitchUtils.safeSend( twitchChannel, f'⚠ Sorry @{userNameThatRedeemed}, you must specify the exact user name of the person you want to fight' ) return False opponentUserName = utils.removePreceedingAt(splits[0]) generalSettings = await self.__generalSettingsRepository.getAllAsync() actionCompleted = False if generalSettings.isFuntoonApiEnabled(): if await self.__funtoonRepository.pkmnBattle( userThatRedeemed=userNameThatRedeemed, userToBattle=opponentUserName, twitchChannel=twitchUser.getHandle()): actionCompleted = True if not actionCompleted and generalSettings.isFuntoonTwitchChatFallbackEnabled( ): await twitchUtils.safeSend( twitchChannel, f'!battle {userNameThatRedeemed} {opponentUserName}') actionCompleted = True self.__timber.log( 'PkmnBattleRedemption', f'Redeemed pkmn battle for {userNameThatRedeemed}:{userIdThatRedeemed} in {twitchUser.getHandle()}' ) return actionCompleted
async def handleMessage(self, twitchUser: User, message: Message) -> bool: if twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif message is None: raise ValueError(f'message argument is malformed: \"{message}\"') if not twitchUser.isChatLoggingEnabled(): return False self.__chatLogger.logMessage(twitchChannel=twitchUser.getHandle(), userId=str(message.author.id), userName=message.author.name, msg=utils.cleanStr(message.content)) return True
async def handlePointRedemption(self, twitchChannel: Channel, twitchUser: User, redemptionMessage: str, rewardId: str, userIdThatRedeemed: str, userNameThatRedeemed: str) -> bool: if twitchChannel is None: raise ValueError( f'twitchChannel argument is malformed: \"{twitchChannel}\"') elif twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif not utils.isValidStr(rewardId): raise ValueError(f'rewardId argument is malformed: \"{rewardId}\"') elif not utils.isValidStr(userIdThatRedeemed): raise ValueError( f'userIdThatRedeemed argument is malformed: \"{userIdThatRedeemed}\"' ) elif not utils.isValidStr(userNameThatRedeemed): raise ValueError( f'userNameThatRedeemed argument is malformed: \"{userNameThatRedeemed}\"' ) if not twitchUser.isPkmnEnabled(): return False generalSettings = await self.__generalSettingsRepository.getAllAsync() actionCompleted = False if generalSettings.isFuntoonApiEnabled(): if await self.__funtoonRepository.pkmnGiveShiny( userThatRedeemed=userNameThatRedeemed, twitchChannel=twitchUser.getHandle()): actionCompleted = True if not actionCompleted and generalSettings.isFuntoonTwitchChatFallbackEnabled( ): await twitchUtils.safeSend(twitchChannel, f'!freeshiny {userNameThatRedeemed}') actionCompleted = True self.__timber.log( 'PkmnShinyRedemption', f'Redeemed pkmn shiny for {userNameThatRedeemed}:{userIdThatRedeemed} in {twitchUser.getHandle()}' ) return actionCompleted
async def handlePointRedemption(self, twitchChannel: Channel, twitchUser: User, redemptionMessage: str, rewardId: str, userIdThatRedeemed: str, userNameThatRedeemed: str) -> bool: if twitchChannel is None: raise ValueError( f'twitchChannel argument is malformed: \"{twitchChannel}\"') elif twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif not utils.isValidStr(rewardId): raise ValueError(f'rewardId argument is malformed: \"{rewardId}\"') elif not utils.isValidStr(userIdThatRedeemed): raise ValueError( f'userIdThatRedeemed argument is malformed: \"{userIdThatRedeemed}\"' ) elif not utils.isValidStr(userNameThatRedeemed): raise ValueError( f'userNameThatRedeemed argument is malformed: \"{userNameThatRedeemed}\"' ) if not twitchUser.isCutenessEnabled( ) or not twitchUser.hasCutenessBoosterPacks(): return False cutenessBoosterPack: CutenessBoosterPack = None for cbp in twitchUser.getCutenessBoosterPacks(): if rewardId == cbp.getRewardId(): cutenessBoosterPack = cbp break if cutenessBoosterPack is None: return False incrementAmount = cutenessBoosterPack.getAmount() if self.__doubleCutenessHelper.isWithinDoubleCuteness( twitchUser.getHandle()): incrementAmount = cutenessBoosterPack.getAmount() * 2 try: await self.__cutenessRepository.fetchCutenessIncrementedBy( incrementAmount=incrementAmount, twitchChannel=twitchUser.getHandle(), userId=userIdThatRedeemed, userName=userNameThatRedeemed) self.__timber.log( 'CutenessRedemption', f'Redeemed cuteness of {incrementAmount} for {userNameThatRedeemed}:{userIdThatRedeemed} in {twitchUser.getHandle()}' ) except (OverflowError, ValueError) as e: self.__timber.log( 'CutenessRedemption', f'Error redeeming cuteness of {incrementAmount} for {userNameThatRedeemed}:{userIdThatRedeemed} in {twitchUser.getHandle()}: {e}' ) await twitchUtils.safeSend( twitchChannel, f'⚠ Error increasing cuteness for {userNameThatRedeemed}') return True
async def handlePointRedemption(self, twitchChannel: Channel, twitchUser: User, redemptionMessage: str, rewardId: str, userIdThatRedeemed: str, userNameThatRedeemed: str) -> bool: if twitchChannel is None: raise ValueError( f'twitchChannel argument is malformed: \"{twitchChannel}\"') elif twitchUser is None: raise ValueError( f'twitchUser argument is malformed: \"{twitchUser}\"') elif not utils.isValidStr(rewardId): raise ValueError(f'rewardId argument is malformed: \"{rewardId}\"') elif not utils.isValidStr(userIdThatRedeemed): raise ValueError( f'userIdThatRedeemed argument is malformed: \"{userIdThatRedeemed}\"' ) elif not utils.isValidStr(userNameThatRedeemed): raise ValueError( f'userNameThatRedeemed argument is malformed: \"{userNameThatRedeemed}\"' ) if not twitchUser.isPkmnEnabled( ) or not twitchUser.hasPkmnCatchBoosterPacks(): return False pkmnCatchBoosterPack: PkmnCatchBoosterPack = None for pkbp in twitchUser.getPkmnCatchBoosterPacks(): if rewardId == pkbp.getRewardId(): pkmnCatchBoosterPack = pkbp break if pkmnCatchBoosterPack is None: return False funtoonPkmnCatchType: FuntoonPkmnCatchType = None if pkmnCatchBoosterPack.hasCatchType(): funtoonPkmnCatchType = self.__toFuntoonPkmnCatchType( pkmnCatchBoosterPack) generalSettings = await self.__generalSettingsRepository.getAllAsync() actionCompleted = False if generalSettings.isFuntoonApiEnabled(): if await self.__funtoonRepository.pkmnCatch( userThatRedeemed=userNameThatRedeemed, twitchChannel=twitchUser.getHandle(), funtoonPkmnCatchType=funtoonPkmnCatchType): actionCompleted = True if not actionCompleted and generalSettings.isFuntoonTwitchChatFallbackEnabled( ): await twitchUtils.safeSend(twitchChannel, f'!catch {userNameThatRedeemed}') actionCompleted = True self.__timber.log( 'PkmnCatchRedemption', f'Redeemed pkmn catch for {userNameThatRedeemed}:{userIdThatRedeemed} (catch type: {pkmnCatchBoosterPack.getCatchType()}) in {twitchUser.getHandle()}' ) return actionCompleted