예제 #1
0
def sabnzbd(update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    if not config["enable"]:
        context.bot.send_message(
            chat_id=update.effective_message.chat_id,
            text=i18n.t("addarr.Sabnzbd.NotEnabled"),
        )
        return ConversationHandler.END

    if not checkId(update):
        context.bot.send_message(chat_id=update.effective_message.chat_id,
                                 text=i18n.t("addarr.Authorize"))
        return SABNZBD_SPEED_LIMIT_100

    if config["onlyAdmin"] and not checkAllowed(update, "admin"):
        context.bot.send_message(
            chat_id=update.effective_message.chat_id,
            text=i18n.t("addarr.NotAdmin"),
        )
        return SABNZBD_SPEED_LIMIT_100

    keyboard = [[
        InlineKeyboardButton('\U0001F40C ' + i18n.t("addarr.Sabnzbd.Limit25"),
                             callback_data=SABNZBD_SPEED_LIMIT_25),
        InlineKeyboardButton('\U0001F40E ' + i18n.t("addarr.Sabnzbd.Limit50"),
                             callback_data=SABNZBD_SPEED_LIMIT_50),
        InlineKeyboardButton('\U0001F406 ' + i18n.t("addarr.Sabnzbd.Limit100"),
                             callback_data=SABNZBD_SPEED_LIMIT_100),
    ]]
    markup = InlineKeyboardMarkup(keyboard)
    update.message.reply_text(i18n.t("addarr.Sabnzbd.Speed"),
                              reply_markup=markup)
    return SABNZBD_SPEED_LIMIT_100
예제 #2
0
def transmission(update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    if not config["enable"]:
        context.bot.send_message(
            chat_id=update.effective_message.chat_id,
            text=i18n.t("addarr.Transmission.NotEnabled"),
        )
        return ConversationHandler.END

    if not checkId(update):
        context.bot.send_message(chat_id=update.effective_message.chat_id,
                                 text=i18n.t("addarr.Authorize"))
        return TSL_NORMAL

    if config["onlyAdmin"] and not checkAllowed(update, "admin"):
        context.bot.send_message(
            chat_id=update.effective_message.chat_id,
            text=i18n.t("addarr.NotAdmin"),
        )
        return TSL_NORMAL

    keyboard = [[
        InlineKeyboardButton('\U0001F40C ' + i18n.t("addarr.Transmission.TSL"),
                             callback_data=TSL_LIMIT),
        InlineKeyboardButton('\U0001F406 ' +
                             i18n.t("addarr.Transmission.Normal"),
                             callback_data=TSL_NORMAL),
    ]]
    markup = InlineKeyboardMarkup(keyboard)
    update.message.reply_text(i18n.t("addarr.Transmission.Speed"),
                              reply_markup=markup)
    return TSL_NORMAL
예제 #3
0
def allMovies(update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    if radarr.config.get("adminRestrictions") and not checkAllowed(
            update, "admin"):
        context.bot.send_message(
            chat_id=update.effective_message.chat_id,
            text=i18n.t("addarr.NotAdmin"),
        )
        return ConversationHandler.END

    if not checkId(update):
        if (authentication(
                update,
                context) == "added"):  # To also stop the beginning command
            return ConversationHandler.END
    else:
        result = radarr.all_movies()
        content = format_long_list_message(result)

        if isinstance(content, str):
            context.bot.send_message(
                chat_id=update.effective_message.chat_id,
                text=content,
            )
        else:
            # print every substring
            for subString in content:
                context.bot.send_message(
                    chat_id=update.effective_message.chat_id,
                    text=subString,
                )
        return ConversationHandler.END
예제 #4
0
def stop(update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    if not checkId(update):
        context.bot.send_message(chat_id=update.effective_message.chat_id,
                                 text=i18n.t("addarr.Authorize"))
        return SERIE_MOVIE_AUTHENTICATED

    clearUserData(context)
    context.bot.send_message(chat_id=update.effective_message.chat_id,
                             text=i18n.t("addarr.End"))
    return ConversationHandler.END
예제 #5
0
def startSerieMovie(update: Update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    if not checkId(update):
        context.bot.send_message(chat_id=update.effective_message.chat_id,
                                 text=i18n.t("addarr.Authorize"))
        return SERIE_MOVIE_AUTHENTICATED

    if update.message is not None:
        reply = update.message.text.lower()
    elif update.callback_query is not None:
        reply = update.callback_query.data.lower()
    else:
        return SERIE_MOVIE_AUTHENTICATED

    if reply[1:] in [
            i18n.t("addarr.Series").lower(),
            i18n.t("addarr.Movie").lower(),
    ]:
        logger.debug(
            f"User issued {reply} command, so setting user_data[choice] accordingly"
        )
        context.user_data.update({
            "choice":
            i18n.t("addarr.Series") if reply[1:]
            == i18n.t("addarr.Series").lower() else i18n.t("addarr.Movie")
        })
    elif reply == i18n.t("addarr.New").lower():
        logger.debug("User issued New command, so clearing user_data")
        clearUserData(context)

    msg = context.bot.send_message(chat_id=update.effective_message.chat_id,
                                   text='\U0001F3F7 ' + i18n.t("addarr.Title"))
    return SERIE_MOVIE_AUTHENTICATED
예제 #6
0
def help(update, context):
    if config.get("enableAllowlist") and not checkAllowed(update, "regular"):
        #When using this mode, bot will remain silent if user is not in the allowlist.txt
        logger.info(
            "Allowlist is enabled, but userID isn't added into 'allowlist.txt'. So bot stays silent"
        )
        return ConversationHandler.END

    context.bot.send_message(chat_id=update.effective_message.chat_id,
                             text=i18n.t(
                                 "addarr.Help",
                                 help=config["entrypointHelp"],
                                 authenticate=config["entrypointAuth"],
                                 add=config["entrypointAdd"],
                                 delete=config["entrypointDelete"],
                                 serie='serie',
                                 movie='movie',
                                 allSeries=config["entrypointAllSeries"],
                                 allMovies=config["entrypointAllMovies"],
                                 transmission=config["entrypointTransmission"],
                                 sabnzbd=config["entrypointSabnzbd"],
                             ))
    return ConversationHandler.END