'Registers for a new account: "register <userid> <noupdate>"
<userid> : The desired user ID
<noupdate> : Do not automatically clobber config values.'

def do_register(self, line):

    args = self._parse(line, ['userid', 'noupdate'])
    password = None
    pwd = None
    pwd2 = '_'
    while (pwd != pwd2):
        pwd = getpass.getpass('Type    a    password    for    this    user:    ')
        pwd2 = getpass.getpass('Retype    the    password:    ')
        if ((pwd != pwd2) or (len(pwd) == 0)):
            print 'Password    mismatch.'
            pwd = None
        else:
            password = pwd
    body = {'type': 'm.login.password'}
    if ('userid' in args):
        body['user'] = args['userid']
    if password:
        body['password'] = password
    reactor.callFromThread(self._do_register, body, ('noupdate' not in args))
