0rx

onMessage_event_log_for_chatango_bot

0rx
Nov 25th, 2015
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.55 KB | None | 0 0
  1. ##############################################################################################################
  2. #############################################################################################################
  3. # putting all messages into msg_log.txt file based on whatever output from onMessage event
  4. # you need to make a msg_log.txt file inside the bot's script folder to make this work
  5. # Remember, this thing is free to use, Don't always think shit of me
  6. #
  7. # ps: It's been a while since the last time I did this, Maybe you find my codes is getting messy
  8. #
  9. # Best regards
  10. # 0rx
  11. #
  12. #
  13. #      HOW TO ??
  14. #    Put this thing under onMessage event, Example is below, and the codes are further below
  15. #
  16. # def onMessage(self, room, user, message):
  17. #        if room.getLevel(self.user) > 0:
  18. #                msg_log = []
  19. #                logs = open('msg_log.txt', 'r')
  20. #                for i in logs.readlines():
  21. #                    if len(i.strip())>0:
  22. #                        msg_log.append(i.strip())
  23. #                logs.close()
  24. #                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))
  25. #                logs = open('msg_log.txt', 'w')
  26. #                logs.write("\r\n".join(msg_log))
  27. #                logs.close()
  28. #        else:
  29. #                msg_log = []
  30. #                logs = open('msg_log.txt', 'r')
  31. #                for i in logs.readlines():
  32. #                    if len(i.strip())>0:
  33. #                        msg_log.append(i.strip())
  34. #                logs.close()
  35. #                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))
  36. #                logs = open('msg_log.txt', 'w')
  37. #                logs.write("\r\n".join(msg_log))
  38. #                logs.close()
  39. #
  40. ##################################################################################################################
  41. ##################################################################################################################
  42.  
  43.  
  44.  
  45.  
  46.  
  47.         if room.getLevel(self.user) > 0:
  48.                 msg_log = []
  49.                 logs = open('msg_log.txt', 'r')
  50.                 for i in logs.readlines():
  51.                     if len(i.strip())>0:
  52.                         msg_log.append(i.strip())
  53.                 logs.close()
  54.                 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))
  55.                 logs = open('msg_log.txt', 'w')
  56.                 logs.write("\r\n".join(msg_log))
  57.                 logs.close()
  58.         else:
  59.                 msg_log = []
  60.                 logs = open('msg_log.txt', 'r')
  61.                 for i in logs.readlines():
  62.                     if len(i.strip())>0:
  63.                         msg_log.append(i.strip())
  64.                 logs.close()
  65.                 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))
  66.                 logs = open('msg_log.txt', 'w')
  67.                 logs.write("\r\n".join(msg_log))
  68.                 logs.close()
Advertisement
Add Comment
Please, Sign In to add comment