Ejemplo n.º 1
0
def gban(sender):
    try:
        adder = GBan(str(sender))
        SESSION.add(adder)
        SESSION.commit()
    except:
        return False
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
def add_user_to_db(message_id, first_name, chat_id, reply_id, logger_id,
                   result_id):
    user = Bot_Users(message_id, first_name, str(chat_id), reply_id, logger_id,
                     result_id)
    SESSION.add(user)
    SESSION.commit()
    return True
Ejemplo n.º 4
0
def addgvar(variable, value):
    if SESSION.query(Globals).filter(
            Globals.variable == str(variable)).one_or_none():
        delgvar(variable)
    adder = Globals(str(variable), value)
    SESSION.add(adder)
    SESSION.commit()
Ejemplo n.º 5
0
def approve(chat_id):

    adder = PMPermit(str(chat_id))

    SESSION.add(adder)

    SESSION.commit()
Ejemplo n.º 6
0
def set_tede(chat_id):
    with INSERTION_LOCK:
        tedechat = SESSION.query(TedeChatBot).get(str(chat_id))
        if not tedechat:
            tedechat = TedeChatBot(str(chat_id))
        SESSION.add(tedechat)
        SESSION.commit()
Ejemplo n.º 7
0
def gmute(sender):

    adder = GMute(str(sender))

    SESSION.add(adder)

    SESSION.commit()
