예제 #1
0
    def _make_i_statement(self):
        """
        {prefix}{PUNC} I {love, hate, f**k with, etc} {subject}{PUNC} {suffix}
        For real, I f*****g love the lions. chyaaa
        """
        i_statement = ''
        verb = Phrase.get_next('VERB', sentiment=self.sentiment)
        subject = f'the {self}' if self.plural else self.name

        subject = subject.replace('-', ' ')

        if flip_coin():
            adverb = Phrase.get_next(kind="ADVERB")
            i_statement += f'i {adverb} {verb} {subject}'
        else:
            i_statement = f'i {verb} {subject}'

        if random.choice([1, 2, 3]) in [1, 2]:
            punctuation = Phrase.get_next('PUNCTUATION',
                                          sentiment=self.sentiment)
            i_statement += f'{punctuation} '
        else:
            i_statement += ' '

        if flip_coin():
            suffix = Phrase.get_next('SUFFIX', sentiment=self.sentiment)
            i_statement += f'{suffix} '

        if flip_coin():
            i_statement += Phrase.get_next('EMOJI', sentiment=self.sentiment)

        i_statement = " ".join(i_statement.split())
        return i_statement
예제 #2
0
    def _make_analogy(self):
        """"""
        def _compare_with_other_subject():
            lower_bound = self.sentiment - 2
            upper_bound = self.sentiment + 2
            comparing_subject = Subject.objects.filter(
                sentiment__lte=upper_bound,
                sentiment__gte=lower_bound).exclude(
                    topic__id=self.topic_id).order_by('used').first()
            comparing_subject.used += 1
            comparing_subject.save()

            verb = "are" if self.plural else "is"
            choices = ['like', 'basically', 'essentially', 'kinda like', '']
            # the lions are basically the shotgunning tallboys of football teams
            text = f"{self} {verb} {random.choice(choices)} the {comparing_subject} of {self.topic}"
            return text

        def _compare_with_altered_other_subject():
            opposite = 10 - self.sentiment
            lower_bound = opposite - 2
            upper_bound = opposite + 2
            comparing_subject = Subject.objects.filter(
                sentiment__lte=upper_bound, sentiment__gte=lower_bound).filter(
                    topic__id=self.topic_id).order_by('used').first()

            if not comparing_subject:
                return ''

            comparing_subject.used += 1
            comparing_subject.save()

            verb = "are" if self.plural else "is"
            adjective = Phrase.get_next('ADJECTIVE', sentiment=self.sentiment)
            choices = [
                'like if', 'arguably like if', 'essentially like if',
                'kinda like if'
            ]
            n = 'the' if self.plural else ''
            o = 'were' if self.plural else 'was'
            # the lions are essentially like if the packers were amazing
            text = f"{self} {verb} {random.choice(choices)} {n} {comparing_subject} {o} actually {adjective}"
            return text

        if flip_coin():
            text = _compare_with_other_subject()
        else:
            text = _compare_with_altered_other_subject()

        if flip_coin():
            text += f" {Phrase.get_next('PUNCTUATION', sentiment=self.sentiment)}"

        if flip_coin():
            text += f" {Phrase.get_next('SUFFIX', sentiment=self.sentiment)}"
        if flip_coin():
            text += f" {Phrase.get_next('EMOJI', sentiment=self.sentiment)}"

        return text
예제 #3
0
    def express_sentiment(self, request):
        sentiment = 7
        if request.sentiment in ['POSITIVE', 'LAUGHING']:
            sentiment = 8
        if request.sentiment == 'NEGATIVE':
            sentiment = 2

        if sentiment > 6 and flip_coin():
            text = Phrase.get_next('YES')
        else:
            text = ''

        first_choice = random.choice([1, 2])
        if first_choice == 1:
            phrase_type = 'EMOJI'
        else:
            phrase_type = 'SUFFIX'
        try:
            text = Phrase.get_next(phrase_type, sentiment=sentiment)
        except IndexError:
            text = ''

        if first_choice != 1:
            text += Phrase.get_next('PUNCTUATION', sentiment=sentiment)

        def _route_one():
            # sender name is blank
            # sender name is the {best, closest to god, most supreme}
            # sender name is the {worst, most embarrassing, least qualified}
            return f" {request.sender_display_name} is {Phrase.get_next('ADJECTIVE', sentiment=sentiment)} "

        def _route_two():
            # "I feel blank"
            # "that makes me feel blank"
            return f" i feel {Phrase.get_next('ADJECTIVE', sentiment=sentiment)} "

        def _route_three():
            # that's blank as f**k
            return f" that ' s {Phrase.get_next('ADJECTIVE', sentiment=sentiment)} like {Subject.get_next(sentiment=sentiment)} "

        second_choice = random.choice([1, 2, 3])
        if second_choice == 1:
            text += _route_one()
        elif second_choice == 2:
            text += _route_two()
        else:
            text += _route_three()

        text += f"{Phrase.get_next('PUNCTUATION', sentiment=sentiment)} "

        if first_choice != 2:
            text += Phrase.get_next('SUFFIX', sentiment=sentiment)
        elif flip_coin():
            text += Phrase.get_next('EMOJI', sentiment=sentiment)

        return text
