aboutsummaryrefslogtreecommitdiff
path: root/src/tw
diff options
context:
space:
mode:
authorAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-21 14:02:37 -0700
committerAndy Wortman <ixineeringeverywhere@gmail.com>2017-10-21 14:02:37 -0700
commit79f626c9ea8e8503bd17c8ea640d8b192f0bbee5 (patch)
tree3c7c87923a26a3d3b8482e6c1214c194670cbd3e /src/tw
parentfaa5864206ad8ab315ae12fb925386c6b76b1a90 (diff)
fix bug with @s not going through in conversations
split included @, meaning no handle started with @, so get_mentions() returned empty vec
Diffstat (limited to 'src/tw')
-rw-r--r--src/tw/tweet.rs8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/tw/tweet.rs b/src/tw/tweet.rs
index 72802ca..a3fdde3 100644
--- a/src/tw/tweet.rs
+++ b/src/tw/tweet.rs
@@ -22,17 +22,19 @@ pub struct Tweet {
}
impl Tweet {
- pub fn get_mentions(&self) -> Vec<&str> {
+ pub fn get_mentions(&self) -> Vec<String> {
self.text.split(&[
',', '.', '/', ';', '\'',
'[', ']', '\\', '~', '!',
- '@', '#', '$', '%', '^',
+ '#', '$', '%', '^',
'&', '*', '(', ')', '-',
'=', '{', '}', '|', ':',
'"', '<', '>', '?', '`',
' ' // forgot this initially. awkward.
][..])
- .filter(|x| x.starts_with("@") && x.len() > 1)
+ .filter(|x| x.starts_with("@") && x.len() > 1 && x.chars().skip(1).all(|c| c != '@'))
+ // discard @, mentions are just the usernames.
+ .map(|handle| handle.chars().skip(1).collect())
.collect()
}