Module package

Subpackages

Description

Modules

callback_handlers

Common query callback families

module.callback_handlers.exit_handler(update, context)

Called when the user wants to close a sub-menu. Removes the message from the user’s chat

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

Return type:

None

module.callback_handlers.informative_callback(update, context)

Called by any command that needs to show information to the user

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

Return type:

None

module.callback_handlers.localization_handler(update, context)

Called by any query that needs to show a localized text to the user

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

Return type:

None

module.callback_handlers.md_handler(update, context)

Called by any query that needs to show the contents of a markdown file to the user

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

Return type:

None

module.callback_handlers.none_handler(update, _)

Called when the user clicks an unactive button. Stops the spinning circle

Parameters:
  • update (Update) – update event

  • context – context passed by the handler

Return type:

None

module.callback_handlers.submenu_handler(update, context)

Called by sm_.* callbacks. Opens the requested sub-menu, usually by editing the message and adding an InlineKeyboard

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

Return type:

None

easter_egg_func

Nobody knows what those functions do

module.easter_egg_func.bladrim(update, context)
module.easter_egg_func.lei_che_ne_pensa_signorina(update, context)
module.easter_egg_func.prof_sticker(update, context)
module.easter_egg_func.prof_sticker_id()
Return type:

str

module.easter_egg_func.santino(update, context)
module.easter_egg_func.smonta_portoni(update, context)
module.easter_egg_func.uni_bandita(update, context)

gitlab

module.gitlab.download_blob_file_async(update, context, blob=None)

Return the handle to the file if below the maximum size otherwise the download link

Parameters:
  • bot – “bot” object of Telegram API

  • update (Update) – “update” object of Telegram API

  • blob – Object containing ID and name of a blob (default: None)

module.gitlab.download_blob_file_async_internal(update, context, blob_id, blob_name, db_result)

Download a file asynchronously and send it if the size is less than 50MB, otherwise send the download link

Parameters:
  • bot – “bot” object of Telegram API

  • update (Update) – “update” object of Telegram API

  • blob_id – The id of file to download

  • blob_name – The name of file to download

  • db_result – The result of query to achieve web_url, pathname and parent_id

module.gitlab.explore_repository_tree(origin_id, path='/', db=None)

Explore a repository analyzing for files and directories

Parameters:
  • origin_id – Origin repository ID

  • path – (default: ‘/’)

  • db – (default: None)

module.gitlab.format_keyboard_buttons(buttons=[])

Place the buttons on multiple lines if possible

Parameters:

buttons – Array containing the buttons to display (default: [])

module.gitlab.get_blob_file(project_id, blob_id)

Return blob object

Parameters:
  • project_id – Project ID

  • blob_id – Blob ID

module.gitlab.get_chat_id(update)

Return the chat ID from update object

Parameters:

update (Update) – “update” object of Telegram API

module.gitlab.get_projects(group_id)

Returns an array containing projects of a group

Paramaters:

group_id: Parent group ID

module.gitlab.get_repository_tree(project_id, path='/', recursive=False)

Return the repository tree

Parameters:
  • project_id – Project ID

  • path – Folder path of the project (default: ‘/’)

  • recursive – If True return every file or directory of the repository (default: False)

module.gitlab.get_subgroups(context, group_id)

Returns an array containing subgroups of a group

Paramaters:

group_id: Parent group ID

module.gitlab.git(update, context)
module.gitlab.gitlab_handler(update, context)

Handle every action of /git and /gitlab command

Parameters:
  • bot – “bot” object of Telegram API

  • update (Update) – “update” object of Telegram API

module.gitlab.init_api()

Initialize the GitLab APIs

module.gitlab.new_session(token)

Create a new session using the authentication token passed as argument.

Parameters:

token – Authentication Token for GitLab APIs

module.gitlab.send_message(update, context, message, buttons=[[]], blob=None)

Send a reply message with text and button or upload a document

Parameters:
  • bot – “bot” object of Telegram API

  • update (Update) – “update” object of Telegram API

  • message – Message text

  • buttons – Array of answer buttons (default: [[]])

  • blob – Object that specifies the blob file to download (default: None)

job_updater

Job updater

module.job_updater.updater_lep(_)

Called with a set frequence. Updates all the scrapables

Parameters:

context – context passed by the handler

shared

Constants and common functions

module.shared.check_log(update, command_name, is_query=False)

If enabled, logs the command

Parameters:
  • update (Update) – update event

  • command_name (str) – name of the event to log

  • is_query (bool) – whether the event to log is a query. Defaults to False.

module.shared.check_print_old_exams(year_exam)

Checks if the old exams should be considered

Parameters:

year_exam (str) – target year

Return type:

bool

Returns:

whether the old exams should be considered

module.shared.get_year_code(month, day)

Generates the code of the year

Parameters:
  • month (int) – month

  • day (int) – day

Return type:

str

Returns:

last two digits of the current year

module.shared.read_json(namefile)

Reads a json file

Parameters:

namefile (str) – name of the json file, without extension

Return type:

dict

Returns:

content of the json file, as a dictionary

module.shared.read_md(namefile)

Reads a markdown file

Parameters:

namefile (str) – name of the markdown file, without extension

Return type:

str

Returns:

content of the markdown file

module.shared.send_message(update, context, messaggio)

Replies with a message, making sure the maximum lenght text allowed is respected

Parameters:
  • update (Update) – update event

  • context (CallbackContext) – context passed by the handler

  • messaggio (str) – message to send