log more actions + tidy up things

This commit is contained in:
seth 2024-03-03 18:32:44 -05:00
parent 651f14d724
commit 915ef54dc3
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
14 changed files with 56 additions and 19 deletions

View file

@ -1,4 +1,5 @@
use eyre::{Context as _, Result};
use log::trace;
use poise::serenity_prelude::{Context, InteractionType, Reaction};
pub async fn handle(ctx: &Context, reaction: &Reaction) -> Result<()> {
@ -17,6 +18,7 @@ pub async fn handle(ctx: &Context, reaction: &Reaction) -> Result<()> {
&& interaction.user == user
&& reaction.emoji.unicode_eq("")
{
trace!("Deleting our own message at the request of {}", user.tag());
message.delete(ctx).await?;
}
}

View file

@ -1,4 +1,5 @@
use eyre::Result;
use log::trace;
use once_cell::sync::Lazy;
use poise::serenity_prelude::{Context, Message};
use rand::seq::SliceRandom;
@ -6,7 +7,7 @@ use regex::Regex;
static ETA_REGEX: Lazy<Regex> = Lazy::new(|| Regex::new(r"\beta\b").unwrap());
pub const ETA_MESSAGES: [&str; 16] = [
const ETA_MESSAGES: [&str; 16] = [
"Sometime",
"Some day",
"Not far",
@ -27,6 +28,7 @@ pub const ETA_MESSAGES: [&str; 16] = [
pub async fn handle(ctx: &Context, message: &Message) -> Result<()> {
if !ETA_REGEX.is_match(&message.content) {
trace!("The message '{}' (probably) doesn't say ETA", message.content);
return Ok(());
}

View file

@ -2,14 +2,14 @@ use crate::{api, Data};
use std::time::Duration;
use eyre::Result;
use log::{debug, trace};
use log::trace;
use poise::serenity_prelude::{Context, Message};
use tokio::time::sleep;
const PK_DELAY_SEC: Duration = Duration::from_secs(1000);
pub async fn is_message_proxied(message: &Message) -> Result<bool> {
debug!(
trace!(
"Waiting on PluralKit API for {} seconds",
PK_DELAY_SEC.as_secs()
);
@ -22,7 +22,7 @@ pub async fn is_message_proxied(message: &Message) -> Result<bool> {
pub async fn handle(_: &Context, msg: &Message, data: &Data) -> Result<()> {
if msg.webhook_id.is_some() {
debug!(
trace!(
"Message {} has a webhook ID. Checking if it was sent through PluralKit",
msg.id
);

View file

@ -1,12 +1,12 @@
use eyre::{eyre, OptionExt, Result};
use log::debug;
use log::{debug, trace};
use poise::serenity_prelude::{
ChannelType, Context, CreateAllowedMentions, CreateMessage, GuildChannel,
};
pub async fn handle(ctx: &Context, thread: &GuildChannel) -> Result<()> {
if thread.kind != ChannelType::PublicThread {
debug!("Not doing support onboard in non-thread channel");
trace!("Not doing support onboard in non-public thread channel");
return Ok(());
}
@ -15,7 +15,7 @@ pub async fn handle(ctx: &Context, thread: &GuildChannel) -> Result<()> {
.ok_or_else(|| eyre!("Couldn't get parent ID from thread {}!", thread.name))?
.name(ctx)
.await
.unwrap_or(String::new())
.unwrap_or_default()
!= "support"
{
debug!("Not posting onboarding message to threads outside of support");