Exemplo n.º 1
0
def get_chat_filters(chat_id):
    try:
        return (SESSION.query(CustomFilters).filter(
            CustomFilters.chat_id == str(chat_id)).order_by(
                func.length(CustomFilters.keyword).desc()).order_by(
                    CustomFilters.keyword.asc()).all())
    finally:
        SESSION.close()
Exemplo n.º 2
0
def chat_antiarabic(chat_id: Union[str, int]) -> bool:
    try:
        chat_setting = SESSION.query(AntiArabicChatSettings).get(str(chat_id))
        if chat_setting:
            return chat_setting.antiarabic
        return False
    finally:
        SESSION.close()
Exemplo n.º 3
0
def is_chat(chat_id):
    try:
        chat = SESSION.query(aiChats).get(str(chat_id))
        if chat:
            return True
        return False
    finally:
        SESSION.close()
Exemplo n.º 4
0
def get_clean_pref(chat_id):
    welc = SESSION.query(Welcome).get(str(chat_id))
    SESSION.close()

    if welc:
        return welc.clean_welcome

    return False
Exemplo n.º 5
0
def get_user(user_id):
    user = SESSION.query(LastFMUsers).get(str(user_id))
    rep = ""
    if user:
        rep = str(user.username)

    SESSION.close()
    return rep
Exemplo n.º 6
0
def allow_connect_to_chat(chat_id: Union[str, int]) -> bool:
    try:
        chat_setting = SESSION.query(ChatAccessConnectionSettings).get(str(chat_id))
        if chat_setting:
            return chat_setting.allow_connect_to_chat
        return False
    finally:
        SESSION.close()
Exemplo n.º 7
0
def get_custom_welcome(chat_id):
    welcome_settings = SESSION.query(Welcome).get(str(chat_id))
    ret = DEFAULT_WELCOME
    if welcome_settings and welcome_settings.custom_welcome:
        ret = welcome_settings.custom_welcome

    SESSION.close()
    return ret
Exemplo n.º 8
0
def get_custom_gdbye(chat_id):
    welcome_settings = SESSION.query(Welcome).get(str(chat_id))
    ret = DEFAULT_GOODBYE
    if welcome_settings and welcome_settings.custom_leave:
        ret = welcome_settings.custom_leave

    SESSION.close()
    return ret
Exemplo n.º 9
0
def __load_all_feds_settings():
    global FEDERATION_NOTIFICATION
    try:
        getuser = SESSION.query(FedsUserSettings).all()
        for x in getuser:
            FEDERATION_NOTIFICATION[str(x.user_id)] = x.should_report
    finally:
        SESSION.close()
Exemplo n.º 10
0
def user_should_report(user_id: int) -> bool:
    try:
        user_setting = SESSION.query(ReportingUserSettings).get(user_id)
        if user_setting:
            return user_setting.should_report
        return True
    finally:
        SESSION.close()
Exemplo n.º 11
0
def welcome_mutes(chat_id):
    try:
        welcomemutes = SESSION.query(WelcomeMute).get(str(chat_id))
        if welcomemutes:
            return welcomemutes.welcomemutes
        return False
    finally:
        SESSION.close()
Exemplo n.º 12
0
def clean_service(chat_id: Union[str, int]) -> bool:
    try:
        chat_setting = SESSION.query(CleanServiceSetting).get(str(chat_id))
        if chat_setting:
            return chat_setting.clean_service
        return False
    finally:
        SESSION.close()
Exemplo n.º 13
0
def fs_settings(chat_id):
    try:
        return (SESSION.query(forceSubscribe).filter(
            forceSubscribe.chat_id == chat_id).one())
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 14
0
def get_welc_mutes_pref(chat_id):
    welcomemutes = SESSION.query(WelcomeMute).get(str(chat_id))
    SESSION.close()

    if welcomemutes:
        return welcomemutes.welcomemutes

    return False
Exemplo n.º 15
0
def chat_should_report(chat_id: Union[str, int]) -> bool:
    try:
        chat_setting = SESSION.query(ReportingChatSettings).get(str(chat_id))
        if chat_setting:
            return chat_setting.should_report
        return False
    finally:
        SESSION.close()
