From 280ae97621e85599a9dd401c3174732b45ad643f Mon Sep 17 00:00:00 2001 From: iximeow Date: Mon, 16 Oct 2017 23:25:12 -0700 Subject: add commands to follow/unfollow --- src/commands/follow.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/commands/follow.rs (limited to 'src/commands/follow.rs') diff --git a/src/commands/follow.rs b/src/commands/follow.rs new file mode 100644 index 0000000..0da07a8 --- /dev/null +++ b/src/commands/follow.rs @@ -0,0 +1,33 @@ +use tw; +use ::Queryer; + +use commands::Command; + +use std::str::FromStr; + +static FOLLOW_URL: &str = "https://api.twitter.com/1.1/friendships/create.json"; +static UNFOLLOW_URL: &str = "https://api.twitter.com/1.1/friendships/destroy.json"; + +pub static UNFOLLOW: Command = Command { + keyword: "unfl", + params: 1, + exec: unfl +}; + +fn unfl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { + // TODO handle this unwrap + let screen_name = line.trim(); //u64::from_str(&line).unwrap(); + queryer.do_api_post(&format!("{}?screen_name={}", FOLLOW_URL, screen_name)); +} + +pub static FOLLOW: Command = Command { + keyword: "fl", + params: 1, + exec: fl +}; + +fn fl(line: String, tweeter: &mut tw::TwitterCache, queryer: &mut Queryer) { + // TODO handle this unwrap + let screen_name = line.trim(); //u64::from_str(&line).unwrap(); + println!("fl resp: {:?}", queryer.do_api_post(&format!("{}?screen_name={}", UNFOLLOW_URL, screen_name))); +} -- cgit v1.1