Tired of not getting your homework assignments? Here's your solution!
Made with a 100% love.
Give the project a star!
Report Bug
·
Request Feature
This project was made because many Moodle-based platforms don't send the notifications when needed, so I decided to create my own notifier.
I decided to use SQLite to store the credentials and create a monitor that every 10 minutes notifies the user if there's a new homework.
In order to run the bot you have to set up the following environment variables:
- BOT_TOKEN - The API key provided by the bot father in Telegram
- ADMIN_ID - Your Telegram ID (you can send a message to userinfobot to get your ID)
- SCHOOL_DOMAIN - Your school's domain (e.g: www.school-domain.edu.com)
export API_KEY="YOUR_API_KEY"
set API_KEY="YOUR_API_KEY"
$env:API_KEY="YOUR_API_KEY"
And repeat with each enviroment variable.
If we want to use our bot we need to set up a webhook, i.e., where we can receive the updates Telegram provides us. To achieve that we can use ngrok to get an HTTP/HTTPS URL or any host like render.
If we use render to host our Flask app it automatically will set up an URL for us, however, if we use ngrok instead to get an URL, we need to make sure that ngrok is running on the same host thar we are running our Flask app.
Once we have our URL and Flask app running, we need to make a request to setWebhook Telegram's endpoint.
You have 2 ways to run the bot:
- Using the flask module
- Using a WSGI Server (such as Gunicorn)
To start the bot using the Flask module you need to set up the "FLASK_APP" environment variable:
export FLASK_APP="app:app"
set FLASK_APP="app:app"
$env:FLASK_APP="app:app"
Once you've set your environment variables you can run your bot with:
python -m flask run
or
flask run
There are multiple WSGI containers to choose from, here we will choose gunicorn as it is the easiest to set up.
First of all you need to install it via PIP
pip install gunicorn
Once we've done that we can start our Bot by doing
gunicorn app:app
And that's it, we should see our Bot being started :)
The bot is pretty much user-friendly, for now, we only have 2 commands (excluding the /help command):
- /login - Used to login into the school's platform. If succeed it will return a message saying that the monitor has started. Otherwise an error will be shown
- /tareas - Used to force a retreive of all the available homeworks. On error if the user is logged it will log in again, if not, it will prompt the user to log in.
- /deletedb - Used to delete all the data in the database.
And that's it! you now know how to use the bot:).
Wanna contribute to the project? Great! Please follow the next steps in order to submit any feature or bug-fix :) You can also send me your ideas to my Telegram, any submit is greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the AGPL-3.0 License. See LICENSE
for more information.
Telegram: - @freshSauce
Project Link: https://github.com/freshSauce/Moodle-Notifier
- Code uploaded to Github.