Commands package
Description
All the commands the bot will react to
aulario
Aulario command
- module.commands.aulario.aulario(update, context, chat_id=None, message_id=None)
Called by the /aulario command. Shows the calendar to the user to allow him to select a day from the calendar
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
Optional
[int
]) – id of the chat. Defaults to None.message_id (
Optional
[int
]) – id of the message. Defaults to None.
- Return type:
None
- module.commands.aulario.calendar_handler(update, context)
Called by clicking on a day on the calendar of the /aulario command. Show the list of subject for the day
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.aulario.create_calendar(days, year=None, month=None)
Called by
aulario()
andmonth_handler()
. Creates an InlineKeyboard to append to the message- Parameters:
days (
int
) – dayyear (
Optional
[int
]) – yeat. Defaults to None.month (
Optional
[int
]) – month. Defaults to None.
- Return type:
InlineKeyboardMarkup
- Returns:
calendar
- module.commands.aulario.create_map(sub, h, room)
Called by
subjects_handler()
. Creates an image to show where the lesson will take place. Returns None if the hall is not in the base image- Parameters:
sub (
str
) – name of the subjecth (
str
) – timeroom (
str
) – hall
- Return type:
Optional
[BytesIO
]- Returns:
photo to send
- module.commands.aulario.get_subjs_keyboard(page, day)
Called by
calendar_handler()
subjects_arrow_handler()
. Generates the keyboard that lists all the subjects for the selected date- Parameters:
page (
int
) – page of the subject selectorday (
str
) – day
- Return type:
list
- Returns:
InlineKeyboard
- module.commands.aulario.month_handler(update, context)
Called when navigating the calendar of the /aulario command. Updates the calendar
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.aulario.subjects_arrow_handler(update, context)
Called when navigating the /aulario menu with the arrows. Shows the next or previous page
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.aulario.subjects_handler(update, context)
Called when clicking on a subject of the /aulario command. Shows more information on the subject selected
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
esami
/esami command
- module.commands.esami.esami(update, context)
Called by the /esami command. Shows the options available to execute an exam query.
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.esami.esami_button_anno(update, context, chat_id, message_id)
Called by one of the buttons of the /esami command. Allows the user to choose an year among the ones proposed
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat of the usermessage_id (
int
) – id of the sub-menu message
- Return type:
None
- module.commands.esami.esami_button_insegnamento(update, context, chat_id, message_id)
Called by one of the buttons of the /esami command. Allows the user to write the subject they want to search for
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat of the usermessage_id (
int
) – id of the sub-menu message
- Return type:
None
- module.commands.esami.esami_button_sessione(update, context, chat_id, message_id)
Called by one of the buttons of the /esami command. Allows the user to choose a session among the ones proposed
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat of the usermessage_id (
int
) – id of the sub-menu message
- Return type:
None
- module.commands.esami.esami_handler(update, context)
Called by any of the buttons in the /esami command sub-menus. The action will change depending on the button:
anno -> adds / removes the selected year from the query parameters
sessione -> adds / removes the selected session from the query parameters
search -> executes the query with all the selected parametes and shows the result
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.esami.esami_input_insegnamento(update, context)
Called after
esami_button_insegnamento()
. Allows the user to input the wanted subject, in the format [Ii]ns: <insegnamento>- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.esami.generate_esami_text(locale, user_dict)
Called by
esami()
after the search button in the /esami command has been pressed. Executes the query and returns the text to send to the user- Parameters:
locale (
str
) – user’s languageuser_dict (
dict
) – dictionary that stores the user selected parameters to use in the query
- Return type:
str
- Returns:
result of the query to send to the user
- module.commands.esami.get_esami_text_inline_keyboard(locale, context)
Generates the text and the InlineKeyboard for the /esami command, based on the current parameters.
- Parameters:
locale (
str
) – user’s languagecontext (
CallbackContext
) – context passed by the handler
- Return type:
(
str
,InlineKeyboardMarkup
)- Returns:
message_text and InlineKeyboardMarkup to use
gdrive
/drive command
- module.commands.gdrive.drive(update, context)
Called by the /drive command. Lets the user navigate the drive folders, if he has the permissions
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.gdrive.drive_handler(update, context)
Called by any of the buttons of the /drive command. Allows the user to navigate in the google drive and download files
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.gdrive.get_files_keyboard(file_list, row_len=2)
Called by
drive()
anddrive_handler()
. Generates the InlineKeyboard that allows the user to navigate among the files in the list- Parameters:
file_list (
list
) – list of filesrow_len (
int
) – lenght of the row. Defaults to 2
- Return type:
list
- Returns:
InlineKeyboard
help
/help command
Called by a sm_help_back_to_menu button from the sub menu. Allows the user to return back to the command list
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id – id of the chat the command was invoked from
message_id – id of the help message
- Return type:
None
- module.commands.help.help_cmd(update, context, edit=False)
Called by the /help command. Shows all the actions supported by the bot
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handleredit (
bool
) – bool flag that affects how the message should be handled
- Return type:
None
- module.commands.help.help_dip_cdl(update, context, chat_id, message_id)
Called by the sm_help_dip_cdl button from the /help command. Lists to the user the commands related to the department or the CDL
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
- module.commands.help.help_ersu(update, context, chat_id, message_id)
Called by the sm_help_ersu button from the /help command. Lists to the user the commands related to the ERSU
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
- module.commands.help.help_misc(update, context, chat_id, message_id)
Called by the sm_help_misc button from the /help command. Lists to the user the commands related to the miscellaneous stuff
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
- module.commands.help.help_projects_acknowledgements(update, context, chat_id, message_id)
Called by the sm_help_projects_acknowledgements button from the /help command. Lists to the user the commands related to the other’s project and acknowledgements
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
Called by the sm_help_rapp_menu button from the /help command. Allows the user to select the department
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
- module.commands.help.help_segr(update, context, chat_id, message_id)
Called by the sm_help_segr button from the /help command. Lists to the user the commands related to the secretariats’ office hours
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id (
int
) – id of the chat the command was invoked frommessage_id (
int
) – id of the help message
- Return type:
None
lezioni
/lezioni command
- module.commands.lezioni.generate_lezioni_text(locale, user_dict)
Called by
lezioni()
after the search button in the /lezioni command has been pressed. Executes the query and returns the text to send to the user- Parameters:
locale (
str
) – user’s languageuser_dict – dictionary that stores the user selected parameters to use in the query
- Return type:
str
- Returns:
result of the query to send to the user
- module.commands.lezioni.get_lezioni_text_InLineKeyboard(locale, context)
Generates the text and the InlineKeyboard for the /lezioni command, based on the current parameters.
- Parameters:
locale (
str
) – user’s languagecontext (
CallbackContext
) – context passed by the handler
- Return type:
Tuple
[str
,InlineKeyboardMarkup
]- Returns:
message_text and InlineKeyboardMarkup to use
- module.commands.lezioni.get_orario_file()
Download pdf file from website.
- Return type:
Optional
[bytes
]- Returns:
None or downloaded file
- module.commands.lezioni.get_url(courses)
Extract the L-31 url from markdown file.
- Parameters:
courses (
str
) – all available courses- Return type:
str
- Returns:
link of the website
- module.commands.lezioni.lezioni(update, context)
Called by the /lezioni command. Sends a pdf file to user downloaded from website.
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.lezioni.lezioni_button_anno(update, context, chat_id, message_id)
Called by one of the buttons of the /lezioni command. Allows the user to choose an year among the ones proposed
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id – id of the chat of the user
message_id – id of the sub-menu message
- Return type:
None
- module.commands.lezioni.lezioni_button_giorno(update, context, chat_id, message_id)
Called by one of the buttons of the /lezioni command. Allows the user to choose a day among the ones proposed
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id – id of the chat of the user
message_id – id of the sub-menu message
- Return type:
None
- module.commands.lezioni.lezioni_button_insegnamento(update, context, chat_id, message_id)
Called by one of the buttons of the /lezioni command. Allows the user to write the subject they want to search for
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerchat_id – id of the chat of the user
message_id – id of the sub-menu message
- Return type:
None
- module.commands.lezioni.lezioni_handler(update, context)
Called by any of the buttons in the /lezioni command sub-menus. The action will change depending on the button:
anno -> adds / removes the selected year from the query parameters
giorno -> adds / removes the selected day from the query parameters
search -> executes the query with all the selected parametes and shows the result
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.lezioni.lezioni_input_insegnamento(update, context)
Called after
lezioni_button_insegnamento()
. Allows the user to input the wanted subject, in the format [Nn]ome: <insegnamento>- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
professori
/prof command
- module.commands.professori.generate_prof_text(locale, names)
Called from the
prof()
method. Executes the query and returns the text to send to the user- Parameters:
locale (
str
) – user’s languagenames (
list
) – list of args passed to the context
- Return type:
str
- Returns:
result of the query to send to the user
- module.commands.professori.prof(update, context)
Called by the /prof command. Use: /prof <nomeprofessore> … Shows all the professors that match the request
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
regolamento_didattico
/regolamentodidattico command
- module.commands.regolamento_didattico.cdl_handler(update, context)
- Return type:
None
- module.commands.regolamento_didattico.get_cdl_keyboard(locale, reg_doc=None)
Called by
regolamentodidattico()
andregolamentodidattico_handler()
. Generates the whole list of rulebooks to append as an InlineKeyboard- Parameters:
locale (
str
) – the user languagereg_doc (
Optional
[dict
]) – rulebooks to show
- Return type:
InlineKeyboardMarkup
- Returns:
list of rulebooks
- module.commands.regolamento_didattico.get_inf_keyboard(locale)
- Return type:
InlineKeyboardMarkup
- module.commands.regolamento_didattico.get_mat_keyboard(locale)
- Return type:
InlineKeyboardMarkup
- module.commands.regolamento_didattico.regolamentodidattico(update, _)
Called by the /regolamentodidattico command. Shows a menu from with the user can choose between (triennale | magistrale)
- Parameters:
update (
Update
) – update eventcontext – context passed by the handler
- Return type:
None
- module.commands.regolamento_didattico.regolamentodidattico_handler(update, context)
Called by any of the /regolamentodidattico buttons. Data can be ( home | triennale | magistrale ). Allows the used to navigate between the rulebooks
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.regolamento_didattico.send_regolamento(update, context)
Called by clicking on a rulebook. Sends said rulebook to the user.
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
report
/report command
- module.commands.report.report(update, context)
Called by the /report command. Use: /report <word> … Allows the user to report something to the administrators
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
start
/start command
- module.commands.start.get_help_keyboard(locale)
Generates the reply keyboard shown at the bottom of the screen
- Return type:
ReplyKeyboardMarkup
- Returns:
reply keyboard
- module.commands.start.start(update, context)
Called by the /start command. Sends a welcome message
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
stats
/stats command
- module.commands.stats.send_graph(rows, bot, chat_id)
Called by
stats_gen()
. Generates a graph and sends it to the user- Parameters:
rows (
list
) – hystory of commandsbot (
Bot
) – telegram botchat_id (
int
) – id of the chat
- Return type:
None
- module.commands.stats.stats(update, context)
Called by the /stats command. Use: /stats [days] Shows the history of all the commands requested to the bot in the last ‘days’. Defaults to 30.
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None
- module.commands.stats.stats_gen(update, context, days=0)
Called by
stats()
orstats_tot()
. Generates the requested stats, both with text and graph- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handlerdays (
int
) – number of days to consider. Defaults to 0.
- Return type:
None
- module.commands.stats.stats_tot(update, context)
Called by the /stats_tot command. Shows the history of all the commands requested to the bot
- Parameters:
update (
Update
) – update eventcontext (
CallbackContext
) – context passed by the handler
- Return type:
None