Skip to content

Commit

Permalink
refactor: cargo clippy の警告を修正 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
m1sk9 authored Oct 28, 2023
1 parent ae8a952 commit eac9b21
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/adapters/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub async fn send_citation_embed(
http: &Arc<Http>,
target_message: &Message,
) -> anyhow::Result<()> {
let message = get_citation_message(ids, &http).await?;
let message = get_citation_message(ids, http).await?;
let embed = build_citation_embed(message).context("埋め込みの生成に失敗しました")?;

target_message
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn get_citation_message(
.get_active_threads(http)
.await
.context("スレッドリストの取得に失敗しました")?;
let thread = match guild_threads.threads.iter().find(|c| &c.id == &channel_id) {
let thread = match guild_threads.threads.iter().find(|c| c.id == channel_id) {
Some(channel) => channel.clone(),
None => {
return Err(anyhow::anyhow!("引用元チャンネルは見つかりませんでした."));
Expand Down
6 changes: 3 additions & 3 deletions src/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ use tracing::{error, info, warn};

pub struct EvHandler;

const MESSAGE_LINK_REGEX: Lazy<Regex> = Lazy::new(|| {
static MESSAGE_LINK_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"https://(?:ptb\.|canary\.)?discord\.com/channels/(\d+)/(\d+)/(\d+)").unwrap()
});
// 引用スキップ機能の正規表現
const SKIP_MESSAGE_LINK_REGEX: Lazy<Regex> = Lazy::new(|| {
static SKIP_MESSAGE_LINK_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"<https://(?:ptb\.|canary\.)?discord\.com/channels/\d+/\d+/\d+>").unwrap()
});

Expand All @@ -26,7 +26,7 @@ impl EventHandler for EvHandler {
}

let content = &message.content;
if !MESSAGE_LINK_REGEX.is_match(&content) || SKIP_MESSAGE_LINK_REGEX.is_match(&content) {
if !MESSAGE_LINK_REGEX.is_match(content) || SKIP_MESSAGE_LINK_REGEX.is_match(content) {
return;
}
let matched_str = MESSAGE_LINK_REGEX.find(content).unwrap().as_str();
Expand Down

0 comments on commit eac9b21

Please sign in to comment.