Ejemplo n.º 1
0
def esami(update: Update, context: CallbackContext):
    """Called by the /esami command.
    Shows the options available to execute an exam query.

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "esami")

    if 'esami' in context.user_data:  #ripulisce il dict dell'user relativo al comando /esami da eventuali dati presenti
        context.user_data['esami'].clear()
    else:  #crea il dict che conterrà i dati del comando /esami all'interno della key ['esami'] di user data
        context.user_data['esami'] = {}

    user_id = update.message.from_user.id
    chat_id = update.message.chat_id

    if chat_id != user_id:  # forza ad eseguire il comando in una chat privata
        context.bot.sendMessage(
            chat_id=chat_id,
            text="Questo comando è utilizzabile solo in privato")
        context.bot.sendMessage(
            chat_id=user_id,
            text="Dal comando /esami che hai eseguito in un gruppo")

    message_text, inline_keyboard = get_esami_text_inline_keyboard(context)
    context.bot.sendMessage(chat_id=user_id,
                            text=message_text,
                            reply_markup=inline_keyboard)
Ejemplo n.º 2
0
def prof(update: Update, context: CallbackContext):
    check_log(update, context, "prof")
    message_text = prof_cmd(context.args)
    if len(message_text) > 4096:
        send_message(update, context, message_text)
    else:
        context.bot.sendMessage(chat_id=update.message.chat_id, text=message_text, parse_mode='Markdown')
Ejemplo n.º 3
0
def santino(update: Update, context: CallbackContext):
    chat_id = update.message.chat_id
    if chat_id in (-1001031103640, config_map['dev_group_chatid']):
        check_log(update, "santino")
        message_text = EasterEgg.get_santino()
        context.bot.sendMessage(chat_id=update.message.chat_id,
                                text=message_text)
Ejemplo n.º 4
0
def report(update: Update, context: CallbackContext):
    check_log(update, context, "report")
    chat_id = update.message.chat_id
    chat_username = update.message.from_user.username
    executed_command = update.message.text.split(' ')[0]


    if chat_id < 0:
        context.bot.sendMessage(chat_id=chat_id, text="! La funzione %s non è ammessa nei gruppi" % executed_command)
    elif not chat_username:
        context.bot.sendMessage(chat_id=chat_id, text="La funzione %s non è ammessa se non si dispone di un username." % executed_command)
    else:
        if  context.args:
            db = sqlite3.connect('data/DMI_DB.db')
            message = "⚠️Segnalazione⚠️\n"
            if db.execute("SELECT Chat_id FROM 'Chat_id_List' WHERE Chat_id = %s" %chat_id).fetchone():
                name = db.execute("SELECT Username,Nome,Cognome FROM 'Chat_id_List' WHERE Chat_id = %s" %chat_id)
                row = name.fetchone()

                if row[0] is None:
                    message += "Nome: " + row[1] + "\n" + "Cognome: " + row[2] + "\n" + " ".join(context.args)
                else:
                    message += "Username: @" + row[0] + "\n" + "Nome: " + row[1] + "\n" + "Cognome: " + row[2] + "\n" + " ".join(context.args)
                context.bot.sendMessage(chat_id = config_map['representatives_group'], text = message)
                context.bot.sendMessage(chat_id = chat_id, text = "Resoconto segnalazione: \n" + message + "\n Grazie per la segnalazione, un rappresentante ti contatterà nel minor tempo possibile.")

                db.close()
            else:
                context.bot.sendMessage(chat_id=chat_id, text="🔒 Non hai i permessi per utilizzare la funzione %s\nUtilizzare il comando /request <nome> <cognome> <e-mail> (il nome e il cognome devono essere scritti uniti Es: Di Mauro -> DiMauro)" % executed_command)

        else:
            context.bot.sendMessage(chat_id = chat_id, text="Errore. Inserisci la tua segnalazione dopo /report (Ad esempio /report Invasione ingegneri in corso.)")
Ejemplo n.º 5
0
def git(update: Update, context: CallbackContext):
    check_log(update, context, "gitlab")

    chat_id = update.message.chat_id
    executed_command = update.message.text.split(' ')[0]

    if chat_id < 0:
        context.bot.sendMessage(
            chat_id=chat_id,
            text="❗️ La funzione %s non è ammessa nei gruppi" %
            executed_command)
    else:
        db = sqlite3.connect('data/DMI_DB.db')

        if db.execute("SELECT Chat_id FROM 'Chat_id_List' WHERE Chat_id = %s" %
                      chat_id).fetchone():
            gitlab_handler(update, context)
        else:
            context.bot.sendMessage(
                chat_id=chat_id,
                text=
                "🔒 Non hai i permessi per utilizzare la funzione %s\nUtilizzare il comando /request <nome> <cognome> <e-mail> (il nome e il cognome devono essere scritti uniti Es: Di Mauro -> DiMauro)"
                % executed_command)

        db.close()
Ejemplo n.º 6
0
def prof(update: Update, context: CallbackContext):
    """Called by the /prof command.
    Use: /prof <nomeprofessore> ...
    Shows all the professors that match the request

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "prof")
    message_text = generate_prof_text(context.args)

    message_text_list = message_text.split('\n\n')
    professors, total_profs = message_text_list[:-1], message_text_list[-1]

    # 15 professors are like ~3500 characters
    for index in range(0, len(professors), 15):
        message_text = '\n\n'.join(professors[index:index + 15])
        # if this is the last message, we could append the "Total results"
        if len(professors) <= index + 15:
            message_text += '\n\n' + total_profs

        context.bot.sendMessage(chat_id=update.message.chat_id,
                                text=message_text,
                                parse_mode='MarkdownV2',
                                disable_web_page_preview=True)
