示例#1
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()
示例#2
0
def button_handler(bot, update):
    query = update.callback_query
    chat_id = query.message.chat_id
    message_id = query.message.message_id
    data = query.data

    # Submenu
    if data.startswith("sm_"):
        func_name = data[3:len(data)]
        globals()[func_name](bot, chat_id, message_id)

    elif data == "esami_button" or data == "lezioni_button" or data == "help_cmd" or data == "exit_cmd":
        message_text = globals()[data]()
        bot.editMessageText(
            text=message_text, chat_id=chat_id, message_id=message_id)

    elif data.startswith("Drive_"):
        callback(bot, update)

    elif data.startswith('git_'):
        gitlab_handler(bot, update, data.replace('git_', ''))

    elif (data == "mensa_help"):
        mensa_cmd(bot, update.callback_query)

    elif data.startswith("mensa_weekend"):
        mensa_weekend(bot, update)

    elif data.startswith("mensa_"):
        mensa_subscription(bot, update)

    elif data == "enablenews" or data == "disablenews":
        globals()[data](bot, query)

    # Simple text
    elif data != "_div":
        message_text = read_md(data)
        check_log(bot, update, data, 1)
        bot.editMessageText(
            text=message_text, chat_id=chat_id, message_id=message_id)