Skip to content

Commit ac1e5eb

Browse files
committed
add fb marketplace shortcuts
1 parent 97175ee commit ac1e5eb

File tree

11 files changed

+42
-58
lines changed

11 files changed

+42
-58
lines changed

src/commands/bunnylol_command.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,7 @@ mod tests {
7171
}
7272

7373
fn get_info() -> BunnylolCommandInfo {
74-
BunnylolCommandInfo::new(
75-
Self::BINDINGS,
76-
"Test command",
77-
"test query",
78-
)
74+
BunnylolCommandInfo::new(Self::BINDINGS, "Test command", "test query")
7975
}
8076
}
8177

src/commands/chatgpt.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for ChatGPTCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to ChatGPT",
18-
"chatgpt",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to ChatGPT", "chatgpt")
2016
}
2117
}
2218

src/commands/duckduckgo.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@ impl BunnylolCommand for DuckDuckGoCommand {
1414
}
1515

1616
fn get_info() -> BunnylolCommandInfo {
17-
BunnylolCommandInfo::new(
18-
Self::BINDINGS,
19-
"Search DuckDuckGo",
20-
"ddg rust programming",
21-
)
17+
BunnylolCommandInfo::new(Self::BINDINGS, "Search DuckDuckGo", "ddg rust programming")
2218
}
2319
}
2420

src/commands/facebook.rs

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
/// Facebook command handler
22
/// Supports: fb, fb [username/page], fb [search terms]
3+
/// Subcommands: mp/buy/sell -> Marketplace
34
use crate::commands::bunnylol_command::{BunnylolCommand, BunnylolCommandInfo};
45
use crate::utils::url_encoding::{build_path_url, build_search_url};
56

67
pub struct FacebookCommand;
78

89
impl FacebookCommand {
10+
const MARKETPLACE_URL: &'static str = "https://www.facebook.com/marketplace";
11+
912
fn construct_profile_url(profile: &str) -> String {
1013
build_path_url("https://www.facebook.com", profile)
1114
}
@@ -20,14 +23,11 @@ impl BunnylolCommand for FacebookCommand {
2023

2124
fn process_args(args: &str) -> String {
2225
let query = Self::get_command_args(args);
23-
if query.is_empty() {
24-
"https://www.facebook.com".to_string()
25-
} else if !query.contains(' ') {
26-
// Single word without spaces - treat as profile/page
27-
Self::construct_profile_url(query)
28-
} else {
29-
// Multiple words - search
30-
Self::construct_search_url(query)
26+
match query {
27+
"" => "https://www.facebook.com".to_string(),
28+
"mp" | "buy" | "sell" => Self::MARKETPLACE_URL.to_string(),
29+
_ if !query.contains(' ') => Self::construct_profile_url(query),
30+
_ => Self::construct_search_url(query),
3131
}
3232
}
3333

@@ -67,4 +67,28 @@ mod tests {
6767
"https://www.facebook.com/search/top?q=Meta%20AI"
6868
);
6969
}
70+
71+
#[test]
72+
fn test_facebook_command_marketplace_mp() {
73+
assert_eq!(
74+
FacebookCommand::process_args("fb mp"),
75+
FacebookCommand::MARKETPLACE_URL
76+
);
77+
}
78+
79+
#[test]
80+
fn test_facebook_command_marketplace_buy() {
81+
assert_eq!(
82+
FacebookCommand::process_args("fb buy"),
83+
FacebookCommand::MARKETPLACE_URL
84+
);
85+
}
86+
87+
#[test]
88+
fn test_facebook_command_marketplace_sell() {
89+
assert_eq!(
90+
FacebookCommand::process_args("fb sell"),
91+
FacebookCommand::MARKETPLACE_URL
92+
);
93+
}
7094
}

src/commands/gmail.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for GmailCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to Gmail",
18-
"mail",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to Gmail", "mail")
2016
}
2117
}
2218

src/commands/googlechat.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for GoogleChatCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to Google Chat",
18-
"gchat",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to Google Chat", "gchat")
2016
}
2117
}
2218

src/commands/googledocs.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for GoogleDocsCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to Google Docs",
18-
"docs",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to Google Docs", "docs")
2016
}
2117
}
2218

src/commands/googlesheets.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for GoogleSheetsCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to Google Sheets",
18-
"gsheets",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to Google Sheets", "gsheets")
2016
}
2117
}
2218

src/commands/googleslides.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ impl BunnylolCommand for GoogleSlidesCommand {
1212
}
1313

1414
fn get_info() -> BunnylolCommandInfo {
15-
BunnylolCommandInfo::new(
16-
Self::BINDINGS,
17-
"Navigate to Google Slides",
18-
"gslides",
19-
)
15+
BunnylolCommandInfo::new(Self::BINDINGS, "Navigate to Google Slides", "gslides")
2016
}
2117
}
2218

src/commands/onepassword.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ impl BunnylolCommand for OnePasswordCommand {
1313
}
1414

1515
fn get_info() -> BunnylolCommandInfo {
16-
BunnylolCommandInfo::new(
17-
Self::BINDINGS,
18-
"1Password home page",
19-
"1p",
20-
)
16+
BunnylolCommandInfo::new(Self::BINDINGS, "1Password home page", "1p")
2117
}
2218
}
2319

0 commit comments

Comments
 (0)