def single_card_text_internal(client: Client, requested_card: Card, disable_emoji: bool) -> str: mana = emoji.replace_emoji('|'.join(requested_card.mana_cost or []), client) mana = mana.replace('|', ' // ') legal = ' — ' + emoji.info_emoji(requested_card, verbose=True) if disable_emoji: legal = '' if requested_card.get('mode', None) == '$': text = '{name} {legal} — {price}'.format( name=requested_card.name, price=card_price.card_price_string(requested_card), legal=legal) else: text = '{name} {mana} — {type}{legal}'.format( name=requested_card.name, mana=mana, type=requested_card.type_line, legal=legal) if requested_card.bugs: for bug in requested_card.bugs: text += '\n:beetle:{rank} bug: {bug}'.format( bug=bug['description'], rank=bug['classification']) if bug['last_confirmed'] < (dtutil.now() - datetime.timedelta(days=60)): time_since_confirmed = (dtutil.now() - bug['last_confirmed']).total_seconds() text += ' (Last confirmed {time} ago.)'.format( time=dtutil.display_time(time_since_confirmed, 1)) return text
async def post_cards(client: Client, cards: List[Card], channel: Messageable, replying_to: Optional[Member] = None, additional_text: str = '') -> None: if len(cards) == 0: await post_no_cards(channel, replying_to) return not_pd = configuration.get_list('not_pd') disable_emoji = str( channel.id) in not_pd or (getattr(channel, 'guild', None) is not None and str(channel.guild.id) in not_pd) cards = uniqify_cards(cards) if len(cards) > MAX_CARDS_SHOWN: cards = cards[:DEFAULT_CARDS_SHOWN] if len(cards) == 1: text = single_card_text_internal(client, cards[0], disable_emoji) else: text = ', '.join('{name} {legal} {price}'.format( name=card.name, legal=((emoji.info_emoji(card)) if not disable_emoji else ''), price=((card_price.card_price_string(card, True) ) if card.get('mode', None) == '$' else '')) for card in cards) if len(cards) > MAX_CARDS_SHOWN: image_file = None else: with channel.typing(): image_file = await image_fetcher.download_image_async(cards) if image_file is None: text += '\n\n' if len(cards) == 1: text += emoji.replace_emoji(cards[0].oracle_text, client) else: text += 'No image available.' text += additional_text if image_file is None: await send(channel, text) else: await send_image_with_retry(channel, image_file, text)