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 update_link(website, link): adder = SESSION.query(database).get(website) if adder: adder.link = link else: adder = database(website, link) SESSION.add(adder) SESSION.commit()
def set_flood(chat_id, amount): with INSERTION_LOCK: flood = SESSION.query(FloodControl).get(str(chat_id)) if not flood: flood = FloodControl(str(chat_id)) flood.user_id = None flood.limit = amount CHAT_FLOOD[str(chat_id)] = (None, DEF_COUNT, amount) SESSION.add(flood) SESSION.commit()
def add_snip(keyword, reply, f_mesg_id): to_check = get_snips(keyword) if not to_check: adder = Note(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return True rem = SESSION.query(Note).get(keyword) SESSION.delete(rem) SESSION.commit() adder = Note(keyword, reply, f_mesg_id) SESSION.add(adder) SESSION.commit() return False
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()
def mute(sender, chat_id): adder = Mute(str(sender), str(chat_id)) SESSION.add(adder) SESSION.commit()
def approve(chat_id, reason): adder = PMPermit(str(chat_id), str(reason)) SESSION.add(adder) SESSION.commit()
def addecho(user_id, chat_id): adder = ECHOSQL(str(user_id), str(chat_id)) SESSION.add(adder) SESSION.commit()
def gmute(sender): adder = GMute(str(sender)) SESSION.add(adder) SESSION.commit()