Exemplo n.º 1
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.º 2
0
def is_muted(sender_id):
    try:
        return SESSION.query(GMute).all()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 3
0
def get_all_s():
    try:
        return SESSION.query(LydiaAI).all()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 4
0
def get_snips(keyword):
    try:
        return SESSION.query(Snips).get(keyword)
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 5
0
def get_all_snips():
    try:
        return SESSION.query(Snips).all()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 6
0
def is_kread():
    try:
        return SESSION.query(KRead).all()
    except BaseException:
        return None
    finally:
        SESSION.close()
Exemplo n.º 7
0
def add_welcome_setting(chat_id, custom_welcome_message, should_clean_welcome,
                        previous_welcome, media_file_id):
    # adder = SESSION.query(Welcome).get(chat_id)
    adder = Welcome(chat_id, custom_welcome_message, should_clean_welcome,
                    previous_welcome, media_file_id)
    SESSION.add(adder)
    SESSION.commit()
Exemplo n.º 8
0
def is_gbanned(chat_id):
    try:
        return SESSION.query(GBan).filter(GBan.chat_id == str(chat_id)).one()
    except BaseException:
        return None
    finally:
        SESSION.close()
Exemplo n.º 9
0
def in_channels(chat_id):
    try:
        return SESSION.query(ghdb).filter(ghdb.chat_id == str(chat_id)).one()
    except BaseException:
        return None
    finally:
        SESSION.close()
Exemplo n.º 10
0
def is_approved(chat_id):
    try:
        return SESSION.query(NOLogPMs).filter(NOLogPMs.chat_id == chat_id).one()
    except BaseException:
        return None
    finally:
        SESSION.close()
Exemplo n.º 11
0
def rm_note(chat_id, keyword):
    note = SESSION.query(Notes).filter(
        Notes.chat_id == str(chat_id), Notes.keyword == keyword
    )
    if note:
        note.delete()
        SESSION.commit()
Exemplo n.º 12
0
def is_fban(chat_id):
    try:
        return SESSION.query(FBan).filter(FBan.chat_id == str(chat_id)).one()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 13
0
def get_filter(chat_id, keyword):
    try:
        return SESSION.query(Filters).get((chat_id, keyword))
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 14
0
def get_current_welcome_settings(chat_id):
    try:
        return SESSION.query(Welcome).filter(Welcome.chat_id == chat_id).one()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 15
0
def addgvar(variable, value):
    if SESSION.query(Globals).filter(
            Globals.variable == str(variable)).one_or_none():
        delgvar(variable)
    adder = Globals(str(variable), value)
    SESSION.add(adder)
    SESSION.commit()
Exemplo n.º 16
0
def get_s(user_id, chat_id):
    try:
        return SESSION.query(LydiaAI).get((user_id, chat_id))
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 17
0
def is_muted(chat_id):
    try:
        return SESSION.query(Mute).filter(Mute.chat_id == str(chat_id)).all()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 18
0
def get_all_filters(chat_id):
    try:
        return SESSION.query(Filters).filter(Filters.chat_id == chat_id).all()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 19
0
def add_to_blacklist(chat_id, trigger):
    with BLACKLIST_FILTER_INSERTION_LOCK:
        blacklist_filt = BlackListFilters(str(chat_id), trigger)

        SESSION.merge(blacklist_filt)  # merge to avoid duplicate key issues
        SESSION.commit()
        CHAT_BLACKLISTS.setdefault(str(chat_id), set()).add(trigger)
Exemplo n.º 20
0
def gvarstatus(variable):
    try:
        return SESSION.query(Globals).filter(
            Globals.variable == str(variable)).first().value
    except BaseException:
        return None
    finally:
        SESSION.close()
Exemplo n.º 21
0
def __load_flood_settings():
    global CHAT_FLOOD
    try:
        all_chats = SESSION.query(FloodControl).all()
        CHAT_FLOOD = {chat.chat_id: (None, DEF_COUNT, chat.limit) for chat in all_chats}
    finally:
        SESSION.close()
    return CHAT_FLOOD
Exemplo n.º 22
0
def migrate_chat(old_chat_id, new_chat_id):
    with GBAN_SETTING_LOCK:
        chat = SESSION.query(GbanSettings).get(str(old_chat_id))
        if chat:
            chat.chat_id = new_chat_id
            SESSION.add(chat)

        SESSION.commit()
Exemplo n.º 23
0
def add_channel(chat_id, channel):
    adder = SESSION.query(forceSubscribe).get(chat_id)
    if adder:
        adder.channel = channel
    else:
        adder = forceSubscribe(chat_id, channel)
    SESSION.add(adder)
    SESSION.commit()
Exemplo n.º 24
0
def add_note(chat_id, keyword, reply):
    adder = SESSION.query(Notes).get((str(chat_id), keyword))
    if adder:
        adder.reply = reply
    else:
        adder = Notes(str(chat_id), keyword, reply)
    SESSION.add(adder)
    SESSION.commit()
Exemplo n.º 25
0
def remove_s(
    user_id,
    chat_id
):
    note = SESSION.query(LydiaAI).get((user_id, chat_id))
    if note:
        SESSION.delete(note)
        SESSION.commit()
Exemplo n.º 26
0
def ungban_user(user_id):
    with GBANNED_USERS_LOCK:
        user = SESSION.query(GloballyBannedUsers).get(user_id)
        if user:
            SESSION.delete(user)

        SESSION.commit()
        __load_gbanned_userid_list()
Exemplo n.º 27
0
def add_filter(chat_id, keyword, f_mesg_id):
    adder = SESSION.query(Filters).get((chat_id, keyword))
    if adder:
        adder.f_mesg_id = f_mesg_id
    else:
        adder = Filters(chat_id, keyword, f_mesg_id)
    SESSION.add(adder)
    SESSION.commit()
Exemplo n.º 28
0
def is_approved(chat_id):
    try:
        return SESSION.query(PMPermit).filter(
            PMPermit.chat_id == str(chat_id)).one()
    except:
        return None
    finally:
        SESSION.close()
Exemplo n.º 29
0
def remove_url(tg_chat_id, tg_feed_link):
    with INSERTION_LOCK:
        # this loops to delete any possible duplicates for the same TG User ID, TG Chat ID and link
        for row in check_url_availability(tg_chat_id, tg_feed_link):
            # add the action to the DB query
            SESSION.delete(row)

        SESSION.commit()
Exemplo n.º 30
0
def add_snip(keyword, f_mesg_id):
    adder = SESSION.query(Snips).get(keyword)
    if adder:
        adder.f_mesg_id = f_mesg_id
    else:
        adder = Snips(keyword, f_mesg_id)
    SESSION.add(adder)
    SESSION.commit()