def fs_settings(chat_id): try: return (SESSION.query(forceSubscribe).filter( forceSubscribe.chat_id == chat_id).one()) except: return None finally: SESSION.close()
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()
def gvarstatus(variable): try: return (SESSION.query(Globals).filter( Globals.variable == str(variable)).first().value) except BaseException: return None finally: SESSION.close()
def get_current_welcome_settings(chat_id): try: return SESSION.query(Welcome).filter( Welcome.chat_id == str(chat_id)).one() except BaseException: return None finally: SESSION.close()
def getcurrent_wafu_settings(chat_id): try: return (SESSION.query(Joinwafu).filter( Joinwafu.chat_id == str(chat_id)).one()) except BaseException: return None finally: SESSION.close()
def rm_note(chat_id, keyword): to_check = get_note(chat_id, keyword) if not to_check: return False else: rem = SESSION.query(Notes).get((str(chat_id), keyword)) SESSION.delete(rem) SESSION.commit() return True
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()
def add_snip(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference): adder = SESSION.query(Snips).get(keyword) if adder: adder.reply = reply adder.snip_type = snip_type adder.media_id = media_id adder.media_access_hash = media_access_hash adder.media_file_reference = media_file_reference else: adder = Snips(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference) SESSION.add(adder) SESSION.commit()