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

improved structure and readability of main.py #196

Merged
merged 3 commits into from Jun 28, 2023

Conversation

AnastasiosZyngiridis
Copy link
Contributor

@AnastasiosZyngiridis AnastasiosZyngiridis commented Jun 25, 2023

1.Removed unnecessary import statements (import sys, import shutil, import getpass).

2.Encapsulated the code inside the BotCore class to provide better organization and encapsulation.

3.Replaced hardcoded configuration values with variables (self.server_url, self.port, self.name, etc.).

4.Utilized the os.path module for path-related operations instead of manually concatenating strings.

5.Updated the logging statements to use the logger instance.

6.Refactored the message_info method to handle exceptions and return a dictionary with all fields set to prevent None values.

7.Updated the methods method to return a dictionary of method references.

8.Added docstrings to functions and methods.

9.Fixed the indentation of the code to conform to Python style guidelines.

10.Replaced the print statements with logger statements for consistent logging.

11.Modified the load_plugins_from_folder method to handle different sources of plugin names (from configuration file or directory) and log errors appropriately.

12.Updated the load_plugins method to load plugins from the specified folders.

13.Refactored the run_plugins method to use the loaded plugins and pass the necessary arguments to the plugin's run method.

14.Renamed command_parser method to core_commands_parse for clarity.

15.Removed unused methods and variables (self.sp_command, self.core_plugins, pull).

16.Added missing exception handling in the quit method.

17.Cleaned up the code formatting and removed unnecessary comments.

Description

How Has This Been Tested?

Additional context

Add any other context or screenshots about the pull request here.

Checklist

  • I have read, understood and followed our Contributing Guide
  • My code follows the code style of this project
  • I have updated the documentation accordingly
  • I added my country flag to the README.md

Code of Conduct

By submitting this issue, you agree to follow our Code of Conduct

  • I agree to follow this project's Code of Conduct

1.Removed unnecessary import statements (import sys, import shutil, import getpass).

2.Encapsulated the code inside the BotCore class to provide better organization and encapsulation.

3.Replaced hardcoded configuration values with variables (self.server_url, self.port, self.name, etc.).

4.Utilized the os.path module for path-related operations instead of manually concatenating strings.

5.Updated the logging statements to use the logger instance.

6.Refactored the message_info method to handle exceptions and return a dictionary with all fields set to prevent None values.

7.Updated the methods method to return a dictionary of method references.

8.Added docstrings to functions and methods.

9.Fixed the indentation of the code to conform to Python style guidelines.

10.Replaced the print statements with logger statements for consistent logging.

11.Modified the load_plugins_from_folder method to handle different sources of plugin names (from configuration file or directory) and log errors appropriately.

12.Updated the load_plugins method to load plugins from the specified folders.

13.Refactored the run_plugins method to use the loaded plugins and pass the necessary arguments to the plugin's run method.

14.Renamed command_parser method to core_commands_parse for clarity.

15.Removed unused methods and variables (self.sp_command, self.core_plugins, pull).

16.Added missing exception handling in the quit method.

17.Cleaned up the code formatting and removed unnecessary comments.

"""
ONGOING REQUIREMENT/S
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnastasiosZyngiridis Why did you remove this section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Abdur-rahmaanJ Sorry for the mistake. As they where ONGOING REQUIREMENT/S i didn't touch them and forgot to put them back in after i was done editing the rest of the code.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AnastasiosZyngiridis Just add them back, thank you.

Copy link
Member

@Abdur-rahmaanJ Abdur-rahmaanJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put code back

Copy link
Member

@Abdur-rahmaanJ Abdur-rahmaanJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l

@Abdur-rahmaanJ Abdur-rahmaanJ merged commit 01785fc into pyhoneybot:master Jun 28, 2023
1 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants