aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hooks/url.rs8
-rw-r--r--src/main.rs2
2 files changed, 5 insertions, 5 deletions
diff --git a/src/hooks/url.rs b/src/hooks/url.rs
index 2392d1d..4e19282 100644
--- a/src/hooks/url.rs
+++ b/src/hooks/url.rs
@@ -41,17 +41,17 @@ pub async fn url_title(url: &str) -> Result<String, Error> {
}
#[tracing::instrument(skip(bot))]
-pub fn url_preview(bot: &crate::Bot, msg: Message) -> Result<()> {
+pub async fn url_preview(bot: &crate::Bot, msg: Message) -> Result<()> {
if let Command::PRIVMSG(target, text) = msg.command.clone() {
let mut titles: Vec<String> = Vec::new();
for url in url_parser(&text) {
trace!("got url: {:?}", url);
- match futures::executor::block_on(url_title(&url.as_str())) {
+ match url_title(&url.as_str()).await {
Ok(title) => {
trace!("extracted title from url: {:?}, {:?}", title, url);
titles.push(title);
- },
+ }
Err(err) => error!("Failed to get urls title: {:?}", err),
}
}
@@ -69,7 +69,7 @@ pub fn msg_builder(titles: &Vec<String>) -> String {
"Title{}: {}",
if titles.len() > 1 { "s" } else { "" },
titles.join(" --- ")
- )
+ )
}
#[cfg(test)]
diff --git a/src/main.rs b/src/main.rs
index 776299d..f442d35 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -13,7 +13,7 @@ async fn main() {
AUTHENTICATE,
catinator::hooks::sasl
),
- hook(
+ async hook(
"url_preview",
"Send preview of website",
PRIVMSG,