aboutsummaryrefslogtreecommitdiff
path: root/commands/look_up.rs
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-01 20:55:15 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-01 20:55:15 -0700
commite6ebf2c99a70bd5ee4e8d07097e6b128c3630714 (patch)
tree476947a6f2937737bc69ca073a2519bd9f15b1fe /commands/look_up.rs
parentaf67981a2a1c28b3b5598f74d48bfd3a7490c91a (diff)
extract commands and twitter model into modules
Diffstat (limited to 'commands/look_up.rs')
-rw-r--r--commands/look_up.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/commands/look_up.rs b/commands/look_up.rs
new file mode 100644
index 0000000..d04f984
--- /dev/null
+++ b/commands/look_up.rs
@@ -0,0 +1,32 @@
+use tw;
+use ::Queryer;
+
+use commands::Command;
+
+pub static LOOK_UP_USER: Command = Command {
+ keyword: "look_up_user",
+ params: 1,
+ exec: look_up_user
+};
+
+fn look_up_user(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) {
+ if let Some(user) = tweeter.fetch_user(&line, &mut queryer) {
+ println!("{:?}", user);
+ } else {
+// println!("Couldn't retrieve {}", userid);
+ }
+}
+
+pub static LOOK_UP_TWEET: Command = Command {
+ keyword: "look_up_tweet",
+ params: 1,
+ exec: look_up_tweet
+};
+
+fn look_up_tweet(line: String, tweeter: &mut tw::TwitterCache, mut queryer: &mut Queryer) {
+ if let Some(tweet) = tweeter.fetch_tweet(&line, &mut queryer) {
+ println!("{:?}", tweet);
+ } else {
+// println!("Couldn't retrieve {}", tweetid);
+ }
+}