Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting an error when loading. #29

Closed
Hypertoken opened this issue May 21, 2022 · 2 comments
Closed

Getting an error when loading. #29

Hypertoken opened this issue May 21, 2022 · 2 comments

Comments

@Hypertoken
Copy link

Hypertoken commented May 21, 2022

Bot only handles chat and disconnects. not perks, joins, or deaths.
Maybe something with the regex on line 82 of perks.py

hours = re.search(r"Hours Survived: (\d+)", message).group(1)

2022-05-21 01:26:41,323:INFO:zomboi: Loading Perk history...
Ignoring exception in on_ready
Traceback (most recent call last):
  File "/home/zomboi/.local/lib/python3.10/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/home/zomboi/zomboi.py", line 69, in on_ready
    zomboi.add_cog(PerkHandler(zomboi, logPath))
  File "/home/zomboi/perks.py", line 16, in __init__
    self.loadHistory()
  File "/home/zomboi/perks.py", line 56, in loadHistory
    self.handleLog(*self.splitLine(line))
  File "/home/zomboi/perks.py", line 82, in handleLog
    hours = re.search(r"Hours Survived: (\d+)", message).group(1)
AttributeError: 'NoneType' object has no attribute 'group'
@Hypertoken
Copy link
Author

Hypertoken commented May 21, 2022

After further review; Looks like the regex is fine, it was the trimming of the string that wasn't going as planned. Since the timestamp for the string is handled already.

The issue is on line 62 of perks.py;
message = message[message.find("[", 2) + 1 :]

Which should remove everything up to the 2nd square open bracket. Problem is that was intended for the timestamp which is already removed. So it was removing the User. This was a domino effect, causing the "Hours Played" to return "." a period.

So changing line 62 of perks.py to;
message = message[message.find("[", 1) + 1 :]

Now it will properly parse the User, Type, and Hours

@JonnyPtn
Copy link
Owner

Is this on the 41.71? I haven't tested with that build yet so maybe the log format changed

I'll keep this open if that's the case then I'll remember to fix?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants