def add_filter( chat_id, keyword, reply, snip_type, media_id, media_access_hash, media_file_reference, ): adder = SESSION.query(Filters).get((str(chat_id), 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 = Filters( chat_id, keyword, reply, snip_type, media_id, media_access_hash, media_file_reference, ) SESSION.add(adder) SESSION.commit()
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 set_ses(chat_id, ses_id, expires): with INSERTION_LOCK: autochat = SESSION.query(ChatbotChats).get(str(chat_id)) if not autochat: autochat = ChatbotChats(str(chat_id), str(ses_id), str(expires)) else: autochat.ses_id = str(ses_id) autochat.expires = str(expires) SESSION.add(autochat) SESSION.commit()
def set_afk(user_id, reason, start_time=""): with INSERTION_LOCK: curr = SESSION.query(AFK).get(user_id) if not curr: curr = AFK(user_id, reason, True, start_time) else: curr.is_afk = True curr.reason = reason curr.start_time = time.time() AFK_USERS[user_id] = reason AFK_USERSS[user_id] = start_time SESSION.add(curr) SESSION.commit()
def add_talkmode(chat_id: str): talkmoddy = Talkmode(str(chat_id)) SESSION.add(talkmoddy) SESSION.commit()
def add_nsfwatch(chat_id: str): nsfws = Nsfwatch(str(chat_id)) SESSION.add(nsfws) SESSION.commit()
def add_nightmode(chat_id: str): nightmoddy = Nightmode(str(chat_id)) SESSION.add(nightmoddy) SESSION.commit()