Ejemplo n.º 8
0
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()
Ejemplo n.º 9
0
def add_welcome_setting(chat_id, custom_welcome_message, should_clean_welcome, previous_welcome,media_file_id=None):
    try:
        adder = Welcome(chat_id, custom_welcome_message, should_clean_welcome, previous_welcome, media_file_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    except:
        return False
Ejemplo n.º 10
0
def add_welcome_setting(chat_id, previous_welcome, f_mesg_id):
    try:
        adder = Welcome(chat_id, previous_welcome, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    except BaseException:
        return False
Ejemplo n.º 11
0
def add_collection(keywoard, json, njson):
    to_check = get_collection(keywoard)
    if not to_check:
        keyword_items = Petercord_GlobalCollection_Json(keywoard, json, njson)
        SESSION.add(keyword_items)
        SESSION.commit()
        return True
    return False
Ejemplo n.º 12
0
def add_s(user_id, chat_id, session_id, session_expires):
    adder = SESSION.query(LydiaAI).get((user_id, chat_id))
    if adder:
        adder.session_id = session_id
        adder.session_expires = session_expires
    else:
        adder = LydiaAI(user_id, chat_id, session_id, session_expires)
    SESSION.add(adder)
    SESSION.commit()
def add_collection(keywoard, json, njson={}):
    to_check = get_collection(keywoard)
    if to_check:
        keyword_items = SESSION.query(Cat_GlobalCollection_Json).get(keywoard)
        SESSION.delete(keyword_items)
    keyword_items = Cat_GlobalCollection_Json(keywoard, json, njson)
    SESSION.add(keyword_items)
    SESSION.commit()
    return True
Ejemplo n.º 14
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
Ejemplo n.º 15
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()
Ejemplo n.º 16
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()
Ejemplo n.º 17
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()
Ejemplo n.º 18
0
def save_credentials(user, credentials):
    saved_credentials = SESSION.query(GoogleDriveCreds).get(user)
    if not saved_credentials:
        saved_credentials = GoogleDriveCreds(user)

    saved_credentials.credentials = credentials

    SESSION.add(saved_credentials)
    SESSION.commit()
    return True
Ejemplo n.º 19
0
def add_rkwelcome_setting(chat_id, should_clean_rkwelcome, previous_rkwelcome,
                          f_mesg_id):
    adder = SESSION.query(rkwelcome).get(chat_id)
    if adder:
        adder.should_clean_rkwelcome = should_clean_rkwelcome
        adder.previous_rkwelcome = previous_rkwelcome
        adder.f_mesg_id = f_mesg_id
    else:
        adder = rkwelcome(chat_id, should_clean_rkwelcome, previous_rkwelcome,
                          f_mesg_id)
    SESSION.add(adder)
    SESSION.commit()
Ejemplo n.º 20
0
def add_welcome_setting(chat_id, previous_welcome, reply, f_mesg_id):
    to_check = get_welcome(chat_id)
    if not to_check:
        adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    rem = SESSION.query(Welcome).get(str(chat_id))
    SESSION.delete(rem)
    SESSION.commit()
    adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id)
    SESSION.commit()
    return False
Ejemplo n.º 21
0
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()
Ejemplo n.º 22
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
Ejemplo n.º 23
0
def add_goodbye_setting(chat_id, previous_goodbye, reply, f_mesg_id):
    to_check = get_goodbye(chat_id)
    if not to_check:
        adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    else:
        rem = SESSION.query(Goodbye).get(str(chat_id))
        SESSION.delete(rem)
        SESSION.commit()
        adder = Goodbye(chat_id, previous_goodbye, reply, f_mesg_id)
        SESSION.commit()
        return False
Ejemplo n.º 24
0
def add_snip(keyword, reply, f_mesg_id):
    to_check = get_snip(keyword)
    if not to_check:
        adder = Snips(keyword, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    rem = SESSION.query(Snips).filter(Snips.snip == keyword)
    SESSION.delete(rem)
    SESSION.commit()
    adder = Snips(keyword, reply, f_mesg_id)
    SESSION.add(adder)
    SESSION.commit()
    return False
Ejemplo n.º 25
0
def add_filter(chat_id, keyword, reply, f_mesg_id):
    to_check = get_filter(chat_id, keyword)
    if not to_check:
        adder = Filter(str(chat_id), keyword, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    rem = SESSION.query(Filter).get((str(chat_id), keyword))
    SESSION.delete(rem)
    SESSION.commit()
    adder = Filter(str(chat_id), keyword, reply, f_mesg_id)
    SESSION.add(adder)
    SESSION.commit()
    return False
Ejemplo n.º 26
0
def add_note(keyword, reply, f_mesg_id):
    to_check = get_note(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
Ejemplo n.º 27
0
def add_snip(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference):
    to_check = get_snip(keyword)
    if not to_check:
        adder = Snips(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference)
        SESSION.add(adder)
        SESSION.commit()
        return True
    else:
        rem = SESSION.query(Snips).filter(Snips.snip == keyword)
        SESSION.delete(rem)
        SESSION.commit()
        adder = Snips(keyword, reply, snip_type, media_id, media_access_hash, media_file_reference)
        SESSION.add(adder)
        SESSION.commit()
        return False
Ejemplo n.º 28
0
def add_note(chat_id, keyword, reply, f_mesg_id):
    to_check = get_note(chat_id, keyword)
    if not to_check:
        adder = Notes(str(chat_id), keyword, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return True
    else:
        rem = SESSION.query(Notes).get((str(chat_id), keyword))
        SESSION.delete(rem)
        SESSION.commit()
        adder = Notes(str(chat_id), keyword, reply, f_mesg_id)
        SESSION.add(adder)
        SESSION.commit()
        return False
Ejemplo n.º 29
0
def addecho(chat_id, user_id, chat_name, user_name, user_username, chat_type):
    to_check = is_echo(chat_id, user_id)
    if not to_check:
        adder = Echos(str(chat_id), str(user_id), chat_name, user_name,
                      user_username, chat_type)
        SESSION.add(adder)
        SESSION.commit()
        return True
    rem = SESSION.query(Echos).get((str(chat_id), str(user_id)))
    SESSION.delete(rem)
    SESSION.commit()
    adder = Echos(str(chat_id), str(user_id), chat_name, user_name,
                  user_username, chat_type)
    SESSION.add(adder)
    SESSION.commit()
    return False
Ejemplo n.º 30
0
def add_user_to_bl(chat_id: int, first_name: str, username: str, reason: str,
                   date: str):
    """add the user to the blacklist"""
    to_check = check_is_black_list(chat_id)
    if not to_check:
        __user = Bot_BlackList(str(chat_id), first_name, username, reason,
                               date)
        SESSION.add(__user)
        SESSION.commit()
    rem = SESSION.query(Bot_BlackList).get(str(chat_id))
    SESSION.delete(rem)
    SESSION.commit()
    user = Bot_BlackList(str(chat_id), first_name, username, reason, date)
    SESSION.add(user)
    SESSION.commit()
    return True