import copy
import re


def change_cmd(evt, new_cmd):
    """Takes an event and returns an event with the same metadata but a
    different command."""
    event = copy.copy(evt)
    event.cmd = new_cmd

    old_cmd = '{0}{1}'.format(event.source_bot.command_token, evt.cmd)
    new_cmd = '{0}{1}'.format(event.source_bot.command_token, new_cmd)
    event.meta['body'] = re.sub('^{0}'.format(old_cmd),
                                new_cmd,
                                evt.meta['body'])
    return event