suss-swe-ig / suss-telegram-groups

Bot for sharing SUSS Telegram Groups
MIT License
0 stars 0 forks source link

Add get course information function #11

Open sheppy9 opened 2 months ago

sheppy9 commented 2 months ago

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

geodome commented 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

geodome commented 2 months ago

Please use python type hinting for improved readability.

https://docs.python.org/3/library/typing.html

geodome commented 2 months ago

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/