use http client from context

This commit is contained in:
seth 2024-04-26 20:53:13 -04:00
parent 921540e249
commit 84a7cfe151
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
26 changed files with 148 additions and 149 deletions

View file

@ -23,7 +23,8 @@ pub async fn handle(
FullEvent::Ready { data_about_bot } => {
info!("Logged in as {}!", data_about_bot.user.name);
let latest_minecraft_version = api::prism_meta::latest_minecraft_version().await?;
let latest_minecraft_version =
api::prism_meta::latest_minecraft_version(&data.http_client).await?;
let activity = ActivityData::playing(format!("Minecraft {latest_minecraft_version}"));
info!("Setting presence to activity {activity:#?}");
@ -37,7 +38,7 @@ pub async fn handle(
}
FullEvent::Message { new_message } => {
trace!("Recieved message {}", new_message.content);
trace!("Received message {}", new_message.content);
// ignore new messages from bots
// note: the webhook_id check allows us to still respond to PK users
@ -49,11 +50,12 @@ pub async fn handle(
}
if let Some(storage) = &data.storage {
let http = &data.http_client;
// detect PK users first to make sure we don't respond to unproxied messages
pluralkit::handle(ctx, new_message, storage).await?;
pluralkit::handle(ctx, http, storage, new_message).await?;
if storage.is_user_plural(new_message.author.id).await?
&& pluralkit::is_message_proxied(new_message).await?
&& pluralkit::is_message_proxied(http, new_message).await?
{
debug!("Not replying to unproxied PluralKit message");
return Ok(());
@ -61,13 +63,13 @@ pub async fn handle(
}
eta::handle(ctx, new_message).await?;
expand_link::handle(ctx, new_message).await?;
expand_link::handle(ctx, &data.http_client, new_message).await?;
analyze_logs::handle(ctx, new_message, data).await?;
}
FullEvent::ReactionAdd { add_reaction } => {
trace!(
"Recieved reaction {} on message {} from {}",
"Received reaction {} on message {} from {}",
add_reaction.emoji,
add_reaction.message_id.to_string(),
add_reaction.user_id.unwrap_or_default().to_string()
@ -78,7 +80,7 @@ pub async fn handle(
}
FullEvent::ThreadCreate { thread } => {
trace!("Recieved thread {}", thread.id);
trace!("Received thread {}", thread.id);
support_onboard::handle(ctx, thread).await?;
}