Пример #1
0
async def clear_quadrant(cmd):
    response = ""
    author = cmd.message.author
    quadrant = None
    user_data = EwUser(id_user=author.id, id_server=author.guild.id)
    if user_data.life_state == ewcfg.life_state_shambler:
        response = "You lack the higher brain functions required to {}.".format(
            cmd.tokens[0])
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    for token in cmd.tokens[1:]:
        if token.lower() in quad_static.quadrants_map:
            quadrant = quad_static.quadrants_map[token.lower()]
        if quadrant is not None:
            break

    if quadrant is None:
        response = "Please select a quadrant for your romantic feelings."
        return await fe_utils.send_message(
            cmd.client, cmd.message.channel,
            fe_utils.formatMessage(cmd.message.author, response))

    quadrant_data = EwQuadrant(id_server=author.guild.id,
                               id_user=author.id,
                               quadrant=quadrant.id_quadrant)

    if quadrant_data.id_target != -1:
        target_member_data = cmd.guild.get_member(quadrant_data.id_target)
        target_member_data_2 = None

        if quadrant_data.id_target2 != -1:
            target_member_data_2 = cmd.guild.get_member(
                quadrant_data.id_target)

        quadrant_data = EwQuadrant(id_server=author.guild.id,
                                   id_user=author.id,
                                   quadrant=quadrant.id_quadrant,
                                   id_target=-1,
                                   id_target2=-1)
        quadrant_data.persist()

        response = "You break up with {}. Maybe it's for the best...".format(
            target_member_data.display_name)
        if target_member_data_2 != None:
            response = "You break up with {} and {}. Maybe it's for the best...".format(
                target_member_data.display_name,
                target_member_data_2.display_name)

    else:
        response = "You haven't filled out that quadrant, bitch."

    return await fe_utils.send_message(
        cmd.client, cmd.message.channel,
        fe_utils.formatMessage(cmd.message.author, response))
Пример #2
0
def get_quadrant(cmd, id_quadrant):
    author = cmd.message.author
    quadrant = quad_static.quadrants_map[id_quadrant]
    if cmd.mentions_count == 0:
        quadrant_data = EwQuadrant(id_server=author.guild.id,
                                   id_user=author.id,
                                   quadrant=quadrant.id_quadrant)
        if author.guild.get_member(quadrant_data.id_target) is None:
            quadrant_data.id_target = -1
        if author.guild.get_member(quadrant_data.id_target2) is None:
            quadrant_data.id_target2 = -1

        quadrant_data.persist()

        if quadrant_data.id_target == -1:
            response = "You have no one in this quadrant."
        else:
            onesided = quadrant_data.check_if_onesided()

            if quadrant.id_quadrant == ewcfg.quadrant_policitous and quadrant_data.id_target2 != -1:
                target_name = "{} and {}".format(
                    author.guild.get_member(
                        quadrant_data.id_target).display_name,
                    author.guild.get_member(
                        quadrant_data.id_target2).display_name)
            else:
                target_name = author.guild.get_member(
                    quadrant_data.id_target).display_name

            if not onesided:
                response = quadrant.resp_view_relationship_self.format(
                    target_name)
            else:
                response = quadrant.resp_view_onesided_self.format(target_name)

    else:
        member = cmd.mentions[0]
        quadrant_data = EwQuadrant(id_server=member.guild.id,
                                   id_user=member.id,
                                   quadrant=quadrant.id_quadrant)

        if author.guild.get_member(quadrant_data.id_target) is None:
            quadrant_data.id_target = -1
        if author.guild.get_member(quadrant_data.id_target2) is None:
            quadrant_data.id_target2 = -1

        quadrant_data.persist()

        if quadrant_data.id_target == "":
            response = "They have no one in this quadrant."
        else:

            onesided = quadrant_data.check_if_onesided()

            if quadrant.id_quadrant == ewcfg.quadrant_policitous and quadrant_data.id_target2 != -1:
                target_name = "{} and {}".format(
                    author.guild.get_member(
                        quadrant_data.id_target).display_name,
                    author.guild.get_member(
                        quadrant_data.id_target2).display_name)
            else:
                target_name = author.guild.get_member(
                    quadrant_data.id_target).display_name

            if not onesided:
                response = quadrant.resp_view_relationship.format(
                    member.display_name, target_name)
            else:
                response = quadrant.resp_view_onesided.format(
                    member.display_name, target_name)

    return response