コード例 #1
0
async def get_fleet_users_stars_from_info(ctx: commands.Context, fleet_info: dict, fleet_users_infos: dict, retrieved_date: datetime = None, as_embed: bool = settings.USE_EMBEDS) -> list:
    fleet_name = fleet_info[FLEET_DESCRIPTION_PROPERTY_NAME]
    division = lookups.DIVISION_DESIGN_ID_TO_CHAR[fleet_info[top.DIVISION_DESIGN_KEY_NAME]]

    fleet_users_infos = util.sort_entities_by(list(fleet_users_infos.values()), [('AllianceScore', int, True), (user.USER_KEY_NAME, int, False)])
    fleet_users_infos_count = len(fleet_users_infos)

    title = f'{fleet_name} member stars (division {division})'
    lines = []
    for i, user_info in enumerate(fleet_users_infos, 1):
        stars = user_info['AllianceScore']
        user_name = util.escape_markdown(user_info[user.USER_DESCRIPTION_PROPERTY_NAME])
        fleet_membership = user_info.get('AllianceMembership')
        if i < fleet_users_infos_count:
            difference = int(user_info['AllianceScore']) - int(fleet_users_infos[i]['AllianceScore'])
        else:
            difference = 0
        user_rank = lookups.get_lookup_value_or_default(lookups.ALLIANCE_MEMBERSHIP, fleet_membership, default=fleet_membership)
        lines.append(f'**{i}.** {stars} (+{difference}) {emojis.star} {user_name} ({user_rank})')

    footer_text = util.get_historic_data_note(retrieved_date)

    if as_embed:
        colour = util.get_bot_member_colour(ctx.bot, ctx.guild)
        icon_url = await sprites.get_download_sprite_link(fleet_info.get('AllianceSpriteId'))
        result = util.create_basic_embeds(title, description=lines, colour=colour, icon_url=icon_url, footer=footer_text)
        return result
    else:
        if retrieved_date is not None:
            lines.append(f'```{footer_text}```')
        return lines
コード例 #2
0
ファイル: pss_fleet.py プロジェクト: savisaar2/YaDc
def get_fleet_users_stars_from_info(fleet_info: dict,
                                    fleet_users_infos: dict,
                                    retrieved_date: datetime = None) -> list:
    fleet_name = fleet_info[FLEET_DESCRIPTION_PROPERTY_NAME]
    division = lookups.DIVISION_DESIGN_ID_TO_CHAR[
        fleet_info['DivisionDesignId']]

    fleet_users_infos = util.sort_entities_by(list(
        fleet_users_infos.values()), [('AllianceScore', int, True),
                                      (user.USER_KEY_NAME, int, False)])
    fleet_users_infos_count = len(fleet_users_infos)

    lines = [f'**{fleet_name} member stars (division {division})**']
    for i, user_info in enumerate(fleet_users_infos, 1):
        stars = user_info['AllianceScore']
        user_name = util.escape_markdown(
            user_info[user.USER_DESCRIPTION_PROPERTY_NAME])
        if i < fleet_users_infos_count:
            difference = int(user_info['AllianceScore']) - int(
                fleet_users_infos[i]['AllianceScore'])
        else:
            difference = 0
        lines.append(
            f'**{i}.** {stars} (+{difference}) {emojis.star} {user_name}')

    if retrieved_date is not None:
        lines.append(util.get_historic_data_note(retrieved_date))

    return lines
コード例 #3
0
 def get_name_at_username(self, escape_markdown=False):
     if self.username:
         result = "{} @{}".format(self.name, self.username)
     else:
         result = self.name
     if escape_markdown:
         return escape_markdown(result)
     return result
コード例 #4
0
def _get_division_stars_as_text(division_letter: str, fleet_infos: list) -> list:
    lines = [f'__**Division {division_letter.upper()}**__']
    fleet_infos = util.sort_entities_by(fleet_infos, [('Score', int, True)])
    fleet_infos_count = len(fleet_infos)
    for i, fleet_info in enumerate(fleet_infos, start=1):
        fleet_name = util.escape_markdown(fleet_info['AllianceName'])
        if 'Trophy' in fleet_info.keys():
            trophies = fleet_info['Trophy']
            trophy_str = f' ({trophies} {emojis.trophy})'
        else:
            trophy_str = ''
        stars = fleet_info['Score']
        if i < fleet_infos_count:
            difference = int(stars) - int(fleet_infos[i]['Score'])
        else:
            difference = 0
        lines.append(f'**{i:d}.** {stars} (+{difference}) {emojis.star} {fleet_name}{trophy_str}')
    return lines
コード例 #5
0
def _get_top_captains_as_text(captain_data: dict, take: int = 100):
    headline = f'**Top {take} captains**'
    lines = [headline]

    position = 0
    for entry in captain_data.values():
        position += 1
        name = util.escape_markdown(entry['Name'])
        trophies = entry['Trophy']
        fleet_name = entry['AllianceName']

        trophy_txt = f'{trophies} {emojis.trophy}'

        line = f'**{position}.** {name} ({fleet_name}): {trophy_txt}'
        lines.append(line)
        if position == take:
            break

    return lines
コード例 #6
0
def _get_top_fleets_as_text(alliance_data: dict, take: int = 100):
    tourney_running = tourney.is_tourney_running()

    headline = f'**Top {take} fleets**'
    lines = [headline]

    position = 0
    for entry in alliance_data.values():
        position += 1
        name = util.escape_markdown(entry['AllianceName'])
        trophies = entry['Trophy']
        stars = entry['Score']

        trophy_txt = f'{trophies} {emojis.trophy}'
        if tourney_running:
            stars_txt = f', {stars} {emojis.star}'
        else:
            stars_txt = ''

        line = f'**{position}.** {name} ({trophy_txt}{stars_txt})'
        lines.append(line)

    return lines
