-
Notifications
You must be signed in to change notification settings - Fork 6
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
Logging to Discord channel #29
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Cheukting
I have a few comments
pass | ||
|
||
|
||
class AlreadyRegisteredError(BotError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can consider putting a bit more information for the error message here. Currently it's called in one place here:
discord/EuroPythonBot/helpers/pretix_connector.py
Lines 72 to 75 in 4fa2828
def validate_key(key: str) -> bool: | |
if key in REGISTERED_SET: | |
raise AlreadyRegisteredError("Ticket already registered") | |
return True |
and I think by adding:
class AlreadyRegisteredError(BotError):
"""Exception raised for registering a registered ticket."""
def __init__(self, key, message="Ticket is already registered."):
self.ticket_id = key
self.message = message + f" Key: {self.key}"
super().__init__(self.message)
we can add more debugger friendly error message like:
❌ : artem.kislovskiy encounter an error - AlreadyRegisteredError: Ticket already registered Ticket id: G0CFM-raquelindividual
However, we can find a better name for the key
variable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another thought, maybe we can explicitly add a timestamp in the beginning of the error message, that way I know for sure when a certain event happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: the code snippet works fine, thanks, I will add that. RE: the timestamp, I don't think it is needed as discord will log the time when receiving the message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will just modify the message that got passed in for now, do not see the point of holding the id in the Exception object for now, if needed in the future we can refactor
pass | ||
|
||
|
||
class NotFoundError(BotError): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm changing the logic to validate the ticket on Pretix. And I'll update this class there, not sure what would be the best error message here at the moment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can add as many errors as you like, they are all in the error.py
EuroPythonBot/helpers/logging.py
Outdated
if error is None: | ||
content = f"✅ : `{user_name}` registered as {[role.name for role in user.roles[1:]]}" | ||
else: | ||
content = f"❌ : `{user_name}` encounter an error - {error.__class__.__name__}: {error}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would maybe put \n
instead of -
if possible
❌ : artem.kislovskiy encounter an error
AlreadyRegisteredError: Ticket already registered Ticket id: G0CFM-raquelindividual
And maybe used smth like this:
❌ ERROR: user_name=artem.kislovskiy
AlreadyRegisteredError: Ticket already registered Ticket id: G0CFM-raquelindividual
But I'm totally fine to keep it as it is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's ok, just formatting things, I will add that (and an empty line if we do it with a multiline display) - I do not like the user_name=
I am thinking if someone said they have a problem and you ask them the name, you just to though the message and seek for that name anyway, no need to make it more "code like"
EuroPythonBot/helpers/logging.py
Outdated
user_name = user.name | ||
|
||
if error is None: | ||
content = f"✅ : `{user_name}` registered as {[role.name for role in user.roles[1:]]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about we use the same pattern as in error, like:
✅ SUCCESS: user_name=artem.kislovskiy roles=['Speakers', 'Attendees', 'online_role', 'inperson_role', 'new role', 'Ops', 'Admin']
BTW, do you know why we are ignoring the very first roleuser.roles[1:]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: same reason as above, I prefer it to look more like a communication rather than code, for skipping the 1st role, it is @everyone and it is not needed - everyone gets them
Ready to merge @Kislovskiy |
part of #18 and #14 - only about logging successful registration and failed registration into dedicated Discord channel