Exemplo n.º 16
0
def get_gdbye_pref(chat_id):
    welc = SESSION.query(Welcome).get(str(chat_id))
    SESSION.close()
    if welc:
        return welc.should_goodbye, welc.custom_leave, welc.leave_type
    else:
        # Welcome by default.
        return True, DEFAULT_GOODBYE, Types.TEXT
Exemplo n.º 17
0
def get_reason(user_id):
    user = SESSION.query(BlacklistUsers).get(str(user_id))
    rep = ""
    if user:
        rep = user.reason

    SESSION.close()
    return rep
Exemplo n.º 18
0
def get_rules(chat_id):
    rules = SESSION.query(Rules).get(str(chat_id))
    ret = ""
    if rules:
        ret = rules.rules

    SESSION.close()
    return ret
Exemplo n.º 19
0
def rem_chat(chat_id):
    with INSERTION_LOCK:
        chat = SESSION.query(Chats).get(str(chat_id))
        if chat:
            SESSION.delete(chat)
            SESSION.commit()
        else:
            SESSION.close()
Exemplo n.º 20
0
def get_flood_setting(chat_id):
    try:
        setting = SESSION.query(FloodSettings).get(str(chat_id))
        if setting:
            return setting.flood_type, setting.value
        return 1, "0"

    finally:
        SESSION.close()
Exemplo n.º 21
0
def get_blacklist_setting(chat_id):
    try:
        setting = CHAT_SETTINGS_BLACKLISTS.get(str(chat_id))
        if setting:
            return setting["blacklist_type"], setting["value"]
        return 1, "0"

    finally:
        SESSION.close()
Exemplo n.º 22
0
def num_stickers_chat_filters(chat_id):
    try:
        return (
            SESSION.query(StickersFilters.chat_id)
            .filter(StickersFilters.chat_id == str(chat_id))
            .count()
        )
    finally:
        SESSION.close()
Exemplo n.º 23
0
def __load_gban_stat_list():
    global GBANSTAT_LIST
    try:
        GBANSTAT_LIST = {
            x.chat_id
            for x in SESSION.query(GbanSettings).all() if not x.setting
        }
    finally:
        SESSION.close()
Exemplo n.º 24
0
def __load_gbanned_userid_list():
    global GBANNED_LIST
    try:
        GBANNED_LIST = {
            x.user_id
            for x in SESSION.query(GloballyBannedUsers).all()
        }
    finally:
        SESSION.close()
Exemplo n.º 25
0
def disconnect(user_id):
    with CONNECTION_INSERTION_LOCK:
        disconnect = SESSION.query(Connection).get((int(user_id)))
        if disconnect:
            SESSION.delete(disconnect)
            SESSION.commit()
            return True
        SESSION.close()
        return False
Exemplo n.º 26
0
def is_enabled(chat_id):
    try:
        resultcurr = SESSION.query(CleanerBlueTextChatSettings).get(
            str(chat_id))
        if resultcurr:
            return resultcurr.is_enable
        return False  # default
    finally:
        SESSION.close()
Exemplo n.º 27
0
def get_welc_pref(chat_id):
    welc = SESSION.query(Welcome).get(str(chat_id))
    SESSION.close()
    if welc:
        return welc.should_welcome, welc.custom_welcome, welc.custom_content, welc.welcome_type

    else:
        # Welcome by default.
        return True, DEFAULT_WELCOME, None, Types.TEXT
Exemplo n.º 28
0
def get_note(chat_id, note_name):
    try:
        return (
            SESSION.query(Notes)
            .filter(func.lower(Notes.name) == note_name, Notes.chat_id == str(chat_id))
            .first()
        )
    finally:
        SESSION.close()
Exemplo n.º 29
0
def get_human_checks(user_id, chat_id):
    try:
        human_check = SESSION.query(WelcomeMuteUsers).get((user_id, str(chat_id)))
        if not human_check:
            return None
        human_check = human_check.human_check
        return human_check
    finally:
        SESSION.close()
Exemplo n.º 30
0
def disapprove(chat_id, user_id):
    with APPROVE_INSERTION_LOCK:
        disapprove_user = SESSION.query(Approvals).get((str(chat_id), user_id))
        if disapprove_user:
            SESSION.delete(disapprove_user)
            SESSION.commit()
            return True
        SESSION.close()
        return False