Skip to content

Commit

Permalink
v0.0.14
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Dec 17, 2024
1 parent 39383d6 commit 8d6844b
Show file tree
Hide file tree
Showing 8 changed files with 883 additions and 837 deletions.
1,633 changes: 838 additions & 795 deletions Cargo.lock

Large diffs are not rendered by default.

40 changes: 20 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ license = "MIT"
description = "Matrix bot for Cuprate"

[dependencies]
anyhow = { version = "1.0.86" }
chrono = { version = "0.4.38" }
const_format = { version = "0.2.32" }
dirs = { version = "5.0.1" }
matrix-sdk = { version = "0.7.1", features = ["markdown", "anyhow"] }
once_cell = { version = "1.19.0" }
rand = { version = "0.8.5" }
readable = { version = "0.16.0", features = ["full"] }
reqwest = { version = "0.12.5", features = ["gzip"] }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = { version = "1.0.117" }
serde_plain = { version = "1.0.2" }
strum = { version = "0.26.2", features = ["derive"] }
thiserror = { version = "1.0.61" }
tokio = { version = "1.38.0", features = ["full"] }
toml = { version = "0.8.14" }
tracing = { version = "0.1.40" }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
zeroize = { version = "1.8.1" }
anyhow = { version = "1" }
chrono = { version = "0.4" }
const_format = { version = "0.2" }
dirs = { version = "5" }
matrix-sdk = { version = "0.8", features = ["markdown", "anyhow"] }
once_cell = { version = "1" }
rand = { version = "0.8" }
readable = { version = "0.16", features = ["full"] }
reqwest = { version = "0.12", features = ["gzip"] }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
serde_plain = { version = "1" }
strum = { version = "0.26", features = ["derive"] }
thiserror = { version = "2" }
tokio = { version = "1", features = ["full"] }
toml = { version = "0.8" }
tracing = { version = "0.1" }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
zeroize = { version = "1" }

[dev-dependencies]
pretty_assertions = { version = "1.4.0" }
pretty_assertions = { version = "1" }
1 change: 0 additions & 1 deletion moo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ allowed_users = [
"@hinto:monero.social",
"@boog900:monero.social",
"@syntheticbird:monero.social",
"@yamabiiko:unitoo.it",
]


Expand Down
6 changes: 3 additions & 3 deletions src/command/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl Command {
] {
for (pr, md) in db.iter() {
if md.priority == priority {
string += &format!("{pr:?} ");
string.push_str(&format!("{pr:?} "));
}
}
}
Expand Down Expand Up @@ -346,12 +346,12 @@ impl Command {

// If the meeting is on-going, end it.
let msg = if MEETING_ONGOING.load(Ordering::Acquire) {
MEETING_ONGOING.store(false, Ordering::Release);

let mut logs = String::new();
let mut db = MEETING_DATABASE.lock().await;
std::mem::swap(&mut logs, &mut db);

MEETING_ONGOING.store(false, Ordering::Release);

match crate::github::finish_cuprate_meeting(logs).await {
Ok((logs, next_meeting)) => {
format!("- Logs: {logs}\n - Next meeting: {next_meeting}")
Expand Down
3 changes: 1 addition & 2 deletions src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,11 @@ pub static CUPRATE_MEETING_MODERATOR_MATRIX_ID: Lazy<&UserId> =
Lazy::new(|| user_id!("@boog900:monero.social"));

/// TODO
pub static ALLOWED_MATRIX_IDS_DEFAULT: Lazy<[OwnedUserId; 4]> = Lazy::new(|| {
pub static ALLOWED_MATRIX_IDS_DEFAULT: Lazy<[OwnedUserId; 3]> = Lazy::new(|| {
[
owned_user_id!("@hinto:monero.social"),
owned_user_id!("@boog900:monero.social"),
owned_user_id!("@syntheticbird:monero.social"),
owned_user_id!("@yamabiiko:unitoo.it"),
]
});

Expand Down
4 changes: 2 additions & 2 deletions src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,11 @@ pub async fn post_cuprate_meeting_issue(

let err = || anyhow!("Failed to parse previous meeting title: {previous_meeting_title}");

if !iter.next().is_some_and(|s| s == "Cuprate") {
if iter.next().is_none_or(|s| s != "Cuprate") {
return Err(err());
}

if !iter.next().is_some_and(|s| s == "Meeting") {
if iter.next().is_none_or(|s| s != "Meeting") {
return Err(err());
}

Expand Down
31 changes: 18 additions & 13 deletions src/meeting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,30 @@ pub async fn meeting_handler(startup: SystemTime, event: SyncRoomMessageEvent) {
}
}

let text = match &event.content.msgtype {
MessageType::Text(t) => &t.body,
MessageType::Audio(_) => "<audio>",
MessageType::Emote(_) => "<emote>",
MessageType::Image(_) => "<image>",
MessageType::Video(_) => "<video>",
MessageType::File(_) => "<file>",
_ => "<unknown_attachment>",
let text = match event.content.msgtype {
MessageType::Text(t) => t.body,
MessageType::Emote(x) => x.body,
MessageType::Notice(x) => x.body,
MessageType::ServerNotice(x) => x.body,
MessageType::VerificationRequest(x) => x.body,
MessageType::Location(x) => format!("<{}>", x.plain_text_representation()),
MessageType::Audio(x) => format!("<{}>", x.filename()),
MessageType::File(x) => format!("<{}>", x.filename()),
MessageType::Image(x) => format!("<{}>", x.filename()),
MessageType::Video(x) => format!("<{}>", x.filename()),
_ => "<unknown>".to_string(),
};

// HACK: do not relay ``` as it messes up the meeting log formatting:
// <https://github.com/monero-project/meta/issues/1108>
if text == "```" {
info!("Ignoring ```");
return;
}
let text = if text.contains("```") {
text.replace("```", "")
} else {
text
};

let mut db = MEETING_DATABASE.lock().await;
if MEETING_ONGOING.load(std::sync::atomic::Ordering::Acquire) {
*db += &format!("\n```\n{}: {text}\n```", sender.localpart());
db.push_str(&format!("\n```\n{}: {text}\n```", sender.localpart()));
}
}
2 changes: 1 addition & 1 deletion src/pull_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub enum PullRequestError {

impl PullRequestError {
/// TODO
pub fn other(pr: PullRequest, error: anyhow::Error) -> Self {
pub const fn other(pr: PullRequest, error: anyhow::Error) -> Self {
Self::Other { pr, error }
}
}
Expand Down

0 comments on commit 8d6844b

Please sign in to comment.