예제 #4
0
    def _add_a_little(self):
        prefix = Phrase.get_next('PREFIX', sentiment=self.sentiment)
        verb = 'are' if self.plural else 'is'
        text = f"{prefix} {self} {verb} {Phrase.get_next('ADJECTIVE', sentiment=self.sentiment)}{Phrase.get_next('PUNCTUATION', sentiment=self.sentiment)} "

        if flip_coin():
            text += f" {Phrase.get_next('SUFFIX', sentiment=self.sentiment)}"
        if flip_coin():
            text += f" {Phrase.get_next('EMOJI', sentiment=self.sentiment)}"
        return text
예제 #5
0
    def express_opinion(self):
        """
        """
        if self.topic.name == "FOOTBALL_TEAMS":
            if flip_coin():
                return self.offer_bet(entity='TEAM')
            else:
                return self._make_analogy()

        choices = [1, 2, 3, 4]
        if self.topic.name == "FOOTBALL_PLAYERS":
            choices.append(5)

        if self.topic.name == "BBR_MEMBERS":
            choices.append(6)

        choice = random.choice(choices)
        if choice == 1:
            return self._describe()
        elif choice == 2:
            return self._make_i_statement()
        elif choice == 3:
            return self._make_analogy()
        elif choice == 4:
            return self._add_a_little()
        elif choice == 5:
            return self.offer_bet(entity='PLAYER')
        elif choice == 6:
            return self.offer_bet(entity='MEMBER')
예제 #6
0
 def right(self):
     choices = ['f*****g right', 'damn straight', 'that\'s right', 'you know it', '💯']
     core = '{} {}'.format(random.choice(choices), self.sender)
     core += f" {Phrase.get_next('SUFFIX', sentiment=8)}"
     if flip_coin():
         core += f" {Phrase.get_next('EMOJI', sentiment=8)}"
     return self._build_answer(confirm=False, core=core, suffix=False)
예제 #7
0
 def talk_about_adjective(self, adjective):
     prefixes = [
         "i'll tell you what else is", "you know what else is",
         "speaking of", "while we're on the topic of"
     ]
     subject = Subject.objects.filter(
         sentiment__gte=adjective.sentiment - 2,
         sentiment__lte=adjective.sentiment + 2).order_by('?').first()
     subject_verb = "are" if subject.plural else "is"
     text = f"{random.choice(prefixes)} {adjective}, "
     if flip_coin():
         text += f"{subject} {subject_verb} {adjective}. "
     else:
         text += f"how about {subject}. "
     text += f"{subject.express_opinion()}"
     return text
예제 #8
0
def offer_bet(subject, entity):
    if flip_coin():
        text = route_one(subject, entity)
    else:
        text = route_two(subject, entity)
예제 #9
0
def route_two(subject, entity):
    amount = random.choice(['a', 'a', 'a', 5, 5, 10, 10, 25, 100])
    bet = Phrase.get_next('BETTABLE')

    # strip the 's' off the end
    if amount == 'a':
        bet = bet[:-1]

    if entity == 'MEMBER':
        if flip_coin():
            start = random.choice(["i bet", "i'd bet", "i'd bet you"])
            text = f"{start} {amount} {bet} {subject.member.name} "
        else:
            text = f"{amount} {bet} says {subject.member.name} "

        if flip_coin():
            verb = random.choice([
                "gets pierced", "misses the playoffs", "makes the playoffs",
                "wins it all"
            ])
            verb += " this year"
        else:
            verb = random.choice(
                ["cant pull off a shotgun", "doesnt send a shotgun vid"])
            verb += random.choice([" today", " this week", " by this weekend"])

        text += verb

    elif entity == 'TEAM':
        if flip_coin():
            start = random.choice(["i bet", "i'd bet", "i'd bet you"])
            text = f"{start} {amount} {bet} the {subject} "
        else:
            text = f"{amount} {bet} says the {subject} "

        if team := NFLTeam.objects.filter(
                name__contains=subject.name.capitalize()).first():
            if team.next_opponent is not None:
                verb = " beat " if subject.sentiment > 5 else " lose to "
                text += f"{verb} the {team.next_opponent} "
                choices = ["week 1"]
                text += random.choice(choices)
                if flip_coin():
                    text += f" {Phrase.get_next('SUFFIX', sentiment=subject.sentiment)}"
                if flip_coin():
                    text += f" {Phrase.get_next('EMOJI', sentiment=subject.sentiment)}"
                return text

        choices = [
            "win", "lose", "score over POINTS", "score less than POINTS"
        ]

        if subject.sentiment >= 5:
            prop = random.choice(
                ["win ", "score over POINTS ", "score more than POINTS"])
        else:
            prop = random.choice(
                ["lose ", "score less than POINTS", "score under POINTS"])

        text += random.choice(choices)
        if "POINTS" in text:
            points = random.choice(range(18, 36))
            points += .5
            text = text.replace("POINTS", str(points))
        text += " week 1"
