Example #1
0
def log(message):
    message_type = str(message.chat.type)[0].upper()
    #print("[" + message_type + "] Message from: " + utils.get_user_info(message) + " Content: " + str(message.text))
    conn = sqlite3.connect(configuration.db_log_path)
    c = conn.cursor()

    body = str(message.text)

    data = ()

    if utils.is_private(message):
        data = (str(message.chat.first_name), str(message.chat.last_name), str(message.chat.id), body, utils.get_timestamp(),message_type)
    elif utils.is_group(message):
        data = (str(message.from_user.first_name), str(message.from_user.last_name), str(message.from_user.id), body,utils.get_timestamp(), message_type)

    c.execute("INSERT INTO log VALUES (null,?,?,?,?,?,?)", data)

    conn.commit()
    conn.close()
Example #2
0
def location_rule(argv):
    if len(argv) < 3:
        usage.constraint("location rule")
        sys.exit(1)
    
    res_name = argv.pop(0)
    if not utils.is_resource(res_name) and not utils.is_group(res_name):
        utils.err("'%s' is not a resource" % res_name)

    argv.pop(0)

    cib = utils.get_cib_etree()
    constraints = cib.find(".//constraints")
    lc = ET.SubElement(constraints,"rsc_location")
    lc_id = utils.find_unique_id(cib, "location-" + res_name)
    lc.set("id", lc_id)
    lc.set("rsc", res_name)

    utils.rule_add(lc, argv)

    utils.replace_cib_configuration(cib)