Many fixes and tweaks

* Fix tags (again?)

* Make tag names more consistent

* Remove prefix commands (not implemented well and not worth fixing)

* Allow '-'s in tags

* Fix /joke

* Fix /members

* Fix intel_hd issue match

* Fix log analysis reply

* Clearer log analysis messages

It's weird to say the process failed when no issues were found.

* Clippy

* Final doc cleanup

* Fix link expanding

* Fix duplicate event filtering

The other code simply does not work. ChannelId does have a method to grab members but I'm not sure whether it would work either.

* Remove message resolution

It's surprisingly hard to create an bug-free implementation.

* Fix pluralkit detection

* simplify tag codegen

* commands: improve error handling in members

unwrap() bad!!!11!!

* events: use debug logs for pk checks

* Revert "Remove message resolution"

This reverts commit 0d9f224a81917212adafdeb2213f3cc11b44cf88.

* Bring back prefix commands with "."

(it's easier to type)

* Add help

* Fix messsage resolution

* utils: factor out message resolution

* Improve tag message

* Disable VC support for message resolution for now

* Improve prefix command usage

Update on edit, display additional tip with wrong usage.

* Check invoke_on_edit to display tip

* Add defer in commands which make http requests

* Apply tag sorting to slash commands too

* handlers::error: `+=` -> `writeln!`

* handlers::event: ignore own new messages

* help: remove unneeded format!

* optimize for size in release builds

* nix: cleanup deployment expressions

* nix: use treefmt

* nix: update flake.lock

Flake lock file updates:

• Updated input 'fenix':
    'github:nix-community/fenix/eb683549b7d76b12d1a009f888b91b70ed34485f' (2024-01-27)
  → 'github:nix-community/fenix/c53bb4a32f2fce7acf4e8e160a54779c4460ffdb' (2024-03-17)
• Updated input 'fenix/rust-analyzer-src':
    'github:rust-lang/rust-analyzer/596e5c77cf5b2b660b3ac2ce732fa0596c246d9b' (2024-01-26)
  → 'github:rust-lang/rust-analyzer/5ecace48f693afaa6adf8cb23086b651db3aec96' (2024-03-16)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/4fddc9be4eaf195d631333908f2a454b03628ee5' (2024-01-25)
  → 'github:nixos/nixpkgs/34ad8c9f29a18b4dd97a9ad40ceb16954f24afe7' (2024-03-17)
• Updated input 'pre-commit-hooks':
    'github:cachix/pre-commit-hooks.nix/f56597d53fd174f796b5a7d3ee0b494f9e2285cc' (2024-01-20)
  → 'github:cachix/pre-commit-hooks.nix/5df5a70ad7575f6601d91f0efec95dd9bc619431' (2024-02-15)
• Updated input 'procfile-nix':
    'github:getchoo/procfile-nix/31a33e4264e5c6214844993c5b508fb3500ef5cd' (2024-01-27)
  → 'github:getchoo/procfile-nix/7a0ab379a4ab71c9deccaca9fb463e9aaea363d8' (2024-03-14)

---------

Co-authored-by: seth <getchoo@tuta.io>
This commit is contained in:
TheKodeToad 2024-03-18 01:01:46 +00:00 committed by GitHub
parent 1ea08671fb
commit 9d0c022c68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 492 additions and 296 deletions

View file

@ -95,7 +95,7 @@ fn intel_hd(log: &str) -> Issue {
See https://prismlauncher.org/wiki/getting-started/installing-java/#a-note-about-intel-hd-20003000-on-windows-10 for more info".to_string()
);
let found = log.contains("java.lang.NoSuchMethodError: sun.security.util.ManifestEntryVerifier.<init>(Ljava/util/jar/Manifest;)V");
let found = log.contains("org.lwjgl.LWJGLException: Pixel format not accelerated");
found.then_some(issue)
}
@ -204,7 +204,7 @@ async fn outdated_launcher(log: &str, data: &Data) -> Result<Issue> {
if version_from_log < latest_version {
let issue = (
"Outdated Prism Launcher".to_string(),
"Outdated Prism Launcher".to_string(),
format!("Your installed version is {version_from_log}, while the newest version is {latest_version}.\nPlease update, for more info see https://prismlauncher.org/download/")
);

View file

@ -19,7 +19,7 @@ pub async fn handle(ctx: &Context, message: &Message, data: &Data) -> Result<()>
if log.is_err() {
let embed = CreateEmbed::new()
.title("Analyze failed!")
.title("Analysis failed!")
.description("Couldn't download log");
let allowed_mentions = CreateAllowedMentions::new().replied_user(true);
let our_message = CreateMessage::new()
@ -43,11 +43,9 @@ pub async fn handle(ctx: &Context, message: &Message, data: &Data) -> Result<()>
let mut e = CreateEmbed::new().title("Log analysis");
if issues.is_empty() {
e = e.color(COLORS["green"]).field(
"Analyze failed!",
"No issues found automatically",
false,
);
e = e
.color(COLORS["green"])
.description("No issues found automatically");
} else {
e = e.color(COLORS["red"]);
@ -61,6 +59,7 @@ pub async fn handle(ctx: &Context, message: &Message, data: &Data) -> Result<()>
let allowed_mentions = CreateAllowedMentions::new().replied_user(true);
let message = CreateMessage::new()
.reference_message(message)
.allowed_mentions(allowed_mentions)
.embed(embed);

View file

@ -4,13 +4,12 @@ use poise::serenity_prelude::{Context, CreateAllowedMentions, CreateMessage, Mes
use crate::utils;
pub async fn handle(ctx: &Context, message: &Message) -> Result<()> {
let embeds = utils::resolve_message(ctx, message).await?;
let embeds = utils::resolve_message::from_message(ctx, message).await?;
// TODO getchoo: actually reply to user
// ...not sure why Message doesn't give me a builder in reply() or equivalents
if !embeds.is_empty() {
let allowed_mentions = CreateAllowedMentions::new().replied_user(false);
let reply = CreateMessage::new()
.reference_message(message)
.embeds(embeds)
.allowed_mentions(allowed_mentions);

View file

@ -15,7 +15,7 @@ mod support_onboard;
pub async fn handle(
ctx: &Context,
event: &FullEvent,
framework: FrameworkContext<'_, Data, Report>,
_framework: FrameworkContext<'_, Data, Report>,
data: &Data,
) -> Result<()> {
match event {
@ -31,8 +31,10 @@ pub async fn handle(
FullEvent::Message { new_message } => {
// ignore new messages from bots
// NOTE: the webhook_id check allows us to still respond to PK users
if new_message.author.bot && new_message.webhook_id.is_none() {
// note: the webhook_id check allows us to still respond to PK users
if (new_message.author.bot && new_message.webhook_id.is_none())
|| new_message.is_own(ctx)
{
trace!("Ignoring message {} from bot", new_message.id);
return Ok(());
}
@ -57,7 +59,7 @@ pub async fn handle(
}
FullEvent::ThreadCreate { thread } => {
support_onboard::handle(ctx, thread, framework).await?;
support_onboard::handle(ctx, thread).await?;
}
_ => {}

View file

@ -2,18 +2,18 @@ use crate::{api, Data};
use std::time::Duration;
use eyre::Result;
use log::trace;
use log::{debug, trace};
use poise::serenity_prelude::{Context, Message};
use tokio::time::sleep;
const PK_DELAY_SEC: Duration = Duration::from_secs(1000);
const PK_DELAY: Duration = Duration::from_secs(1);
pub async fn is_message_proxied(message: &Message) -> Result<bool> {
trace!(
"Waiting on PluralKit API for {} seconds",
PK_DELAY_SEC.as_secs()
PK_DELAY.as_secs()
);
sleep(PK_DELAY_SEC).await;
sleep(PK_DELAY).await;
let proxied = api::pluralkit::get_sender(message.id).await.is_ok();
@ -21,21 +21,23 @@ 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() {
trace!(
"Message {} has a webhook ID. Checking if it was sent through PluralKit",
msg.id
);
if msg.webhook_id.is_none() {
return Ok(());
}
trace!(
"Waiting on PluralKit API for {} seconds",
PK_DELAY_SEC.as_secs()
);
sleep(PK_DELAY_SEC).await;
debug!(
"Message {} has a webhook ID. Checking if it was sent through PluralKit",
msg.id
);
if let Ok(sender) = api::pluralkit::get_sender(msg.id).await {
data.storage.store_user_plurality(sender).await?;
}
trace!(
"Waiting on PluralKit API for {} seconds",
PK_DELAY.as_secs()
);
sleep(PK_DELAY).await;
if let Ok(sender) = api::pluralkit::get_sender(msg.id).await {
data.storage.store_user_plurality(sender).await?;
}
Ok(())

View file

@ -1,36 +1,17 @@
use crate::Data;
use eyre::{eyre, Context as _, OptionExt, Report, Result};
use eyre::{eyre, OptionExt, Result};
use log::{debug, trace};
use poise::serenity_prelude::{
ChannelType, Context, CreateAllowedMentions, CreateMessage, GuildChannel,
};
use poise::FrameworkContext;
pub async fn handle(
ctx: &Context,
thread: &GuildChannel,
framework: FrameworkContext<'_, Data, Report>,
) -> Result<()> {
pub async fn handle(ctx: &Context, thread: &GuildChannel) -> Result<()> {
if thread.kind != ChannelType::PublicThread {
trace!("Not doing support onboard in non-public thread channel");
return Ok(());
}
// TODO @getchoo: it seems like we can get multiple ThreadCreate events
// should probably figure out a better way to not repeat ourselves here
if thread
.members(ctx)
.wrap_err_with(|| {
format!(
"Couldn't fetch members from thread {}! Not sending a support onboard message.",
thread.id
)
})?
.iter()
.any(|member| member.user.id == framework.bot_id)
{
debug!("Not sending support onboard message...I think i've been here before :p");
if thread.last_message_id.is_some() {
debug!("Ignoring duplicate thread creation event");
return Ok(());
}