Skip to content

Commit

Permalink
Add /shrug chat command (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
TicClick authored Feb 4, 2024
1 parent 2db1dd9 commit 155d155
Showing 1 changed file with 33 additions and 10 deletions.
43 changes: 33 additions & 10 deletions src/gui/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ trait Command {
fn preferred_alias(&self) -> &String {
self.aliases().first().unwrap()
}
fn example(&self) -> &str;
fn example(&self) -> &str {
self.preferred_alias()
}
fn argcount(&self) -> usize;

fn ui_hint(&self, ui: &mut egui::Ui) {
Expand Down Expand Up @@ -124,9 +126,6 @@ impl Command for CloseChat {
fn description(&self) -> &str {
"close the active tab, or leave the channel"
}
fn example(&self) -> &str {
self.preferred_alias()
}
fn aliases(&self) -> &Vec<String> {
&self.aliases
}
Expand Down Expand Up @@ -156,9 +155,6 @@ impl Command for ClearChat {
fn description(&self) -> &str {
"clear the active tab, removing all messages"
}
fn example(&self) -> &str {
self.preferred_alias()
}
fn aliases(&self) -> &Vec<String> {
&self.aliases
}
Expand Down Expand Up @@ -188,9 +184,6 @@ impl Command for ShowUsage {
fn description(&self) -> &str {
"show a guide around the application"
}
fn example(&self) -> &str {
self.preferred_alias()
}
fn aliases(&self) -> &Vec<String> {
&self.aliases
}
Expand All @@ -205,6 +198,35 @@ impl Command for ShowUsage {
}
}

struct Shrug {
pub aliases: Vec<String>,
}

impl Command for Shrug {
fn new() -> Self {
Self {
aliases: ["/shrug".into()].to_vec(),
}
}
fn description(&self) -> &str {
\\_(ツ)_/¯"
}
fn aliases(&self) -> &Vec<String> {
&self.aliases
}
fn argcount(&self) -> usize {
0
}
fn ui_title(&self) -> egui::RichText {
egui::RichText::new(self.preferred_alias())
}
fn action(&self, state: &UIState, _args: Vec<String>) {
state
.core
.chat_message_sent(&state.active_chat_tab_name, \\_(ツ)_/¯");
}
}

pub struct CommandHelper {
commands: Vec<Box<dyn Command>>,
}
Expand All @@ -218,6 +240,7 @@ impl Default for CommandHelper {
Box::new(CloseChat::new()),
Box::new(ClearChat::new()),
Box::new(ShowUsage::new()),
Box::new(Shrug::new()),
],
};
s.commands
Expand Down

0 comments on commit 155d155

Please sign in to comment.