Exemplo n.º 1
0
def build_message_for_integration(bounty, event_name):
    """Build message to be posted to integrated service (e.g. slack).

    Args:
        bounty (dashboard.models.Bounty): The Bounty to be marketed.
        event_name (str): The name of the event.

    Returns:
        str: Message to post to slack.

    """
    from dashboard.utils import humanize_event_name
    event_name_in_msg = humanize_event_name(event_name)
    if event_name == 'killed_bounty':
        if (bounty.bulk_payout_tips.count()):
            event_name_in_msg = humanize_event_name('work_done')
    conv_details = ""
    usdt_details = ""
    try:
        conv_details = f"@ (${round(convert_token_to_usdt(bounty.token_name),2)}/{bounty.token_name})"
        usdt_details = f"({bounty.value_in_usdt_now} USD {conv_details} "
    except Exception:
        pass  # no USD conversion rate

    title = bounty.title if bounty.title else bounty.github_url
    msg = f"*{event_name_in_msg}*" \
          f"\n*Issue*: {title}" \
          f"\n*Bounty value*: {round(bounty.get_natural_value(), 4)} {bounty.token_name} {usdt_details}" \
          f"\n{bounty.get_absolute_url()}"
    return msg
Exemplo n.º 2
0
 def test_humanize_event_name():
     """Test the humanized representation of an event name."""
     assert humanize_event_name('start_work') == 'WORK STARTED'
     assert humanize_event_name(
         'remarket_funded_issue') == 'REMARKET_FUNDED_ISSUE'
     assert humanize_event_name('issue_remarketed') == 'ISSUE RE-MARKETED'