import json
import re


def uri_twitch(bot, response, matches):
    """ Extract Twitch.tv channel information. """
    channel = json.loads(response.text)

    title = channel['status'].replace('\n', ' ')
    title = re.sub(r'\s+', ' ', title).strip()
    game = channel['game'].replace('\n', ' ')
    game = re.sub(r'\s+', ' ', game).strip()

    return 'Twitch: {}'.format(channel['display_name']), title, game