Пример #1
0
def process_open_account(author: AccountId, message: str, server: Server, prefix='', platform_name='Reddit', **kwargs):
    """Processes a message that tries to open a new account."""
    if server.has_account(author):
        return 'Hi there %s. Looks like you already have an account. No need to open another one.' % author.readable()

    server.open_account(author)
    return 'Hi there %s. Your account has been opened successfully. Thank you for your business. %s' % (author.readable(), get_generic_help_message(author, prefix, platform_name))
Пример #2
0
def open_account(author: Union[AccountId, str], account: Union[AccountId, str],
                 server: Server):
    """Open account through authorization of author on server.
    Author can be the same account as account"""
    if server.has_account(account):
        raise ValueCommandException(account)
    if server.has_account(author):
        _assert_authorized(_get_account(author, server), None)
    server.open_account(account)
Пример #3
0
def process_admin_open_account(author: AccountId, message: str, server: Server, **kwargs):
    """Processes a message that tries to open a new account."""
    assert_authorized(author, server, Authorization.ADMIN)
    account_name = parse_account_name_command(message)
    if server.has_account(account_name):
        raise CommandException('Account `%s` already exists.' % account_name)

    server.open_account(account_name)
    return 'Account `%s` has been opened successfully.' % account_name