track filehandler
All checks were successful
Build and Push Docker Image / build (push) Successful in 12s
All checks were successful
Build and Push Docker Image / build (push) Successful in 12s
This commit is contained in:
parent
c398cac067
commit
d2d0b1a03e
@ -24,24 +24,17 @@ class ConsoleCog(commands.Cog):
|
|||||||
"""
|
"""
|
||||||
Reads and handles the server-console.txt file.
|
Reads and handles the server-console.txt file.
|
||||||
"""
|
"""
|
||||||
_last_line_number = 0
|
file_handler: LogFileReader
|
||||||
|
|
||||||
def __init__(self, bot: commands.Bot):
|
def __init__(self, bot: commands.Bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
|
self.file_handler = LogFileReader(CONSOLE_FILE_PATH)
|
||||||
self.listen_for_changes.start()
|
self.listen_for_changes.start()
|
||||||
|
|
||||||
@tasks.loop(seconds=3)
|
@tasks.loop(seconds=3)
|
||||||
async def listen_for_changes(self):
|
async def listen_for_changes(self):
|
||||||
log.debug("listening for changes")
|
log.debug("listening for changes")
|
||||||
try:
|
async for line in self.file_reader.read():
|
||||||
file_reader = LogFileReader(CONSOLE_FILE_PATH)
|
|
||||||
except FileNotFoundError:
|
|
||||||
log.error("console file not found")
|
|
||||||
self.listen_for_changes.cancel()
|
|
||||||
return
|
|
||||||
|
|
||||||
log.debug("checking over changes")
|
|
||||||
async for line in file_reader.read():
|
|
||||||
await self.process_console_line(line)
|
await self.process_console_line(line)
|
||||||
|
|
||||||
async def process_console_line(self, line: str):
|
async def process_console_line(self, line: str):
|
||||||
|
Reference in New Issue
Block a user