示例#1
0
文件: app.py 项目: s-mcqueen/DL-text
def process_authorized(body, number):
    # we know the phone number is someone we know
    user_name = mongo_handler.get_user_name(number)
    user_privileges = mongo_handler.get_privileges(number)

    # if the text message is valid
    if parse.valid_text(body):
        list_name = parse.get_list_name(body)

        # if user is allowed to text this list
        if list_name in user_privileges:
            raw_message = parse.get_message_body(body)
            message_body = user_name + ": " + raw_message
            numbers_list = mongo_handler.get_phone_numbers(list_name)
            
            # send text!
            send_sms_to_list(message_body, numbers_list, list_name, user_name)

        # user is not allowed to text this list
        else:
            # if list exists, then user isn't authorized to text it 
            if list_exists(list_name):
                handle_bad_privileges(number)
            else:
                handle_bad_list_name(number)
    
    # text message is not valid
    else:
        handle_bad_text(number)
示例#2
0
文件: app.py 项目: s-mcqueen/DL-text
def process_unauthorized(body, number):
    if parse.valid_text(body):
        handle_bad_privileges(number)
    else:
        handle_other(number)