Esempio n. 1
0
def addDevUser(user_id):
    addUser = SESSION.query(DevUser).filter(DevUser.user_id == user_id).first()
    if addUser:
        raise Exception("The user already added as Dev.")
    else:
        addUser = DevUser(None, user_id)
        SESSION.add(addUser)
        SESSION.commit()
Esempio n. 2
0
def addMuteUser(chat_id, first_name, user_id):
    addUser = (SESSION.query(MutePersonal).filter(
        MutePersonal.chat_id == chat_id).filter(
            MutePersonal.user_id == user_id).first())
    if addUser:
        raise Exception("The user already muted.")
    else:
        addUser = MutePersonal(None, chat_id, first_name, user_id)
        SESSION.add(addUser)
        SESSION.commit()
Esempio n. 3
0
def addWelcomeSetting(chat_id, msg_type, msg_content="", file_id=""):
    addwel = SESSION.query(Welcome).get(chat_id)
    if addwel:
        addwel.msg_type = msg_type
        addwel.msg_content = msg_content
        try:
            os.remove(addwel.file_id)
        except Exception as e:
            print("addWelcomeSetting : %s" % (e))
        addwel.file_id = file_id
    else:
        addwel = Welcome(chat_id, msg_type, msg_content, file_id)
    SESSION.add(addwel)
    SESSION.commit()
Esempio n. 4
0
def addAutoReply(text, msg_type, msg_content="", file_id=""):
    try:
        addRep = SESSION.query(AutoReply).filter(AutoReply.text == text).one()
    except Exception as e:
        addRep = None
        print(str("error : togglepropsetting : %s" % (e)))

    if addRep:
        addRep.msg_type = msg_type
        addRep.msg_content = msg_content
        try:
            os.remove(addRep.file_id)
        except Exception as e:
            print("addAutoReplySetting : %s" % (e))
        addRep.file_id = file_id
    else:
        addRep = AutoReply(text, msg_type, msg_content, file_id)
    SESSION.add(addRep)
    SESSION.commit()
Esempio n. 5
0
def togglePropSettings(chatId, propName, active=True):
    try:
        try:
            addProp = (SESSION.query(PropSetting).filter(
                PropSetting.chatId == chatId
                and PropSetting.propName == propName).one())
        except Exception as e:
            addProp = None
            print(str("error : togglepropsetting : %s" % (e)))

        if addProp:
            addProp.propName = propName
            addProp.active = active
        else:
            addProp = PropSetting(chatId, propName, active)
        SESSION.add(addProp)
        SESSION.commit()
        return True
    except Exception as e:
        print(str("error : togglepropsetting : %s" % (e)))