aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2017-10-17 00:11:22 -0700
committeriximeow <me@iximeow.net>2017-10-17 00:11:56 -0700
commit9a50ccba1c77cba504b7458e144e6fc5d10b55d1 (patch)
tree9f5975587d77e96d00f6c89260e8976f6c5e4215
parent9b3b0c356af994c642e7c19af671471125fbccd2 (diff)
check followers on startup too
-rw-r--r--src/main.rs1
-rw-r--r--src/tw/mod.rs7
2 files changed, 8 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 820bcb1..0526c06 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -40,6 +40,7 @@ static STREAMURL: &str = "https://userstream.twitter.com/1.1/user.json?tweet_mod
static TWEET_LOOKUP_URL: &str = "https://api.twitter.com/1.1/statuses/show.json?tweet_mode=extended";
static USER_LOOKUP_URL: &str = "https://api.twitter.com/1.1/users/show.json";
static ACCOUNT_SETTINGS_URL: &str = "https://api.twitter.com/1.1/account/settings.json";
+static GET_FOLLOWER_IDS_URL: &str = "https://api.twitter.com/1.1/followers/ids.json?stringify_ids=true";
header! { (Authorization, "Authorization") => [String] }
header! { (Accept, "Accept") => [String] }
diff --git a/src/tw/mod.rs b/src/tw/mod.rs
index 710bf59..49b7add 100644
--- a/src/tw/mod.rs
+++ b/src/tw/mod.rs
@@ -383,6 +383,10 @@ impl TwitterCache {
pub fn get_settings(&self, queryer: &mut ::Queryer) -> Option<serde_json::Value> {
queryer.do_api_get(::ACCOUNT_SETTINGS_URL)
}
+
+ pub fn get_followers(&self, queryer: &mut ::Queryer) -> Option<serde_json::Value> {
+ queryer.do_api_get(::GET_FOLLOWER_IDS_URL)
+ }
}
fn handle_twitter_event(
@@ -443,6 +447,9 @@ fn handle_twitter_welcome(
} else {
println!("Unable to make API call to figure out who you are...");
}
+ let followers = tweeter.get_followers(queryer).unwrap();
+ let id_arr: Vec<String> = followers["ids"].as_array().unwrap().iter().map(|x| x.as_str().unwrap().to_owned()).collect();
+ tweeter.set_followers(id_arr);
}
pub fn handle_message(