예제 #10
0
        if subject.sentiment >= 5:
            prop = random.choice(
                ["win ", "score over POINTS ", "score more than POINTS"])
        else:
            prop = random.choice(
                ["lose ", "score less than POINTS", "score under POINTS"])

        text += random.choice(choices)
        if "POINTS" in text:
            points = random.choice(range(18, 36))
            points += .5
            text = text.replace("POINTS", str(points))
        text += " week 1"
    else:
        if flip_coin():
            text = f"i bet you {amount} {bet} {subject} scores "
        else:
            text = f"{amount} {bet} says {subject} scores "

        if subject.sentiment >= 5:
            prop = random.choice(["over ", "more than "])
        else:
            prop = random.choice(["under ", "less than "])

        text += prop
        points = random.choice(range(8, 19))
        points += .5
        text += str(points)
        text += " fantasy points week 1"
예제 #11
0
    def build(self):
        request_type = self.request.message_type

        text = None

        if request_type == 'HELP':
            text = self.help()

        elif request_type == 'FACT':
            text = self.process_fact()

        elif request_type == 'FOLLOW_UP':
            text = self.process_followup()

        elif request_type == 'GIF':
            text = self.find_gif()
            self.image = text

        elif request_type == 'IMAGE':
            text = self.find_image()

        elif request_type == 'CONTENT':
            text = self.find_content()

        elif request_type == 'CHECK_IN':
            text = self.give_update()

        elif request_type == 'WAIVER':
            wrapper = ESPNWrapper()
            text = wrapper.pickup()

        elif request_type == 'STANDINGS':
            text = ESPNWrapper().standings()

        elif request_type == 'SIMULATE':
            text = ESPNWrapper().final_standings()

        elif request_type == 'RANKINGS':
            text = ESPNWrapper().get_power_rankings()

        elif request_type == 'SHOTGUN':
            text = self.shotgun()

        elif request_type == 'YEBOA':
            text = self.yeboa()

        elif request_type == 'BET':
            text = self.offer_bet()

        elif request_type == 'QUESTION':
            sender = self.request.sender_display_name
            text = Answerer(sender=sender, request=self.request).answer()

        elif self.request.subject:
            text = Subject.objects.get(
                name=self.request.subject).express_opinion()

        elif self.request.adjective:
            adjective = Phrase.objects.get(text=self.request.adjective,
                                           kind='ADJECTIVE')
            text = self.request.bot.talk_about_adjective(adjective)

        elif self.request.bot.current_subject:
            text = Subject.objects.get(
                name=self.request.bot.current_subject).express_opinion()
            self.request.bot.current_subject = None
            self.request.bot.save()

        elif len(self.request.text) > 100:
            text = Subject.objects.get(name='long-messages').express_opinion()

        elif self.request.sentiment == "POSITIVE":
            choice = random.choice([1, 2, 3])
            if choice == 1:
                text = self.request.bot.express_sentiment(request=self.request)
            if choice == 2:
                text = ManagerFact.get_next(manager=self.request.sender,
                                            sentiment=8)
            if choice == 3:
                text = self.request.bot.express_sentiment(request=self.request)

            if not text:
                text = self.request.bot.express_sentiment(request=self.request)

        elif self.request.sentiment == "NEGATIVE":
            choice = random.choice([1, 2, 3])
            if choice == 1:
                text = self.request.bot.express_sentiment(request=self.request)
            if choice == 2:
                text = ManagerFact.get_next(manager=self.request.sender,
                                            sentiment=3)
            if choice == 3:
                subject = Subject.objects.get(member=self.request.sender)
                text = subject.express_opinion()

            if not text:
                text = self.request.bot.express_sentiment(request=self.request)

        elif self.request.sentiment == "LAUGHING":
            choice = random.choice([1, 2, 3])
            if choice == 1:
                text = self.request.bot.express_sentiment(request=self.request)
            if choice == 2:
                text = ManagerFact.get_next(manager=self.request.sender,
                                            sentiment=8)
            if choice == 3:
                subject = Subject.objects.get(member=self.request.sender)
                text = subject.express_opinion()

            if not text:
                text = self.request.bot.express_sentiment(request=self.request)

        if not text:
            if flip_coin():
                subject = Subject.objects.get(member=self.request.sender)
                text = subject.offer_bet(entity="MEMBER")
            else:
                text = self.request.bot.express_sentiment(request=self.request)

        if not text or text == '':
            choices = [
                f"lol i {Phrase.get_next('VERB', sentiment=8)} {self.request.sender_display_name}",
                f"lmao {self.request.sender_display_name} is {Phrase.get_next('ADJECTIVE', sentiment=8)}",
                f"{self.request.sender_display_name} with the {Phrase.get_next('THING', sentiment=8)}",
                f"that's some {Phrase.get_next('ADJECTIVE')} shit"
                "damn for real?",
                f"lol you right {self.request.sender_display_name}",
                f"lol i guess so {self.request.sender_display_name}",
                f"{self.request.sender_display_name} bringing the {Phrase.get_next('THING', sentiment=8)}",
                f"{self.request.sender_display_name} out here hittin home runs",
                "sick!!", "we lit"
            ]
            text = random.choice(choices)

            text += f" {Phrase.get_next('EMOJI')}"

        text = text.replace('MEMBER_NAME', self.request.sender_display_name)
        self.text = text
        self.save()
