Skip to content

Commit

Permalink
Implement !about command
Browse files Browse the repository at this point in the history
  • Loading branch information
haecker-felix committed Sep 19, 2021
1 parent 9330fd2 commit 1715051
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "hebbot"
version = "0.1.0"
version = "2.1.0"
authors = ["Felix Häcker <[email protected]>"]
edition = "2018"

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ In this closed room administrative commands can be executed.

| Command | Description |
| --------------- | ---------------------------------------------------------- |
| !about | Shows bot version details |
| !clear | Clears all stored news |
| !details "term" | Shows section/project details (term can be emoji or name) |
| !list-config | Lists current bot configuration |
Expand Down
15 changes: 15 additions & 0 deletions src/bot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ impl EventCallback {
info!("Received command: {} ({})", command, args);

match command {
"!about" => self.about_command().await,
"!clear" => self.clear_command().await,
"!details" => self.details_command(&args).await,
"!help" => self.help_command().await,
Expand All @@ -622,6 +623,7 @@ impl EventCallback {

async fn help_command(&self) {
let help = "Available commands: \n\n\
!about \n\
!clear \n\
!details <name> \n\
!list-config \n\
Expand All @@ -637,6 +639,19 @@ impl EventCallback {
.await;
}

async fn about_command(&self) {
let version = env!("CARGO_PKG_VERSION");

let msg = format!(
"You are running Hebbot version {}<br>© 2021 Felix Häcker<br><a href=\"https://github.com/haecker-felix/hebbot/\">Open Homepage</a> | <a href=\"https://github.com/haecker-felix/hebbot/issues/new\">Report Issue</a>",
version
);

self.0
.send_message(&msg, BotMsgType::AdminRoomHtmlNotice)
.await;
}

async fn clear_command(&self) {
let msg = {
let mut news_store = self.0.news_store.lock().unwrap();
Expand Down

0 comments on commit 1715051

Please sign in to comment.