-
Notifications
You must be signed in to change notification settings - Fork 14
Adds user whitelisting support #9
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
base: master
Are you sure you want to change the base?
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.
Thanks for the patch, this is a great feature!
db_logger.py
Outdated
|
|
||
| try: | ||
| self.cursor.execute("INSERT INTO chat_log (sender, message, channel, date) VALUES (%s, %s, %s, %s)", | ||
| if self.senders_whitelist is not None and sender in self.senders_whitelist: |
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.
if (self.senders_whitelist is not None and sender in self.senders_whitelist) or (self.senders_whitelist is None):
db_logger.py
Outdated
| if self.senders_whitelist is not None and sender in self.senders_whitelist: | ||
| self.cursor.execute("INSERT INTO chat_log (sender, message, channel, date) VALUES (%s, %s, %s, %s)", | ||
| (sender, message, channel, current_time_in_milli())) | ||
| elif self.senders_whitelist is None: |
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.
Delete this and the next line
manager.py
Outdated
| self.log_filename = log_filename | ||
| self.channels = channels | ||
| self.db_logger = DatabaseLogger(settings.DATABASE['HOST'], | ||
| if settings.USERS is not None and len(settings.USERS) is not 0: |
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 do not need this if condition here. If settings.USERS is None, it will do exactly what it should.
manager.py
Outdated
| settings.IRC['PASSWORD'], | ||
| self.log_filename) | ||
| bot_db_logger = DatabaseLogger(settings.DATABASE['HOST'], | ||
| if settings.USERS is not None and len(settings.USERS) is not 0: |
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.
Same comment as above.
users = [] now valid for no users
|
This is working for me. Let me know if any other changes are needed. |
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.
Sorry for the delay in the review! These should be simple fixes and then I'll merge it. Thanks again!
manager.py
Outdated
| self.log_filename = log_filename | ||
| self.channels = channels | ||
| self.db_logger = DatabaseLogger(settings.DATABASE['HOST'], | ||
| if settings.USERS is not None: |
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.
Sorry I should have been more explicit here. You don't actually need the if here (neither the else and the contents inside it). In case settings.USERS is None, you will automatically be passing None as the last argument as well.
| settings.IRC['PASSWORD'], | ||
| self.log_filename) | ||
| bot_db_logger = DatabaseLogger(settings.DATABASE['HOST'], | ||
| if settings.USERS is not None: |
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.
Same comment as above.
Also forgot some formatting below...
Made this modification for a project I'm working on.
Purely feature-enabling, does not change any behaviour if feature is not used.