Ejemplo n.º 7
0
def esami(update: Update, context: CallbackContext):
    check_log(update, context, "esami")

    if 'esami' in context.user_data:
        context.user_data['esami'].clear(
        )  #ripulisce il dict dell'user relativo al comando /esami da eventuali dati presenti
    else:
        context.user_data['esami'] = {
        }  #crea il dict che conterrà i dati del comando /esami all'interno della key ['esami'] di user data

    user_id = update.message.from_user.id
    chat_id = update.message.chat_id

    if chat_id != user_id:  # forza ad eseguire il comando in una chat privata, anche per evitare di inondare un gruppo con i risultati
        context.bot.sendMessage(
            chat_id=chat_id,
            text="Questo comando è utilizzabile solo in privato")
        context.bot.sendMessage(
            chat_id=user_id,
            text="Dal comando esami che hai eseguito in un gruppo")

    message_text, inline_keyboard = get_esami_text_inline_keyboard(context)
    context.bot.sendMessage(chat_id=user_id,
                            text=message_text,
                            reply_markup=inline_keyboard)
Ejemplo n.º 8
0
def esami_input_insegnamento(update: Update, context: CallbackContext):
    if context.user_data['esami'].get('cmd', 'null') == "input_insegnamento": #se effettivamente l'user aveva richiesto di modificare l'insegnamento...
        check_log(update, context, "esami_input_insegnamento")
        context.user_data['esami']['insegnamento'] = re.sub(r"^(?!=<[/])[Ii]ns:\s+", "", update.message.text) #ottieni il nome dell'insegnamento e salvalo nel dict
        del context.user_data['esami']['cmd'] #elimina la possibilità di modificare l'insegnamento fino a quando l'apposito button non viene premuto di nuovo
        reply = get_esami_text_InlineKeyboard(context)
        context.bot.sendMessage(chat_id=update.message.chat_id, text=reply[0], reply_markup=reply[1])