コード例 #7
0
 def get_creator_name(self):
     creator_name = self.players_names[0]
     return escape_markdown(creator_name)
コード例 #8
0
 def get_username(self, escape_markdown=True):
     if self.username is None:
         return None
     return utility.escape_markdown(
         self.username) if escape_markdown else self.name
コード例 #9
0
 def get_first_name(self, escape_markdown=True):
     return utility.escape_markdown(
         self.name) if escape_markdown else self.name
コード例 #10
0
MSG_CONTINUE = "🔁 Vuoi continuare?"

MSG_TOO_EARLY = "⏰ Troppo presto... prova a pensarci ancora un po'."

MSG_SEND_PHOTO_NOT_DOCUMENT = "⛔️ Mandami l'immagine come *Foto* e non come documento."
MSG_WRONG_INPUT_OLD_KEYBOARD = "⛔️ Input non valido, probabilmente hai premuto un tasto che non è più valido nell'interfaccia aggiornata. Sarai reindirizzato/a nella schermata iniziale."
MSG_WRONG_INPUT_ONLY_TEXT_ACCEPTED = "⛔️ Input non valido, devi inserire solo del testo."
MSG_WRONG_INPUT_USE_TEXT = '⛔ Input non valido, per favore inserisci del testo.'
MSG_WRONG_INPUT_USE_TEXT_OR_BUTTONS = '⛔️ Input non valido, per favore inserisci del testo o usa i pulsanti 🎛'
MSG_WRONG_INPUT_INSRT_NUMBER = '⛔️🔢 Input non valido, per favore inserisci un numero.'
MSG_WRONG_INPUT_INSRT_NUMBER_BETWEEN = '⛔️🔢 Input non valido, per favore inserisci un numero da {} a {}.'
MSG_WRONG_INPUT_USE_BUTTONS = '⛔️ Input non valido, per favore usa i pulsanti 🎛'
MSG_WRONG_INPUT_USE_BUTTONS_TEXT_PHOTO = '⛔️ Input non valido, per favore usa i pulsanti, testo o immagini.'
MSG_WRONG_BUTTON_INPUT = '⛔️ Input non valido, probabilmente hai premuto un tasto due volte.'
MSG_INPUT_TOO_SHORT = '⛔️ Input troppo corto.'
MSG_INPUT_CONTAINS_SPACE_OR_MARKDOWN = '⛔️ Input non può conotenere spazi o i caratteri: "{}".'.format(
    utility.escape_markdown(utility.MARKDOWN_CHARS))
MSG_INPUT_NO_MARKDOWN = '⛔️ Il testo non può contenere i caratteri: {}'.format(
    utility.escape_markdown(utility.MARKDOWN_CHARS))
MSG_COMMAND_NOT_RECOGNIZED = '⛔️ Comando non riconosciuto.'

MSG_REFRESH_INTERFACE = "🤖 Il chatbot è stato aggiornato."

ALL_BUTTONS_TEXT_LIST = [
    v for k, v in globals().items() if k.startswith('BUTTON_')
]


def text_is_button(text):
    return text in ALL_BUTTONS_TEXT_LIST
コード例 #11
0
 def get_name_and_id(self, escape_md=True):
     result = "{} ({})".format(self.name, self.serial_id)
     if escape_markdown:
         return escape_markdown(result)
     return result
コード例 #12
0
 def get_name(self, escape_md=True):
     if escape_md:
         return escape_markdown(self.name)
     return self.name
コード例 #13
0
    'it': '⛔️ Input non valido, per favore usa i pulsanti 🎛'
}
MSG_WRONG_BUTTON_INPUT = {
    'en': '⛔️ Wrong input, you probably pressed a button twice.',
    'it': '⛔️ Input non valido, probabilmente hai premuto un tasto due volte.'
}
MSG_INPUT_TOO_SHORT = {
    'en': '⛔️ Input too short.',
    'it': '⛔️ Input troppo corto.'
}
MSG_NAME_TOO_LONG = {
    'en': '⛔️ Input too long, please insert a text with max {} characters.',
    'it': '⛔️ Input troppo lungo, inserisci un nome con al massimo {} caratteri.'
}
MSG_GAME_NAME_ERROR = {
    'en': '⛔️ Game name cannot contain spaces or the following characters: "{}".'.format(utility.escape_markdown(utility.MARKDOWN_CHARS_SLASH)),
    'it': '⛔️ Il nome del gioco non può conotenere spazi o i caratteri: "{}".'.format(utility.escape_markdown(utility.MARKDOWN_CHARS_SLASH))
}
MSG_INPUT_NO_MARKDOWN = {
    'en': '⛔️ Input cannot contain the following characters: {}'.format(utility.escape_markdown(utility.MARKDOWN_CHARS)),
    'it': '⛔️ Il testo non può contenere i caratteri: {}'.format(utility.escape_markdown(utility.MARKDOWN_CHARS))
}
MSG_CHAT_MSG_NO_MARKDOWN = {
    'en': '⛔️ The chat message cannot contain the following characters: {}'.format(utility.escape_markdown(utility.MARKDOWN_CHARS)),
    'it': '⛔️ Il testo del messaggio non può contenere i caratteri: {}'.format(utility.escape_markdown(utility.MARKDOWN_CHARS))
}
MSG_INPUT_NO_UNDERSCORES = {
    'en': '⛔️ The text you have inserted does not contain the sequence of 3 underscores (\'___\').',
    'it': '⛔️ Il testo inserito non contiene la sequenza di 3 trattini bassi (\'___\').'
}
MSG_INPUT_NO_SYNONYM = {