示例#1
0
def add_url(tg_chat_id, tg_feed_link, tg_old_entry_link):
    with INSERTION_LOCK:
        action = RSS(tg_chat_id, tg_feed_link, tg_old_entry_link)

        SESSION.add(action)
        SESSION.commit()
示例#2
0
def get_restr(chat_id):
    try:
        return SESSION.query(Restrictions).get(str(chat_id))
    finally:
        SESSION.close()
示例#3
0
def get_gmute_list():
    try:
        return [x.to_dict() for x in SESSION.query(GloballyMutedUsers).all()]
    finally:
        SESSION.close()
示例#4
0
def add_note_button_to_db(chat_id, note_name, b_name, url, same_line):
    with BUTTONS_INSERTION_LOCK:
        button = Buttons(chat_id, note_name, b_name, url, same_line)
        SESSION.add(button)
        SESSION.commit()
示例#5
0
def num_chats():
    try:
        return SESSION.query(func.count(distinct(Notes.chat_id))).scalar()
    finally:
        SESSION.close()
示例#6
0
def get_connected_chat(user_id):
    try:
        return SESSION.query(Connection).get((int(user_id)))
    finally:
        SESSION.close()
示例#7
0
def get_history(user_id):
    try:
        return SESSION.query(ConnectionHistory).get(str(user_id))
    finally:
        SESSION.close()
示例#8
0
def num_blacklist_filters():
    try:
        return SESSION.query(BlackListFilters).count()
    finally:
        SESSION.close()
示例#9
0
def num_blacklist_chat_filters(chat_id):
    try:
        return SESSION.query(BlackListFilters.chat_id).filter(
            BlackListFilters.chat_id == str(chat_id)).count()
    finally:
        SESSION.close()
示例#10
0
def num_filters():
    try:
        return SESSION.query(CustomFilters).count()
    finally:
        SESSION.close()
示例#11
0
def get_all_filters():
    try:
        return SESSION.query(CustomFilters).all()
    finally:
        SESSION.close()
示例#12
0
def get_filter(chat_id, keyword):
    try:
        return SESSION.query(CustomFilters).get((str(chat_id), keyword))
    finally:
        SESSION.close()
示例#13
0
def get_all():
    try:
        return SESSION.query(RSS).all()
    finally:
        SESSION.close()
示例#14
0
def get_urls(tg_chat_id):
    try:
        return SESSION.query(RSS).filter(RSS.chat_id == tg_chat_id).all()
    finally:
        SESSION.close()
示例#15
0
def get_user_bio(user_id):
    userbio = SESSION.query(UserBio).get(user_id)
    SESSION.close()
    if userbio:
        return userbio.bio
    return None
示例#16
0
def num_blacklist_filter_chats():
    try:
        return SESSION.query(func.count(distinct(
            BlackListFilters.chat_id))).scalar()
    finally:
        SESSION.close()
示例#17
0
def num_disabled():
    try:
        return SESSION.query(Disable).count()
    finally:
        SESSION.close()
示例#18
0
def num_logchannels():
    try:
        return SESSION.query(func.count(distinct(GroupLogs.chat_id))).scalar()
    finally:
        SESSION.close()
示例#19
0
def curr_connection(chat_id):
    try:
        return SESSION.query(Connection).get((str(chat_id)))
    finally:
        SESSION.close()
示例#20
0
def prev_locale(chat_id):
    try:
        return SESSION.query(Locales).get((str(chat_id)))
    finally:
        SESSION.close()
示例#21
0
def get_all_chat_notes(chat_id):
    try:
        return SESSION.query(Notes).filter(
            Notes.chat_id == str(chat_id)).order_by(Notes.name.asc()).all()
    finally:
        SESSION.close()
示例#22
0
def approve(chat_id, user_id):
    with APPROVE_INSERTION_LOCK:
        approve_user = Approvals(str(chat_id), user_id)
        SESSION.add(approve_user)
        SESSION.commit()
示例#23
0
def num_notes():
    try:
        return SESSION.query(Notes).count()
    finally:
        SESSION.close()
示例#24
0
def is_approved(chat_id, user_id):
    try:
        return SESSION.query(Approvals).get((str(chat_id), user_id))
    finally:
        SESSION.close()
示例#25
0
def get_locks(chat_id):
    try:
        return SESSION.query(Permissions).get(str(chat_id))
    finally:
        SESSION.close()
示例#26
0
def check_afk_status(user_id):
    try:
        return SESSION.query(AFK).get(user_id)
    finally:
        SESSION.close()
示例#27
0
def get_gmuted_user(user_id):
    try:
        return SESSION.query(GloballyMutedUsers).get(user_id)
    finally:
        SESSION.close()
示例#28
0
def get_user_me_info(user_id):
    userinfo = SESSION.query(UserInfo).get(user_id)
    SESSION.close()
    if userinfo:
        return userinfo.info
    return None
示例#29
0
def del_fed(fed_id, chat_id):
    with FEDS_LOCK:
        curr = SESSION.query(Federations).get(fed_id)
        print(curr)
        if curr:
            SESSION.delete(curr)
            SESSION.commit()

        curr = SESSION.query(ChatF).get(str(chat_id))
        if curr:
            SESSION.delete(curr)
            SESSION.commit()

        curr = SESSION.query(UserF).all()
        for I in curr:
            if I.fed_id == fed_id:
                SESSION.delete(I)
                SESSION.commit()

        curr = SESSION.query(RulesF).get(fed_id)
        if curr:
            SESSION.delete(curr)
            SESSION.commit()

        return
示例#30
0
def check_url_availability(tg_chat_id, tg_feed_link):
    try:
        return SESSION.query(RSS).filter(RSS.feed_link == tg_feed_link,
                                         RSS.chat_id == tg_chat_id).all()
    finally:
        SESSION.close()