コード例 #1
0
ファイル: antispam_sql.py プロジェクト: sekret666/Rose
def update_gban_reason(user_id, name, reason=None):
    with GBANNED_USERS_LOCK:
        user = SESSION.query(GloballyBannedUsers).get(user_id)
        if not user:
            return None
        old_reason = user.reason
        user.name = name
        user.reason = reason

        SESSION.merge(user)
        SESSION.commit()
        return old_reason
コード例 #2
0
ファイル: antispam_sql.py プロジェクト: sekret666/Rose
def gban_user(user_id, name, reason=None):
    with GBANNED_USERS_LOCK:
        user = SESSION.query(GloballyBannedUsers).get(user_id)
        if not user:
            user = GloballyBannedUsers(user_id, name, reason)
        else:
            user.name = name
            user.reason = reason

        SESSION.merge(user)
        SESSION.commit()
        __load_gbanned_userid_list()
コード例 #3
0
ファイル: feds_sql.py プロジェクト: sekret666/Rose
def set_frules(fed_id, rules):
    with FEDS_LOCK:
        global FEDERATION_BYOWNER, FEDERATION_BYFEDID, FEDERATION_BYNAME
        # Variables
        getfed = FEDERATION_BYFEDID.get(str(fed_id))
        owner_id = getfed['owner']
        fed_name = getfed['fname']
        fed_members = getfed['fusers']
        fed_rules = str(rules)
        # Set user
        FEDERATION_BYOWNER[str(owner_id)]['frules'] = fed_rules
        FEDERATION_BYFEDID[str(fed_id)]['frules'] = fed_rules
        FEDERATION_BYNAME[fed_name]['frules'] = fed_rules
        # Set on database
        fed = Federations(str(owner_id), fed_name, str(fed_id), fed_rules,
                          str(fed_members))
        SESSION.merge(fed)
        SESSION.commit()
        return True
コード例 #4
0
ファイル: feds_sql.py プロジェクト: sekret666/Rose
def user_demote_fed(fed_id, user_id):
    with FEDS_LOCK:
        global FEDERATION_BYOWNER, FEDERATION_BYFEDID, FEDERATION_BYNAME
        # Variables
        getfed = FEDERATION_BYFEDID.get(str(fed_id))
        owner_id = getfed['owner']
        fed_name = getfed['fname']
        fed_rules = getfed['frules']
        # Temp set
        try:
            members = eval(eval(getfed['fusers'])['members'])
        except ValueError:
            return False
        members.remove(user_id)
        # Set user
        FEDERATION_BYOWNER[str(owner_id)]['fusers'] = str({
            'owner':
            str(owner_id),
            'members':
            str(members)
        })
        FEDERATION_BYFEDID[str(fed_id)]['fusers'] = str({
            'owner': str(owner_id),
            'members': str(members)
        })
        FEDERATION_BYNAME[fed_name]['fusers'] = str({
            'owner': str(owner_id),
            'members': str(members)
        })
        # Set on database
        fed = Federations(
            str(owner_id), fed_name, str(fed_id), fed_rules,
            str({
                'owner': str(owner_id),
                'members': str(members)
            }))
        SESSION.merge(fed)
        SESSION.commit()
        return True
コード例 #5
0
ファイル: feds_sql.py プロジェクト: sekret666/Rose
def user_join_fed(fed_id, user_id):
    with FEDS_LOCK:
        global FEDERATION_BYOWNER, FEDERATION_BYFEDID, FEDERATION_BYNAME
        # Variables
        getfed = FEDERATION_BYFEDID.get(str(fed_id))
        owner_id = getfed['owner']
        fed_name = getfed['fname']
        fed_rules = getfed['frules']
        # Temp set
        members = eval(eval(getfed['fusers'])['members'])
        members.append(user_id)
        # Set user
        FEDERATION_BYOWNER[str(owner_id)]['fusers'] = str({
            'owner':
            str(owner_id),
            'members':
            str(members)
        })
        FEDERATION_BYFEDID[str(fed_id)]['fusers'] = str({
            'owner': str(owner_id),
            'members': str(members)
        })
        FEDERATION_BYNAME[fed_name]['fusers'] = str({
            'owner': str(owner_id),
            'members': str(members)
        })
        # Set on database
        fed = Federations(
            str(owner_id), fed_name, str(fed_id), fed_rules,
            str({
                'owner': str(owner_id),
                'members': str(members)
            }))
        SESSION.merge(fed)
        SESSION.commit()
        __load_all_feds_chats()
        return True
コード例 #6
0
ファイル: users_sql.py プロジェクト: sekret666/Rose
def ensure_bot_in_db():
    with INSERTION_LOCK:
        bot = Users(dispatcher.bot.id, dispatcher.bot.username)
        SESSION.merge(bot)
        SESSION.commit()