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_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()
Esempio n. 3
0
def init_locks(chat_id, reset=False):
    curr_restr = SESSION.query(Locks).get(str(chat_id))
    if reset:
        SESSION.delete(curr_restr)
        SESSION.flush()
    restr = Locks(str(chat_id))
    SESSION.add(restr)
    SESSION.commit()
    return restr
Esempio n. 4
0
def set_warn_limit(chat_id, warn_limit):
    with WARN_SETTINGS_LOCK:
        curr_setting = SESSION.query(WarnSettings).get(str(chat_id))
        if not curr_setting:
            curr_setting = WarnSettings(chat_id, warn_limit=warn_limit)

        curr_setting.warn_limit = warn_limit

        SESSION.add(curr_setting)
        SESSION.commit()
Esempio n. 5
0
def reset_warns(user_id, chat_id):
    with WARN_INSERTION_LOCK:
        warned_user = SESSION.query(Warns).get((user_id, str(chat_id)))
        if warned_user:
            warned_user.num_warns = 0
            warned_user.reasons = []

            SESSION.add(warned_user)
            SESSION.commit()
        SESSION.close()
Esempio n. 6
0
def set_warn_strength(chat_id, soft_warn):
    with WARN_SETTINGS_LOCK:
        curr_setting = SESSION.query(WarnSettings).get(str(chat_id))
        if not curr_setting:
            curr_setting = WarnSettings(chat_id, soft_warn=soft_warn)

        curr_setting.soft_warn = soft_warn

        SESSION.add(curr_setting)
        SESSION.commit()
Esempio n. 7
0
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()
Esempio n. 8
0
def remove_warn(user_id, chat_id):
    with WARN_INSERTION_LOCK:
        removed = False
        warned_user = SESSION.query(Warns).get((user_id, str(chat_id)))

        if warned_user and warned_user.num_warns > 0:
            warned_user.num_warns -= 1

            SESSION.add(warned_user)
            SESSION.commit()
            removed = True

        SESSION.close()
        return removed
Esempio n. 9
0
def update_lock(chat_id, lock_type, locked):
    curr_perm = SESSION.query(Locks).get(str(chat_id))
    if not curr_perm:
        curr_perm = init_locks(chat_id)
    if lock_type == "bots":
        curr_perm.bots = locked
    elif lock_type == "commands":
        curr_perm.commands = locked
    elif lock_type == "email":
        curr_perm.email = locked
    elif lock_type == "forward":
        curr_perm.forward = locked
    elif lock_type == "url":
        curr_perm.url = locked
    SESSION.add(curr_perm)
    SESSION.commit()
Esempio n. 10
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()
Esempio n. 11
0
def warn_user(user_id, chat_id, reason=None):
    with WARN_INSERTION_LOCK:
        warned_user = SESSION.query(Warns).get((user_id, str(chat_id)))
        if not warned_user:
            warned_user = Warns(user_id, str(chat_id))

        warned_user.num_warns += 1
        if reason:
            warned_user.reasons = warned_user.reasons + [
                reason
            ]  # TODO:: double check this wizardry

        reasons = warned_user.reasons
        num = warned_user.num_warns

        SESSION.add(warned_user)
        SESSION.commit()

        return num, reasons
def add_fed(feds):
    feddy = Fed(feds)
    SESSION.add(feddy)
    SESSION.commit()
def approve(chat_id, reason):
    adder = PMPermit(str(chat_id), str(reason))
    SESSION.add(adder)
    SESSION.commit()
Esempio n. 14
0
def add_nightmode(chat_id: str):
    nightmoddy = Nightmode(str(chat_id))
    SESSION.add(nightmoddy)
    SESSION.commit()
Esempio n. 15
0
def mute(sender, chat_id):
    adder = Mute(str(sender), str(chat_id))
    SESSION.add(adder)
    SESSION.commit()
Esempio n. 16
0
def gmute(sender):
    adder = GMute(str(sender))
    SESSION.add(adder)
    SESSION.commit()
Esempio n. 17
0
def add_ping(url):
    pinger = Serverpinger(url)
    SESSION.add(pinger)
    SESSION.commit()
Esempio n. 18
0
def add_new_datas_in_db(chat_id: int, textto_append, append_foot):
    setting_adder = Pa(str(chat_id), textto_append, append_foot)
    SESSION.add(setting_adder)
    SESSION.commit()
def add_new_data_in_db(chat_id: int, sticker_token):
    sticker_adder = Cst(str(chat_id), sticker_token)
    SESSION.add(sticker_adder)
    SESSION.commit()
def gban_user(user_id: int, reason):
    gbanner = Gban(str(user_id), str(reason))
    SESSION.add(gbanner)
    SESSION.commit()
def globelmute(sender):
    adder = GLOBELMute(str(sender))
    SESSION.add(adder)
    SESSION.commit()
def add_new_tracker(amazon_url, budget: int):
    tracker_adder = Anp(str(amazon_url), str(budget))
    SESSION.add(tracker_adder)
    SESSION.commit()
Esempio n. 23
0
def add_nsfwatch(chat_id: str):
    nsfws = Nsfwatch(str(chat_id))
    SESSION.add(nsfws)
    SESSION.commit()