diff --git a/src/main.rs b/src/main.rs index 0169ddf..91bb0f0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,6 +50,7 @@ async fn main() { if text.contains("/help") || text.contains("/start") { bot.send_message(msg.chat.id, help_text()) .parse_mode(teloxide::types::ParseMode::MarkdownV2) + .reply_markup(location_button_markup) .await?; } else { match openstreetmap::geocode_text(text) { @@ -60,7 +61,7 @@ async fn main() { wikipedia::send_wikipedia_pages(location.lat, location.lon, bot, msg).await; } Err(error) => { - println!("Geocoding failed: {}", error); + log::warn!("Geocoding failed: {}", error); bot.send_message( msg.chat.id, format!("Location query returned no matches:\n\t{}\nTry /help", text), @@ -73,6 +74,7 @@ async fn main() { _ => {} }, _ => { + log::warn!("Unsupported message type recieved"); bot.send_message( msg.chat.id, "Send a location or address to see nearby places that have a wikipedia page!", diff --git a/src/openstreetmap.rs b/src/openstreetmap.rs index 09f8f78..9196340 100644 --- a/src/openstreetmap.rs +++ b/src/openstreetmap.rs @@ -27,7 +27,6 @@ pub struct Location { } pub fn geocode_text(search_query: &str) -> Result { - // "https://nominatim.openstreetmap.org/search.php?q=1650+wewatta+world&format=jsonv2&limit=1" let base_url = "https://nominatim.openstreetmap.org/search.php"; let url = Url::parse_with_params(base_url, &[("q", search_query), ("format", "jsonv2"), ("limit", "1")]) diff --git a/src/wikipedia.rs b/src/wikipedia.rs index e33c13b..d322298 100644 --- a/src/wikipedia.rs +++ b/src/wikipedia.rs @@ -41,6 +41,7 @@ pub struct Root { } fn escape_markdown_v2(text: String) -> String { + // https://core.telegram.org/bots/api#markdownv2-style text.chars().fold(String::new(), |mut acc, c| { match c { '_' | '*' | '[' | ']' | '(' | ')' | '~' | '`' | '>' | '#' | '+' | '-' | '=' | '|' | '{' | '}' | '.' | '!' => {