Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##############################################################################################################
- #############################################################################################################
- # putting all messages into msg_log.txt file based on whatever output from onMessage event
- # you need to make a msg_log.txt file inside the bot's script folder to make this work
- # Remember, this thing is free to use, Don't always think shit of me
- #
- # ps: It's been a while since the last time I did this, Maybe you find my codes is getting messy
- #
- # Best regards
- # 0rx
- #
- #
- # HOW TO ??
- # Put this thing under onMessage event, Example is below, and the codes are further below
- #
- # def onMessage(self, room, user, message):
- # if room.getLevel(self.user) > 0:
- # msg_log = []
- # logs = open('msg_log.txt', 'r')
- # for i in logs.readlines():
- # if len(i.strip())>0:
- # msg_log.append(i.strip())
- # logs.close()
- # msg_log.append("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, message.ip, user.name.title(), message.body))
- # logs = open('msg_log.txt', 'w')
- # logs.write("\r\n".join(msg_log))
- # logs.close()
- # else:
- # msg_log = []
- # logs = open('msg_log.txt', 'r')
- # for i in logs.readlines():
- # if len(i.strip())>0:
- # msg_log.append(i.strip())
- # logs.close()
- # msg_log.append("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, "IP-NOT-VISIBLE", user.name.title(), message.body))
- # logs = open('msg_log.txt', 'w')
- # logs.write("\r\n".join(msg_log))
- # logs.close()
- #
- ##################################################################################################################
- ##################################################################################################################
- if room.getLevel(self.user) > 0:
- msg_log = []
- logs = open('msg_log.txt', 'r')
- for i in logs.readlines():
- if len(i.strip())>0:
- msg_log.append(i.strip())
- logs.close()
- msg_log.append("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, message.ip, user.name.title(), message.body))
- logs = open('msg_log.txt', 'w')
- logs.write("\r\n".join(msg_log))
- logs.close()
- else:
- msg_log = []
- logs = open('msg_log.txt', 'r')
- for i in logs.readlines():
- if len(i.strip())>0:
- msg_log.append(i.strip())
- logs.close()
- msg_log.append("[%s]\033[94m[MSG]\033[0m\033[31m[LVL %s]\033[0m[%s][%s] %s: %s" % (time.strftime("%d/%m/%y- %H:%M:%S", time.localtime(time.time())), self.getAccess(user), room.name, "IP-NOT-VISIBLE", user.name.title(), message.body))
- logs = open('msg_log.txt', 'w')
- logs.write("\r\n".join(msg_log))
- logs.close()
Advertisement
Add Comment
Please, Sign In to add comment