This is a Python-based Telegram bot using the telethon library. The bot responds to messages using the evagpt4 reverse engeneered api from OpenGPT repo
MIT License
140
stars
42
forks
source link
Implement Role class and update main.py to use Role instances #10
This PR implements a Role class to represent a role and updates the main.py file to use instances of the Role class instead of the roles JSON object. This improves the code structure and makes it more object-oriented.
Summary of Changes
Created a new file named role.py to define the Role class.
The Role class has a constructor (init method) that takes two parameters: name and info. These parameters are stored as instance variables.
The Role class has getter methods (get_name and get_info) to return the name and info of the role.
The Role class has setter methods (set_name and set_info) to set the name and info of the role.
Modified the main.py file to import the Role class.
In the /newrole event handler, instead of adding the role to the roles JSON object, a new instance of the Role class is created with the provided name and info and added to a dictionary of roles.
In the /roles event handler, the roles are now iterated over the dictionary of Role instances and their names are printed.
In the /role event handler, the Role instance is retrieved from the dictionary of roles using the provided name.
Removed the code that reads and writes the roles JSON file as it is no longer needed.
This PR improves the code structure and makes it easier to manage and extend the roles functionality in the future.
Fixes #8.
To checkout this PR branch, run the following command in your terminal:
git checkout sweep/role-class
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.
Description
This PR implements a Role class to represent a role and updates the main.py file to use instances of the Role class instead of the roles JSON object. This improves the code structure and makes it more object-oriented.
Summary of Changes
This PR improves the code structure and makes it easier to manage and extend the roles functionality in the future.
Fixes #8.
To checkout this PR branch, run the following command in your terminal:
To get Sweep to edit this pull request, leave a comment below or in the code. Leaving a comment in the code will only modify the file but commenting below can change the entire PR.