예제 #12
0
    def follow_up(self,
                  unknown_subject=None,
                  unknown_adjective=None,
                  subject=None,
                  adjective=None):
        self.request.bot.awaiting_answer = True

        if subject and adjective:
            self.request.bot.awaiting_answer = False
            readable_subject = subject.name.replace('-', ' ')
            self.request.bot.current_subject = subject.name
            adjective = Phrase.objects.get(text=adjective, kind='ADJECTIVE')

            if abs(subject.sentiment - adjective.sentiment) >= 4:
                nounverb = "they're" if subject.plural else "its"
                actual_adjective = Phrase.get_next("ADJECTIVE",
                                                   sentiment=subject.sentiment)
                text = f"nah, {nounverb} actually {actual_adjective}"
            elif abs(subject.sentiment - adjective.sentiment) >= 2:
                noun = "they're" if subject.plural else "its"
                verb = 'were' if subject.plural else 'was'
                previous_adjective = Phrase.get_next(
                    "ADJECTIVE", sentiment=subject.sentiment)
                new_adjective = Phrase.get_next("ADJECTIVE",
                                                sentiment=adjective.sentiment)
                text = f"huh, i thought {readable_subject} {verb} {previous_adjective}. Turns out {noun} {new_adjective}"
                subject.sentiment = adjective.sentiment
                subject.save()
            else:
                self.request.bot.awaiting_answer = False
                verb = 'are' if subject.plural else 'is'
                adjective = Phrase.get_next("ADJECTIVE",
                                            sentiment=subject.sentiment)
                text = f"{Phrase.get_next('YES')}, {subject.name} {verb} indeed {adjective}"

        elif subject and unknown_adjective:
            readable_unknown_adjective = unknown_adjective.replace('-', ' ')
            opinion_text = ''
            adjective = Phrase.get_next(kind="ADJECTIVE",
                                        sentiment=subject.sentiment)
            verb = 'are' if subject.plural else 'is'
            subject = f'the {subject}' if subject.plural else subject
            if flip_coin():
                adverb = Phrase.get_next(kind="ADVERB")
                opinion_text += f'{subject.name} {verb} {adverb} {adjective}'
            else:
                opinion_text = f'{subject.name} {verb} {adjective}'

            self.request.bot.current_subject = subject.name
            self.request.bot.unknown_adjective = unknown_adjective
            self.request.bot.awaiting_anser = False

            text = f"Im familiar with {subject.name}. {opinion_text}. Please help me out and rate '{readable_unknown_adjective}' on a scale f 1 to 10"

        elif unknown_subject and adjective:
            adjective = Phrase.objects.get(kind='ADJECTIVE', text=adjective)
            readable_unknown_subject = unknown_subject.replace('-', ' ')
            new_adjective = Phrase.get_next(kind="ADJECTIVE",
                                            sentiment=adjective.sentiment)
            text = f"{Phrase.get_next('ACKNOWLEDGMENT')} {readable_unknown_subject} is {new_adjective}"
            subject = Subject.objects.create(
                name=unknown_subject,
                sentiment=adjective.sentiment,
                topic=Topic.objects.get(name="WHATEVER"))
            self.request.bot.awaiting_anser = False
            self.request.bot.current_subject = unknown_subject
            self.request.bot.unknown_subject = None

            text += f" {subject.express_opinion()}"

        else:
            readable_unknown_subject = unknown_subject.replace('-', ' ')
            self.request.bot.unknown_subject = unknown_subject
            self.request.bot.current_subject = unknown_subject
            text = f"I haven't heard of {readable_unknown_subject}. Please help me out and rate it on a scale of 1 to 10"

        self.request.bot.save()
        return text