Exemple #1
0
def check_group_status(group_id):
    is_valid = False
    database_name = "user_list"
    status = db_op.get_from_database("group_num", group_id, "status", database_name, "QQ_GROUP")
    all_user_mode = db_op.get_from_database("group_num", group_id, "all_user", database_name, "QQ_GROUP")
    if (status == '1'):
        is_valid = True
    return is_valid, all_user_mode
Exemple #2
0
def check_gourp_in_all_mode(requested_qq_group_num):
    # get user group from requested_qq_num in user_list.db
    all_mode_status = db_op.get_from_database("group_num", str(requested_qq_group_num), "all_user", "user_list", "QQ_GROUP")
    
    if (all_mode_status == "1"):
        return True
    return False
Exemple #3
0
def check_user_status(user_id):
    is_valid = False
    database_name = "user_list"
    status = db_op.get_from_database("qq_num", user_id, "status", database_name, "USERS")
    if (status == '1'):
        is_valid = True
    return is_valid
Exemple #4
0
 def inactive_all_user_mode(requested_qq_num, group_id):
     if (check_usergourp_is_fit(requested_qq_num, command_level_core.command_level) == True):
         result = db_op.get_from_database("group_num", group_id, "group_num", "user_list", "QQ_GROUP")
         if (result == None):
             return ".群组不存在"
         else:
             if db_op.set_value_to_database("group_num", group_id, "all_user", "0", "user_list", "QQ_GROUP"):
                 print(".已冻结群组:" + group_id + "的全员模式")
                 return ".已冻结群组:" + group_id + "的全员模式"
             else:
                 return ".冻结失败"
Exemple #5
0
 def active_group(requested_qq_num, group_id):
     if (check_usergourp_is_fit(requested_qq_num, command_level_core.command_level) == True):
         result = db_op.get_from_database("group_num", group_id, "group_num", "user_list", "QQ_GROUP")
         if (result == None):
             return ".群组不存在"
         else:
             if db_op.set_value_to_database("group_num", group_id, "status", "1", "user_list", "QQ_GROUP"):
                 print(".已激活群组:" + group_id)
                 return ".已激活群组:" + group_id
             else:
                 return ".激活失败"
Exemple #6
0
 def remove_group(requested_qq_num, group_id):
     if (check_usergourp_is_fit(requested_qq_num, command_level_core.command_level) == True):
         result = db_op.get_from_database("group_num", group_id, "group_num", "user_list", "QQ_GROUP")
         if (result == None):
             return ".群组不存在"
         else:
             if db_op.remove_from_database("QQ_GROUP", "group_num", group_id, "user_list"):
                 print(".已删除Q群" + group_id)
                 return ".已删除Q群" + group_id
             else:
                 return ".删除失败"
Exemple #7
0
 def add_group(requested_qq_num, group_id):
     if (check_usergourp_is_fit(requested_qq_num, command_level_core.command_level) == True):
         result = db_op.get_from_database("group_num", group_id, "group_num", "user_list", "QQ_GROUP")
         if (result != None):
             return ".群组已存在"
         else:
             if db_op.add_to_database("QQ_GROUP", (group_id, 1), "user_list"):
                 print(".已添加" + group_id + "添加至资料库")
                 return ".已添加" + group_id + "添加至资料库"
             else:
                 return ".添加失败"
Exemple #8
0
 def add_user(requested_qq_num, user_id, assigned_gourp="user"):
     if (check_usergourp_is_fit(requested_qq_num, command_level_core.command_level) == True):
         # do stuff
         result = db_op.get_from_database("qq_num", user_id, "qq_num", "user_list", "USERS")
         if (result != None):
             return ".用户已存在"
         else:
             if db_op.add_to_database("USERS", (user_id, assigned_gourp, str(datetime.datetime.now()), 0), "user_list"):
                 print(".id-" + user_id + "添加至资料库。权限等级:" + assigned_gourp)
                 return ".id-" + user_id + "添加至资料库。权限等级:" + assigned_gourp
             else:
                 return ".添加失败"
Exemple #9
0
def check_usergourp_is_fit(requested_qq_num, command_level):
    # get user group from requested_qq_num in user_list.db
    user_group = db_op.get_from_database("qq_num", str(requested_qq_num), "user_group", "user_list", "USERS")
    if (user_group == None):
        # 用户不存在 || 非注册用户
        # clearance = 10000
        return False
    
    is_valid = False
    if (user_group == "admin"):
        clearance = 1
    elif (user_group == "user"):
        clearance = 100
    elif (user_group == "doll"):
        clearance = 0
    
    if ((clearance <= command_level) & (clearance >= 0)):
        is_valid = True
    
    return is_valid
Exemple #10
0
def get_lastest_buffer_msg():
    database_name = "buffer"
    recive_time = db_op.search_column_get_min(database_name, "time", "temp_msg_list")
    
    # check if there is a message
    if recive_time == None:
        return None
    
    message_type = db_op.get_from_database("time", recive_time, "type", database_name, "temp_msg_list")
    send_id = db_op.get_from_database("time", recive_time, "user_id", database_name, "temp_msg_list")
    nickname = db_op.get_from_database("time", recive_time, "user_nickname", database_name, "temp_msg_list")
    group_id = db_op.get_from_database("time", recive_time, "group_id", database_name, "temp_msg_list")
    message_id = db_op.get_from_database("time", recive_time, "message_id", database_name, "temp_msg_list")
    message = db_op.get_from_database("time", recive_time, "message", database_name, "temp_msg_list")

    # delete data from buffer
    if (db_op.remove_from_database("temp_msg_list", "message_id", message_id, database_name) == False):
        print("NOT valid name")

    return (message_type, send_id, group_id, message, recive_time, message_id, nickname)