Ejemplo n.º 9
0
def lezioni(update: Update, context: CallbackContext):
    """Called by the /lezioni command.
    Shows the options available to execute a lesson query.

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "lezioni")

    if 'lezioni' in context.user_data:
        context.user_data['lezioni'].clear(
        )  # ripulisce il dict dell'user relativo al comando /lezioni da eventuali dati presenti
    else:
        context.user_data['lezioni'] = {
        }  # crea il dict che conterrà i dati del comando /lezioni all'interno della key ['lezioni'] di user data

    user_id = update.message.from_user.id
    chat_id = update.message.chat_id

    if chat_id != user_id:  # forza ad eseguire il comando in una chat privata, anche per evitare di inondare un gruppo con i risultati
        context.bot.sendMessage(
            chat_id=chat_id,
            text="Questo comando è utilizzabile solo in privato")
        context.bot.sendMessage(
            chat_id=user_id,
            text="Dal comando lezioni che hai eseguito in un gruppo")

    message_text, inline_keyboard = get_lezioni_text_InLineKeyboard(context)
    context.bot.sendMessage(chat_id=user_id,
                            text=message_text,
                            reply_markup=inline_keyboard)
Ejemplo n.º 10
0
def drive(update: Update, context: CallbackContext):
    """Called by the /drive command.
    Lets the user navigate the drive folders, if he has the permissions

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "drive")
    chat_id = update.message.chat_id

    gauth = GoogleAuth(settings_file="config/settings.yaml")
    gauth.CommandLineAuth()
    gdrive = GoogleDrive(gauth)

    if chat_id < 0:
        context.bot.sendMessage(
            chat_id=chat_id,
            text="La funzione /drive non è ammessa nei gruppi")
        return

    try:
        file_list = gdrive.ListFile({
            'q': "'0B7-Gi4nb88hremEzWnh3QmN3ZlU' in parents and trashed=false",
            'orderBy': 'folder,title'
        }).GetList()
    except AuthError as e:
        log_error(header="drive", error=e)

    keyboard = get_files_keyboard(
        file_list,
        row_len=3)  # keyboard that allows the user to navigate the folder
    context.bot.sendMessage(chat_id=chat_id,
                            text="DMI UNICT - Appunti & Risorse:",
                            reply_markup=InlineKeyboardMarkup(keyboard))
Ejemplo n.º 11
0
def informative_callback(update: Update, context: CallbackContext):
    cmd = update.message.text.split(' ')[0][
        1:]  #prende solo la prima parola del messaggio (cioè il comando) escludendo lo slash
    check_log(update, context, cmd)
    message_text = read_md(cmd)
    context.bot.sendMessage(chat_id=update.message.chat_id,
                            text=message_text,
                            parse_mode='Markdown')
def regolamentodidattico_button(update: Update, context: CallbackContext):
    check_log(update, context, "regolamentodidattico", 1)

    query = update.callback_query
    context.bot.edit_message_text(chat_id=query.message.chat_id,
                                  message_id=query.message.message_id,
                                  text=first_text(),
                                  reply_markup=regolamentodidattico_keyboard())
Ejemplo n.º 13
0
def regolamentodidattico(update: Update, context: CallbackContext):
    """Called by the /regolamentodidattico command.
    Shows a menu from with the user can choose between (triennale | magistrale)

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "regolamentodidattico")
    update.message.reply_text('Scegliere uno dei seguenti corsi:',
                              reply_markup=get_reg_keyboard())
Ejemplo n.º 14
0
def md_handler(update: Update, context: CallbackContext):
    query = update.callback_query

    data = query.data.replace("md_", "")

    message_text = read_md(data)
    check_log(update, context, data, 1)

    context.bot.editMessageText(text=message_text,
                                chat_id=query.message.chat_id,
                                message_id=query.message.message_id,
                                parse_mode='Markdown')
Ejemplo n.º 15
0
def git(update: Update, context: CallbackContext):
    check_log(update, "gitlab")

    chat_id = update.message.chat_id
    executed_command = update.message.text.split(' ')[0]

    if chat_id < 0:
        context.bot.sendMessage(
            chat_id=chat_id,
            text="�� La funzione %s non è ammessa nei gruppi" %
            executed_command)
    else:
        gitlab_handler(update, context)
Ejemplo n.º 16
0
def informative_callback(update: Update, context: CallbackContext):
    # controllo per poter gestire i comandi (/comando) e i messaggi inviati premendo i bottoni (❔ Help)
    if update.message.text[0] == '/':
        cmd = update.message.text.split(' ')[0][
            1:]  #prende solo la prima parola del messaggio (cioè il comando) escludendo lo slash
    else:
        cmd = update.message.text.split(
            ' ')[1].lower()  # prende la prima parola dopo l'emoji
    check_log(update, context, cmd)
    message_text = read_md(cmd)
    context.bot.sendMessage(chat_id=update.message.chat_id,
                            text=message_text,
                            parse_mode='Markdown')
Ejemplo n.º 17
0
def report(update: Update, context: CallbackContext):
    """Called by the /report command.
    Use: /report <word> ...
    Allows the user to report something to the administrators

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "report")
    chat_id = update.message.chat_id
    chat_user = update.message.from_user
    executed_command = update.message.text.split(' ')[0]

    if chat_id < 0:
        context.bot.sendMessage(
            chat_id=chat_id,
            text=f"! La funzione {executed_command} non è ammessa nei gruppi")
    elif not chat_user.username:
        context.bot.sendMessage(
            chat_id=chat_id,
            text=
            f"La funzione {executed_command} non è ammessa se non si dispone di un username."
        )
    else:
        if context.args:
            message = "⚠️Segnalazione⚠️\n"\
                        f"Username: @{chat_user.username}\n"

            if chat_user.first_name is not None:
                message += f"Nome: {chat_user.first_name}\n"
            if chat_user.last_name is not None:
                message += f"Cognome: {chat_user.last_name}\n"

            message += f"Segnalazione: {' '.join(context.args)}\n"

            context.bot.sendMessage(
                chat_id=config_map['representatives_group'], text=message)
            context.bot.sendMessage(
                chat_id=chat_id,
                text=f"Resoconto segnalazione: \n{message}"
                "\n Grazie per la segnalazione, un rappresentante ti contatterà nel minor tempo possibile."
            )
        else:
            context.bot.sendMessage(
                chat_id=chat_id,
                text=
                "Errore. Inserisci la tua segnalazione dopo /report (Ad esempio /report Invasione ingegneri in corso.)"
            )
