Open sheppy9 opened 2 months ago
Make downloadCourseInfo() async as downloading PDF and resending the PDF will stall the /courseinfo coroutine.
Use queue system to handle concurrent request to send the same PDF file. When a coroutine opens a local PDF file, it also locks access to the same file, so a second coroutine cannot opens it and this will lead to an exception that will kill the second coroutine.
Good resource on Python async: https://docs.python.org/3/library/asyncio-task.html
Please use python type hinting for improved readability.
Here are some design consideration.
Extend the SingletonDatabase class with a File Cache module to manage and retrieve downloads.
The User Class simply retrieves the courseinfo PDF from the File Cache.
https://www.geeksforgeeks.org/cache-eviction-policies-system-design/
A new function that allow user to download pdf course information by asking bot
if command argument is not provided, function will "guess" from chat title
example command /courseinfo /courseinfo ict335
Issue link: Allow user to download course information pdf