main.py 833 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/python3
  2. import os
  3. getLogsCommand = "ls -1 ./in-logs/"
  4. outLogsCommand = os.popen(getLogsCommand).read().split("\n")
  5. def getLogs():
  6. global outLogsCommand
  7. files = []
  8. for i in outLogsCommand:
  9. try:
  10. if i.split(".")[-1] == "log":
  11. files.append(i)
  12. except Exception:
  13. pass
  14. return files
  15. def readChat():
  16. chatLines = []
  17. logFile = open(f"in-logs/{getLogs()[0]}", "r")
  18. logLines = logFile.read().split("\n")
  19. x = 0
  20. while True:
  21. try:
  22. logSplited = logLines[x].split()
  23. except Exception:
  24. break
  25. try:
  26. if logSplited[1] == "[Async" and logSplited[2] == "Chat":
  27. chatLines.append(x+1)
  28. except IndexError:
  29. pass
  30. x += 1
  31. return chatLines
  32. print(readChat())