diff options
| author | Jokler <jokler.contact@gmail.com> | 2019-04-05 00:02:17 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2019-04-05 00:02:17 +0200 |
| commit | 0d8a4196c7733f4f93fa8203ff778bd21e9f05cc (patch) | |
| tree | 3120be1a1d1f54e52a442741d8bbf47b754c0b31 /src/plugins/url.rs | |
| parent | f5554ef8a8af5e9d5c6604c9130d65c71e31be81 (diff) | |
| download | frippy-0d8a4196c7733f4f93fa8203ff778bd21e9f05cc.tar.gz frippy-0d8a4196c7733f4f93fa8203ff778bd21e9f05cc.zip | |
Url: Send titles with a sigle useful word again
Diffstat (limited to 'src/plugins/url.rs')
| -rw-r--r-- | src/plugins/url.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/url.rs b/src/plugins/url.rs index 24b2948..ff73489 100644 --- a/src/plugins/url.rs +++ b/src/plugins/url.rs @@ -45,7 +45,8 @@ impl From<Title> for String { impl Title { fn find_by_delimiters(body: &str, delimiters: [&str; 3]) -> Result<Self, UrlError> { - let title = body.find(delimiters[0]) + let title = body + .find(delimiters[0]) .map(|tag| { body[tag..] .find(delimiters[1]) @@ -124,7 +125,8 @@ impl<C: FrippyClient> UrlTitles<C> { } fn url(&self, text: &str) -> Result<String, UrlError> { - let url = self.grep_url(text) + let url = self + .grep_url(text) .ok_or(ErrorKind::MissingUrl)? .max_kib(self.max_kib) .timeout(Duration::from_secs(5)); @@ -146,11 +148,7 @@ impl<C: FrippyClient> UrlTitles<C> { (Err(e), _) => Err(e)?, }; - if title.usefulness() > 1 { - Ok(title.into()) - } else { - Err(ErrorKind::UselessTitle.into()) - } + Ok(title.into()) } } @@ -158,11 +156,13 @@ impl<C: FrippyClient> Plugin for UrlTitles<C> { type Client = C; fn execute(&self, _: &Self::Client, message: &Message) -> ExecutionStatus { match message.command { - Command::PRIVMSG(_, ref msg) => if URL_RE.is_match(msg) { - ExecutionStatus::RequiresThread - } else { - ExecutionStatus::Done - }, + Command::PRIVMSG(_, ref msg) => { + if URL_RE.is_match(msg) { + ExecutionStatus::RequiresThread + } else { + ExecutionStatus::Done + } + } _ => ExecutionStatus::Done, } } |
