Skip to content

Commit

Permalink
Add MOTD command
Browse files Browse the repository at this point in the history
  • Loading branch information
A-UNDERSCORE-D authored and spb committed Sep 1, 2023
1 parent 61625eb commit 9c65e0b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 2 additions & 1 deletion configs/server1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"listeners": [
{ "address": "127.0.1.2:6667" },
{ "address": "127.0.1.2:6697", "tls": true },
]
],
"motd": "configs/server1_motd.txt",
},

"tls_config": {
Expand Down
2 changes: 2 additions & 0 deletions configs/server1_motd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MOTD for server 1!
- A_Dragon
1 change: 1 addition & 0 deletions configs/server2.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"listeners": [
{ "address": "127.0.1.3:6667" }
]
// No MOTD
},

"tls_config": {
Expand Down
Empty file added configs/server2_motd.txt
Empty file.
18 changes: 18 additions & 0 deletions sable_ircd/src/command/handlers/motd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use super::*;

#[command_handler("MOTD")]
fn handle_motd(server: &ClientServer, response: &dyn CommandResponse) -> CommandResult {
match &server.infos.motd {
None => response.numeric(make_numeric!(NoMotd)),
Some(motd) => {
response.numeric(make_numeric!(MotdStart, server.name()));
for line in motd.lines() {
response.numeric(make_numeric!(Motd, line));
}

response.numeric(make_numeric!(EndOfMotd));
}
}

Ok(())
}
1 change: 1 addition & 0 deletions sable_ircd/src/command/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ mod handlers {
mod kill;
mod kline;
mod mode;
mod motd;
mod names;
mod nick;
mod notice;
Expand Down

0 comments on commit 9c65e0b

Please sign in to comment.