def bot_log(opt=0, agent=0, buff=None, lfn=None): if bot_log is False: return """ Format: DAY-MNTH-MTH-HH-MM-SS-YYYY.log :param opt: [0 = save; 1 = read] :param agent: [-1 = nobody, 0 = bot, 1 = user] :param buff: [the log body] :param lfn: [log filename (optional)] :return: nothing """ if lfn is None: bot_ini = bot_const.bot_init.replace(":", "-") bot_ini = bot_ini.replace(" ", "-") lfn = bot_const.bot_log_base+bot_ini+".log" else: lfn = bot_const.bot_log_base+lfn if agent == 0: buff = bot_const.bot_name+": "+buff elif agent == 1: buff = "Me: "+buff if agent != -1: buff = "["+bot_const.cur_time+"] :: "+buff if opt == 0 and buff is not None and lfn is not None: g_func.write_local_file(lfn, buff+"\n", "a") elif opt == 0 and buff is not None and lfn is None: g_func.write_local_file(lfn, "["+bot_const.cur_time+"] :: "+buff+"\n", "a")
def bot_log(opt=0, agent=0, buff=None, lfn=None): if bot_log is False: return """ :param opt: [0 = save; 1 = read] :param agent: [-1 = nobody, 0 = bot, 1 = user] :param buff: [the log body] :param lfn: [log filename (optional)] :return: nothing """ if lfn is None: lfn = bot_const.bot_log_base+g_func.get_datetime("%Y-%b-%d")+".log" else: lfn = bot_const.bot_log_base+lfn if agent == 0: buff = bot_const.bot_name+": "+g_func.parse_for_log(buff) elif agent == 1: buff = "Me: "+buff if agent != -1: buff = "["+g_func.get_datetime("%H:%M:%S")+"] :: "+buff if opt == 0 and buff is not None: if not os.path.isfile(lfn): string_x = ("[conversation with "+bot_const.bot_name + " on "+g_func.get_datetime('%A %%e %B, %Y')+"; started at " + g_func.get_datetime('%H:%M:%S')+"]\n") g_func.write_local_file(lfn, string_x, "a") g_func.write_local_file(lfn, buff+"\n", "a")