import requests


def get_latest_message(group, token):
    """Gets the most recent message from a group. Token must be valid for the group."""

    GROUP_URI = 'https://api.groupme.com/v3/groups/' + str(group)
    r = requests.get(GROUP_URI + '/messages?token=' + token + '&limit=1')
    return r.json()['response']['messages'][0]