Ejemplo n.º 18
0
def prof(update: Update, context: CallbackContext):
    """Called by the /prof command.
    Use: /prof <nomeprofessore> ...
    Shows all the professors that match the request

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "prof")
    message_text = generate_prof_text(context.args)
    if len(message_text) > 4096:
        send_message(update, context, message_text)
    else:
        context.bot.sendMessage(chat_id=update.message.chat_id, text=message_text, parse_mode='Markdown')
Ejemplo n.º 19
0
def drive(update: Update, context: CallbackContext):
    check_log(update, context, "drive")
    conn = sqlite3.connect('data/DMI_DB.db')

    settings_file = "config/settings.yaml"
    gauth = GoogleAuth(settings_file=settings_file)
    gauth.CommandLineAuth()
    # gauth.LocalWebserverAuth()
    drive = GoogleDrive(gauth)
    chat_id = update.message.chat_id
    id_drive = '0B7-Gi4nb88hremEzWnh3QmN3ZlU'
    if chat_id < 0:
        context.bot.sendMessage(chat_id=chat_id, text="La funzione /drive non è ammessa nei gruppi")
    else:
        if conn.execute("SELECT Chat_id FROM 'Chat_id_List' WHERE Chat_id = " + str(chat_id)).fetchone():
            keyboard2 = [[]]

            try:
                file_list = drive.ListFile({'q': "'" + id_drive + "' in parents and trashed=false", 'orderBy': 'folder,title'}).GetList()
            except Exception as error:
                print (str(error))

            number_row = 0
            number_array = 0

            for file1 in file_list:
                if file1['mimeType'] == "application/vnd.google-apps.folder":
                    if number_row >= 3:
                        keyboard2.append([InlineKeyboardButton("🗂 "+file1['title'], callback_data="Drive_" + file1['id'])])
                        number_row = 0
                        number_array += 1
                    else:
                        keyboard2[number_array].append(InlineKeyboardButton("🗂 "+file1['title'], callback_data="Drive_" + file1['id']))
                        number_row += 1
                else:
                    if number_row >= 3:
                        keyboard2.append([InlineKeyboardButton("📃 "+file1['title'], callback_data="Drive_" + file1['id'])])
                        number_row = 0
                        number_array += 1
                    else:
                        keyboard2[number_array].append(InlineKeyboardButton("📃 "+file1['title'], callback_data="Drive_" + file1['id']))
                        number_row += 1

            reply_markup3 = InlineKeyboardMarkup(keyboard2)
            context.bot.sendMessage(chat_id=chat_id, text="DMI UNICT - Appunti & Risorse:", reply_markup=reply_markup3)
        else:
            context.bot.sendMessage(chat_id=chat_id, text="🔒 Non hai i permessi per utilizzare la funzione /drive,\n Utilizzare il comando /request <nome> <cognome> <e-mail> (il nome e il cognome devono essere scritti uniti Es: Di mauro -> Dimauro) ")
    conn.close()
Ejemplo n.º 20
0
def md_handler(update: Update, context: CallbackContext):
    query = update.callback_query

    data = query.data.replace("md_", "")
    message_text = read_md(data)

    if data == "help":
        message_text = message_text.replace("<cusicon>",
                                            CUSicon[random.randint(0, 5)])

    check_log(update, context, data, 1)

    context.bot.editMessageText(text=message_text,
                                chat_id=query.message.chat_id,
                                message_id=query.message.message_id,
                                parse_mode=ParseMode.MARKDOWN)
Ejemplo n.º 21
0
def report(update: Update, context: CallbackContext):
    check_log(update, context, "report")
    chat_id = update.message.chat_id
    chat_user = update.message.from_user
    executed_command = update.message.text.split(' ')[0]

    if chat_id < 0:
        context.bot.sendMessage(
            chat_id=chat_id,
            text="! La funzione %s non è ammessa nei gruppi" %
            executed_command)
    elif not chat_user.username:
        context.bot.sendMessage(
            chat_id=chat_id,
            text=
            "La funzione %s non è ammessa se non si dispone di un username." %
            executed_command)
    else:
        if context.args:
            message = "⚠️Segnalazione⚠️\n"

            if chat_user.username is not None:
                message += "Username: @" + chat_user.username + "\n"

            if chat_user.first_name is not None:
                message += "Nome: " + chat_user.first_name + "\n"

            if chat_user.last_name is not None:
                message += "Cognome: " + chat_user.last_name + "\n"

            message += "Segnalazione: " + " ".join(context.args) + "\n"

            context.bot.sendMessage(
                chat_id=config_map['representatives_group'], text=message)
            context.bot.sendMessage(
                chat_id=chat_id,
                text="Resoconto segnalazione: \n" + message +
                "\n Grazie per la segnalazione, un rappresentante ti contatterà nel minor tempo possibile."
            )

        else:
            context.bot.sendMessage(
                chat_id=chat_id,
                text=
                "Errore. Inserisci la tua segnalazione dopo /report (Ad esempio /report Invasione ingegneri in corso.)"
            )
Ejemplo n.º 22
0
def informative_callback(update: Update, context: CallbackContext):
    """Called by any command that needs to show information to the user

    Args:
        update: update event
        context: context passed by the handler
    """
    # controllo per poter gestire i comandi (/comando) e i messaggi inviati premendo i bottoni (❔ Help)
    if update.message.text[0] == '/':
        cmd = update.message.text.split(' ')[0][
            1:]  #prende solo la prima parola del messaggio (cioè il comando) escludendo lo slash
    else:
        cmd = update.message.text.split(
            ' ')[1].lower()  # prende la prima parola dopo l'emoji
    check_log(update, cmd)
    message_text = read_md(cmd)
    context.bot.sendMessage(chat_id=update.message.chat_id,
                            text=message_text,
                            parse_mode=ParseMode.MARKDOWN)
Ejemplo n.º 23
0
def esami_input_insegnamento(update: Update, context: CallbackContext):
    """Called after :func:`esami_button_insegnamento`.
    Allows the user to input the wanted subject, in the format [Ii]ns: <insegnamento>

    Args:
        update: update event
        context: context passed by the handler
    """
    if context.user_data['esami'].get('cmd', None) == "input_insegnamento":
        #se effettivamente l'user aveva richiesto di modificare l'insegnamento...
        check_log(update, "esami_input_insegnamento")
        #ottieni il nome dell'insegnamento e salvalo nel dict
        context.user_data['esami']['insegnamento'] = re.sub(
            r"^(?!=<[/])[Ii]ns:\s+", "", update.message.text)
        #elimina la possibilità di modificare l'insegnamento fino a quando l'apposito button non viene premuto di nuovo
        del context.user_data['esami']['cmd']
        message_text, inline_keyboard = get_esami_text_inline_keyboard(context)
        context.bot.sendMessage(chat_id=update.message.chat_id,
                                text=message_text,
                                reply_markup=inline_keyboard)
Ejemplo n.º 24
0
def md_handler(update: Update, context: CallbackContext):
    """Called by any query that needs to show the contents of a markdown file to the user

    Args:
        update: update event
        context: context passed by the handler
    """
    query = update.callback_query

    data = query.data.replace("md_", "")
    message_text = read_md(data)

    if data == "help":
        message_text = message_text.replace("<cusicon>",
                                            CUSicon[random.randint(0, 5)])

    check_log(update, data, is_query=True)

    context.bot.editMessageText(text=message_text,
                                chat_id=query.message.chat_id,
                                message_id=query.message.message_id,
                                parse_mode=ParseMode.MARKDOWN)
Ejemplo n.º 25
0
def help_cmd(update: Update, context: CallbackContext):
    """Called by the /help command.
    Shows all the actions supported by the bot

    Args:
        update: update event
        context: context passed by the handler
    """
    check_log(update, "help")
    chat_id = update.message.chat_id

    message_text = "@DMI_Bot risponde ai seguenti comandi:"

    keyboard = [[]]
    keyboard.append([
        InlineKeyboardButton(" ~ Dipartimento e CdL ~ ", callback_data="NONE")
    ])

    keyboard.append([
        InlineKeyboardButton("📖 Esami (link)", callback_data="md_esami_link"),
        InlineKeyboardButton(AULARIO, callback_data="sm_aulario"),
    ])

    keyboard.append([
        InlineKeyboardButton("📘 Orari lezioni (link)",
                             callback_data="md_lezioni_link"),
        InlineKeyboardButton("👨‍🏫 Info Professori",
                             callback_data="md_professori")
    ])

    keyboard.append([
        InlineKeyboardButton("Regolamento Didattico",
                             callback_data="regolamentodidattico_button")
    ])

    keyboard.append([
        InlineKeyboardButton("👥 Rappresentanti", callback_data="sm_rapp_menu"),
        InlineKeyboardButton("📚 Biblioteca", callback_data="md_biblioteca"),
        InlineKeyboardButton("📊 Gruppi", callback_data="md_gruppi"),
    ])

    keyboard.append([
        InlineKeyboardButton(CUSicon[random.randint(0, 5)] + " CUS",
                             callback_data="md_cus"),
        InlineKeyboardButton(CLOUD, callback_data="md_cloud")
    ])

    keyboard.append([
        InlineKeyboardButton(" ~ Segreteria orari e contatti ~ ",
                             callback_data="NONE")
    ])

    keyboard.append([
        InlineKeyboardButton("Seg. Didattica", callback_data="md_sdidattica"),
        InlineKeyboardButton("Seg. Studenti", callback_data="md_studenti"),
        InlineKeyboardButton("CEA", callback_data="md_cea")
    ])

    keyboard.append([
        InlineKeyboardButton(" ~ ERSU orari e contatti ~ ",
                             callback_data="NONE")
    ])

    keyboard.append([
        InlineKeyboardButton("ERSU", callback_data="md_ersu"),
        InlineKeyboardButton("Ufficio ERSU", callback_data="md_ufficioersu"),
        InlineKeyboardButton("URP", callback_data="md_urp")
    ])

    keyboard.append(
        [InlineKeyboardButton(" ~ Bot e varie ~ ", callback_data="NONE")])

    keyboard.append([
        InlineKeyboardButton("📂 Drive", callback_data="md_drive"),
        InlineKeyboardButton("📂 GitLab", callback_data="md_gitlab")
    ])

    keyboard.append([
        InlineKeyboardButton(" ~ Progetti e Riconoscimenti ~ ",
                             callback_data="NONE")
    ])

    keyboard.append([
        InlineKeyboardButton("📈 Opis Manager", callback_data="md_opismanager"),
        InlineKeyboardButton("Contributors", callback_data="md_contributors")
    ])

    keyboard.append([
        InlineKeyboardButton("Tutti i comandi", callback_data="md_help"),
        InlineKeyboardButton("Chiudi", callback_data="exit_cmd")
    ])

    reply_markup = InlineKeyboardMarkup(keyboard)

    context.bot.sendMessage(chat_id=chat_id,
                            text=message_text,
                            reply_markup=reply_markup)
Ejemplo n.º 26
0
def lezioni(update: Update, context: CallbackContext, *m):
    check_log(update, context, "lezioni")
    message_text = lezioni_cmd(update, context, context.args)
    context.bot.sendMessage(chat_id=update.message.chat_id,
                            text=message_text,
                            parse_mode='Markdown')
Ejemplo n.º 27
0
def help(update: Update, context: CallbackContext):
    check_log(update, context, "help")
    chat_id = update.message.chat_id
    keyboard = [[]]
    message_text = "@DMI_Bot risponde ai seguenti comandi:"

    keyboard.append([
        InlineKeyboardButton(" ~ Dipartimento e CdL ~ ", callback_data="_div")
    ])

    keyboard.append([
        InlineKeyboardButton("📖 Esami (Triennale)",
                             url='http://dev7.unict.it/_esami.php?cds=X81'),
        InlineKeyboardButton("📖 Esami (Magistrale)",
                             url='http://dev7.unict.it/_esami.php?cds=W82'),
        InlineKeyboardButton(
            "🗓 Aulario",
            url='http://aule.dmi.unict.it/aulario/roschedule.php'),
        InlineKeyboardButton(
            "Lezioni", url='http://web.dmi.unict.it/corsi/l-31/orario-lezioni')
    ])

    keyboard.append([
        InlineKeyboardButton("Regolamento Didattico",
                             callback_data="regolamentodidattico_button")
    ])

    keyboard.append([
        InlineKeyboardButton("👥 Rappresentanti", callback_data="sm_rapp_menu"),
        InlineKeyboardButton("📚 Biblioteca", callback_data="md_biblioteca"),
        InlineKeyboardButton(CUSicon[random.randint(0, 5)] + " CUS",
                             callback_data="md_cus"),
        InlineKeyboardButton("☁️ Cloud", callback_data="md_cloud")
    ])

    keyboard.append([
        InlineKeyboardButton(" ~ Segreteria orari e contatti ~ ",
                             callback_data="_div")
    ])

    keyboard.append([
        InlineKeyboardButton("Seg. Didattica", callback_data="md_sdidattica"),
        InlineKeyboardButton("Seg. Studenti", callback_data="md_sstudenti"),
        InlineKeyboardButton("CEA", callback_data="md_cea")
    ])

    keyboard.append([
        InlineKeyboardButton(" ~ ERSU orari e contatti ~ ",
                             callback_data="_div")
    ])

    keyboard.append([
        InlineKeyboardButton("ERSU", callback_data="md_ersu"),
        InlineKeyboardButton("Ufficio ERSU", callback_data="md_ufficioersu"),
        InlineKeyboardButton("URP", callback_data="md_urp")
    ])

    keyboard.append(
        [InlineKeyboardButton(" ~ Bot e varie ~ ", callback_data="_div")])

    keyboard.append([
        InlineKeyboardButton("📂 Drive", callback_data="md_drive"),
        InlineKeyboardButton("📂 GitLab", callback_data="md_gitlab"),
        InlineKeyboardButton("Contributors", callback_data="md_contributors"),
    ])

    keyboard.append([
        InlineKeyboardButton("Tutti i comandi", callback_data="help_cmd"),
        InlineKeyboardButton("Chiudi", callback_data="exit_cmd")
    ])

    reply_markup = InlineKeyboardMarkup(keyboard)

    context.bot.sendMessage(chat_id=chat_id,
                            text=message_text,
                            reply_markup=reply_markup)
Ejemplo n.º 28
0
def informative_callback(update: Update, context: CallbackContext, cmd):
    check_log(update, context, cmd)
    message_text = read_md(cmd)
    context.bot.sendMessage(chat_id=update.message.chat_id,
                            text=message_text,
                            parse_mode='Markdown')
Ejemplo n.º 29
0
def smonta_portoni(update: Update, context: CallbackContext):
    check_log(update, context, "smonta_portoni")
    message_text = EasterEgg.get_smonta_portoni()
    context.bot.sendMessage(chat_id=update.message.chat_id, text=message_text)
Ejemplo n.º 30
0
def lei_che_ne_pensa_signorina(update: Update, context: CallbackContext):
    check_log(update, context, "leiCheNePensaSignorina")
    message_text = EasterEgg.get_lei_che_ne_pensa_signorina()
    context.bot.sendMessage(chat_id=update.message.chat_id, text=message_text)