(ctx: CreateRuntimeContext)
| 22 | pub mod limits; |
| 23 | |
| 24 | pub fn create_extensions(ctx: CreateRuntimeContext) -> Vec<Extension> { |
| 25 | let mut http_client_builder: reqwest::ClientBuilder = reqwest::ClientBuilder::new(); |
| 26 | if let Some(proxy_addr) = &ctx.script_http_client_proxy { |
| 27 | info!("using http client proxy: {}", proxy_addr); |
| 28 | let proxy = reqwest::Proxy::all(proxy_addr).expect("valid http proxy address"); |
| 29 | http_client_builder = http_client_builder.proxy(proxy); |
| 30 | } else { |
| 31 | #[cfg(not(debug_assertions))] |
| 32 | tracing::warn!("no proxy set in release!"); |
| 33 | } |
| 34 | |
| 35 | let http_client = http_client_builder.build().expect("valid http client"); |
| 36 | let premium_tier = *ctx.premium_tier.read().unwrap(); |
| 37 | let core_ctx = CoreRuntimeContext { |
| 38 | event_tx: ctx.event_tx.clone(), |
| 39 | settings_values: ctx.settings_values, |
| 40 | }; |
| 41 | |
| 42 | if let Some(guild_id) = ctx.guild_id { |
| 43 | let rt_ctx = RuntimeContext { |
| 44 | guild_id, |
| 45 | bot_state: ctx.bot_state.clone(), |
| 46 | discord_config: ctx.discord_config.clone(), |
| 47 | guild_logger: ctx.guild_logger.clone(), |
| 48 | script_http_client_proxy: ctx.script_http_client_proxy.clone(), |
| 49 | event_tx: ctx.event_tx.clone(), |
| 50 | premium_tier, |
| 51 | main_tokio_runtime: ctx.main_tokio_runtime, |
| 52 | |
| 53 | db: ctx.db, |
| 54 | }; |
| 55 | |
| 56 | vec![ |
| 57 | bl_script_core::init_ops_and_esm(core_ctx, rt_ctx, http_client, premium_tier), |
| 58 | extensions::storage::bl_storage::init_ops_and_esm(), |
| 59 | extensions::base64::bl_base64::init_ops_and_esm(), |
| 60 | extensions::discord::bl_discord::init_ops_and_esm(), |
| 61 | extensions::console::bl_console::init_ops_and_esm(), |
| 62 | extensions::httpclient::bl_http::init_ops_and_esm(), |
| 63 | extensions::tasks::bl_tasks::init_ops_and_esm(), |
| 64 | extensions::image::bl_image::init_ops_and_esm(), |
| 65 | ] |
| 66 | } else { |
| 67 | vec![ |
| 68 | bl_script_core_no_guild::init_ops_and_esm(core_ctx, http_client, premium_tier), |
| 69 | extensions::storage::bl_storage::init_ops_and_esm(), |
| 70 | extensions::base64::bl_base64::init_ops_and_esm(), |
| 71 | extensions::discord::bl_discord::init_ops_and_esm(), |
| 72 | extensions::console::bl_console::init_ops_and_esm(), |
| 73 | extensions::httpclient::bl_http::init_ops_and_esm(), |
| 74 | extensions::tasks::bl_tasks::init_ops_and_esm(), |
| 75 | extensions::image::bl_image::init_ops_and_esm(), |
| 76 | ] |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | deno_core::extension!( |
| 81 | bl_script_core, |
no test coverage detected