MIS Functions¶
-
misbot.mis_utils.
bunk_lecture
(n, tot_lec, chatID, stype, index)¶ Calculates % drop/rise if one chooses to bunk certain lectures.
Parameters: - n (int) – number of lectures for a subject to bunk
- tot_lec (int) – total lectures conducted for that subject
- chatID (int | str) – user’s unique 9-digit ChatID from telegram
- stype (str) – Subject type (Lectures or Practicals)
- index (int) – Index of the user-selected subject from list of subjects
Returns: Percentage drop/rise
Return type: float
-
misbot.mis_utils.
until_x
(chatID, target)¶ Calculates the no. of lectures user must attend in order to get overall attendance to their specified target.
Parameters: - chatID (int | str) – user’s unique 9-digit ChatID from telegram
- target (float) – attendance percentage target
Returns: Number of lectures to attend
Return type: int
-
misbot.mis_utils.
check_login
(username, password)¶ Checks if user input for their credentials is correct for the student portal.
Parameters: - username (str) – student’s PID (format: XXXNameXXXX) where X - integers
- password (str) – student’s password for student portal
Returns: True for correct credentials, false otherwise.
Return type: bool
-
misbot.mis_utils.
check_parent_login
(username, dob)¶ Checks if user input for their credentials is correct for parent’s portal.
Parameters: - username (str) – student’s PID (format: XXXNameXXXX) where X - integers
- dob (str) – User’s Date of Birth
Returns: True for correct credentials, false otherwise.
Return type: bool
-
misbot.mis_utils.
crop_image
(path)¶ Crop image if the image height is > 800px.
Parameters: path (str) – image file path Returns: True for image height larger than 800px in length. Return type: bool
-
misbot.mis_utils.
clean_attendance_records
()¶ Delete all lectures and practical records from the DB. To be used at the beginning of a new semester so that
/bunk
command doesn’t display lectures of previous semester(s).Returns: Number of records deleted from Lecture and Practical tables. Return type: tuple
-
misbot.mis_utils.
get_user_info
(chat_id)¶ Give user data.
Parameters: chat_id (str) – 9-Digit unique user ID Returns: Dictionary of all user data Return type: dict
-
misbot.mis_utils.
solve_captcha
(session_id)¶ Solve captcha using
securimage_solver
library. Downloads the image from the securimage_endpoint and feeds it to securimage_solver lib.Parameters: session_id (str) – Session cookie Returns: Captcha answer Return type: str
-
misbot.mis_utils.
rate_limited
(bot, chat_id, command)¶ Checks if user has made a request in the past 5 minutes.
Parameters: - bot (telegram.bot.Bot) – Telegram Bot object
- chat_id (str) – 9-Digit unique user ID
- command (str) – Telegram command
Returns: True if user has made a request in past 5 mins, else False
Return type: bool
-
misbot.mis_utils.
get_subject_name
(chat_id, index, stype)¶ Return name of subject for a given user
Parameters: - chat_id (str) – 9-Digit unique user ID
- index (int) – Index of the user-selected subject from list of subjects
- stype (str) – Subject type (Lectures or Practicals)
Returns: Subject name
Return type: str
-
misbot.mis_utils.
get_misc_record
(chat_id)¶ Returns Misc record for a user
Parameters: chat_id (str) – 9-Digit unique user ID