diff --git a/README.md b/README.md index 5885486..71f685f 100644 --- a/README.md +++ b/README.md @@ -143,16 +143,17 @@ To skip the build, just download `Doplarr.jar` and `config.edn` from the release ### Optional Settings -| Environment Variable (Docker) | Config File Keyword | Type | Default Value | Description | -| ----------------------------- | -------------------------- | ------- | ------------- | --------------------------------------------------------------------------------------------------- | -| `DISCORD__MAX_RESULTS` | `:discord/max-results` | Integer | `25` | Sets the maximum size of the search results selection | -| `DISCORD__ROLE_ID` | `:discord/role-id` | Long | N/A | The discord role id for users of the bot (omitting this lets everyone on the server use the bot) | -| `SONARR__QUALITY_PROFILE` | `:sonarr/quality-profile` | String | N/A | The name of the quality profile to use by default for Sonarr | -| `RADARR__QUALITY_PROFILE` | `:radarr/quality-profile` | String | N/A | The name of the quality profile to use by default for Radarr | -| `SONARR__LANGUAGE_PROFILE` | `:sonarr/language-profile` | String | N/A | The name of the language profile to use by default for Radarr | -| `OVERSEERR__DEFAULT_ID` | `:overseerr/default-id` | Integer | N/A | The Overseerr user id to use by default if there is no associated discord account for the requester | -| `PARTIAL_SEASONS` | `:partial-seasons` | Boolean | `true` | Sets whether users can request partial seasons. | -| `LOG_LEVEL` | `:log-level` | Keyword | `:info` | The log level for the logging backend. This can be changed for debugging purposes. | +| Environment Variable (Docker) | Config File Keyword | Type | Default Value | Description | +| ------------------------------ | ------------------------------ | ------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | +| `DISCORD__MAX_RESULTS` | `:discord/max-results` | Integer | `25` | Sets the maximum size of the search results selection | +| `DISCORD__ROLE_ID` | `:discord/role-id` | Long | N/A | The discord role id for users of the bot (omitting this lets everyone on the server use the bot) | +| `DISCORD__REQUESTED_MSG_STYLE` | `:discord/requested-msg-style` | Keyword | `:plain` | Sets the style of the request alert message. One of `:plain :embed :none` | +| `SONARR__QUALITY_PROFILE` | `:sonarr/quality-profile` | String | N/A | The name of the quality profile to use by default for Sonarr | +| `RADARR__QUALITY_PROFILE` | `:radarr/quality-profile` | String | N/A | The name of the quality profile to use by default for Radarr | +| `SONARR__LANGUAGE_PROFILE` | `:sonarr/language-profile` | String | N/A | The name of the language profile to use by default for Radarr | +| `OVERSEERR__DEFAULT_ID` | `:overseerr/default-id` | Integer | N/A | The Overseerr user id to use by default if there is no associated discord account for the requester | +| `PARTIAL_SEASONS` | `:partial-seasons` | Boolean | `true` | Sets whether users can request partial seasons. | +| `LOG_LEVEL` | `:log-level` | Keyword | `:info` | The log level for the logging backend. This can be changed for debugging purposes. One of `trace :debug :info :warn :error :fatal :report` | ### Setting up on Windows diff --git a/src/doplarr/config.clj b/src/doplarr/config.clj index bc37b50..b07aab3 100644 --- a/src/doplarr/config.clj +++ b/src/doplarr/config.clj @@ -25,6 +25,7 @@ :discord/token :discord/role-id :discord/max-results + :discord/requested-msg-style ; Doplarr :partial-seasons :log-level}) diff --git a/src/doplarr/config/specs.clj b/src/doplarr/config/specs.clj index 1c50d57..c2aa71c 100644 --- a/src/doplarr/config/specs.clj +++ b/src/doplarr/config/specs.clj @@ -19,6 +19,7 @@ ; --- Optional settings (spec/def :discord/role-id pos-int?) (spec/def :discord/max-results (spec/int-in 1 26)) +(spec/def :discord/requested-msg-style #{:none :plain :embed}) ; Radarr optionals (spec/def :radarr/quality-profile string?) @@ -51,6 +52,7 @@ If you have configured one, make sure to check spelling. A valid configuration c (spec/keys :req [:discord/token] :opt [:discord/role-id :discord/max-results + :discord/requested-msg-style :radarr/quality-profile :sonarr/quality-profile :sonarr/language-profile diff --git a/src/doplarr/discord.clj b/src/doplarr/discord.clj index 05e918d..93f13b8 100644 --- a/src/doplarr/discord.clj +++ b/src/doplarr/discord.clj @@ -138,6 +138,16 @@ :components [{:type 1 :components (for [format (:request-formats embed-data)] (request-button format uuid))}]}) +(defn request-performed-plain [payload media-type user-id] + {:content + (str "<@" user-id "> has requested the " + (name media-type) " `" (:title payload) " (" (:year payload) ")" + "` and it should be available soon!")}) + +(defn request-performed-embed [embed-data user-id] + {:content (str "<@" user-id "> has requested:") + :embeds [(request-embed embed-data)]}) + ;; Discljord Utilities (defn register-commands [media-types bot-id messaging guild-id] (->> @(m/bulk-overwrite-guild-application-commands! diff --git a/src/doplarr/interaction_state_machine.clj b/src/doplarr/interaction_state_machine.clj index f138793..b4a00d6 100644 --- a/src/doplarr/interaction_state_machine.clj +++ b/src/doplarr/interaction_state_machine.clj @@ -48,6 +48,7 @@ (let [embed (log-on-error (a/> @(m/edit-original-interaction-response! messaging bot-id token (discord/request embed uuid)) (else #(fatal % "Error in sending request embed")))) (let [[op options] (first pending-opts)] @@ -92,7 +93,7 @@ (defmethod process-event! "request" [_ interaction uuid format] (let [{:keys [messaging bot-id]} @state/discord - {:keys [payload media-type token]} (get @state/cache uuid) + {:keys [payload media-type token embed]} (get @state/cache uuid) {:keys [user-id channel-id]} interaction] (letfn [(msg-resp [msg] (->> @(m/edit-original-interaction-response! messaging bot-id token (discord/content-response msg)) (else #(fatal % "Error in message response"))))] @@ -109,12 +110,10 @@ :available (msg-resp "This selection is already available!") (do (info "Performing request for " payload) - (m/create-message! messaging channel-id - :content - (str "<@" user-id "> has requested the " - (name media-type) " `" (:title payload) " (" (:year payload) ")" - "` and it should be available soon!")) - (msg-resp "Request performed!"))))) + (msg-resp "Request performed!") + (case (:discord/requested-msg-style @state/config) + :plain (m/create-message! messaging channel-id (discord/request-performed-plain payload media-type user-id)) + :embed (m/create-message! messaging channel-id (discord/request-performed-embed embed user-id))))))) (else (fn [e] (let [{:keys [status body] :as data} (ex-data e)] (if (= status 403)