Exemplo n.º 1
0
def nick(nickname):
    """
    Builds a NICK command used to give or change a user's nickname.
    
    args:
        nickname: A spaceless string representing the user's desired nickname.
        
    returns:
        An unencoded string representing the NICK command.
    """
    
    return utils.ircjoin(constants.NICK, nickname)
Exemplo n.º 2
0
def oper(username, password):
    """
    Builds an OPER command used to obtain server operator privileges.
    
    args:
        username: A spaceless string representing the username to register with.
        password: A spaceless string representing the password to register with.
        
    returns:
        An unencoded string representing the OPER command.
    """
    
    return utils.ircjoin(constants.OPER, username, password)
Exemplo n.º 3
0
def pass_(password):
    """
    Builds a PASS command used to set a connection password. The optional password can and
    must be set before any attempt to register the connection is made (i.e., before
    sending a NICK/USER combination).
    
    args:
        password: A spaceless string representing the connection password.
        
    returns:
        An unencoded string representing the PASS command.
    """
    
    return utils.ircjoin(constants.PASS, password)
Exemplo n.º 4
0
def user(username, name=None, mode=0, unused='*'):
    """
    Builds a USER command used at the beginning of a connection to specify the username,
    mode, and real name of a new user.
    
    args:
        user: A spaceless string representing the user's username.
        name: A string representing the user's real name. This optional parameter may
              contain spaces. If this parameter is None, it will be the same as the `user`
              parameter.
        mode: An integer, or string representing an integer, used to specify the user mode
              set when registering with the server. This optional parameter defaults to 0
              to signify no user mode.
        unused: This field is unused in the IRC specification and is included for
                completeness.
    
    returns:
        An unencoded string representing the USER command.
    """
    
    if name is None:
        name = username
    
    return utils.ircjoin(constants.USER, username, mode, unused, spaced=name)