diff --git a/.travis.yml b/.travis.yml index 6304996..511e290 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,25 @@ language: python +sudo: required +dist: trusty python: - "2.7" before_script: - psql -c 'create database bot;' -U postgres -install: "pip install -r requirements.txt" + - psql -c 'CREATE TABLE users (id int, mode varchar(30),zoom int,format varchar(30),language varchar(10))' -d bot -U postgres + - psql -c 'CREATE TABLE "render_cache" (bbox text, filename text)' -d bot -U postgres + - psql -c "INSERT INTO \"render_cache\" VALUES ('1,1,1,1', 'ok')" -d bot -U postgres + - psql -c "SELECT * FROM \"render_cache\"; " -d bot -U postgres + - sudo apt-get install -y python-software-properties + - sudo add-apt-repository -y ppa:mapnik/nightly-2.3 + - sudo apt-get update + - sudo apt-get install -y python-mapnik +install: + - pip install -r requirements.txt + - pip install coveralls + - pip install six script: PYTHONPATH="." python test/test.py +after_success: + - PYTHONPATH="." coverage2 run --source=. test/test.py + - coveralls services: - - postgresql \ No newline at end of file + - postgresql diff --git a/README.md b/README.md index 3bf5770..33101be 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Build Status](https://travis-ci.org/Xevib/osmbot.svg?branch=master)](https://travis-ci.org/Xevib/osmbot) - +[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) +[![Coverage Status](https://coveralls.io/repos/github/Xevib/osmbot/badge.svg?branch=master)](https://coveralls.io/github/Xevib/osmbot?branch=master) OSMbot: OpenStreetMap bot for Telegram ====================================== **OSMbot** is a project maintained by the OpenStreetMap Catalan Community. See [WikiProject Catalan/OSMbot](http://wiki.openstreetmap.org/wiki/Ca:WikiProject_Catalan/OSMbot). diff --git a/app.py b/app.py index ab5f26e..c45734b 100644 --- a/app.py +++ b/app.py @@ -20,11 +20,9 @@ sentry.captureMessage('OSMBot started', level=logging.INFO) application.sentry = sentry -f = open('nginx.crt', 'r') - webhook = os.path.join(config['webhook'], config['token']) application.logger.debug('webhook:%s', config['webhook']) -result = telegram_api.setWebhook(webhook, f) +result = telegram_api.setWebhook(webhook) if result: application.logger.debug('Webhook set') diff --git a/bot/locales/cs/LC_MESSAGES/messages.mo b/bot/locales/cs/LC_MESSAGES/messages.mo index eb79eb1..519d330 100644 Binary files a/bot/locales/cs/LC_MESSAGES/messages.mo and b/bot/locales/cs/LC_MESSAGES/messages.mo differ diff --git a/bot/locales/cs/LC_MESSAGES/messages.po b/bot/locales/cs/LC_MESSAGES/messages.po index 83176c5..7e2fce3 100644 --- a/bot/locales/cs/LC_MESSAGES/messages.po +++ b/bot/locales/cs/LC_MESSAGES/messages.po @@ -9,9 +9,9 @@ msgid "" msgstr "" "Project-Id-Version: OSMbot\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2016-07-18 08:53+0200\n" -"PO-Revision-Date: 2016-07-18 08:42+0000\n" -"Last-Translator: Albert F \n" +"POT-Creation-Date: 2016-07-21 22:05+0200\n" +"PO-Revision-Date: 2016-08-18 21:31+0000\n" +"Last-Translator: Roman Horník \n" "Language-Team: Czech (Czech Republic) (http://www.transifex.com/osm-catala/osmbot/language/cs_CZ/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -60,177 +60,170 @@ msgstr "Můžete zkusit jiné ohraničení, nebo jiné měřítko (úroveň při msgid "Good luck! " msgstr "Hodně štěstí!" -#: bot/osmbot_blueprint.py:195 +#: bot/osmbot.py:249 msgid "Results for" msgstr "Výsledky pro" -#: bot/osmbot_blueprint.py:218 +#: bot/osmbot.py:272 bot/templates/inline_article.md:198 msgid "Map" msgstr "Mapa" -#: bot/osmbot_blueprint.py:221 bot/osmbot_blueprint.py:223 -#: bot/osmbot_blueprint.py:225 bot/osmbot_blueprint.py:227 -#: bot/osmbot_blueprint.py:232 bot/osmbot_blueprint.py:234 -#: bot/osmbot_blueprint.py:236 bot/osmbot_blueprint.py:238 +#: bot/osmbot.py:275 bot/osmbot.py:277 bot/osmbot.py:279 bot/osmbot.py:281 +#: bot/osmbot.py:286 bot/osmbot.py:288 bot/osmbot.py:290 bot/osmbot.py:292 msgid "More info" msgstr "Více informací" -#: bot/osmbot_blueprint.py:228 +#: bot/osmbot.py:282 msgid "Phone" msgstr "Telefon" -#: bot/osmbot_blueprint.py:240 bot/osmbot_blueprint.py:398 -#: bot/osmbot_blueprint.py:653 bot/osmbot_blueprint.py:662 -#: bot/templates/details_message.md:200 bot/templates/inline_article.md:197 +#: bot/osmbot.py:294 bot/osmbot.py:451 bot/osmbot.py:730 bot/osmbot.py:739 +#: bot/templates/details_message.md:199 bot/templates/inline_article.md:200 msgid "OpenStreetMap contributors" msgstr "Přispěvatelé OpenStreetMap" -#: bot/osmbot_blueprint.py:298 bot/osmbot_blueprint.py:301 -#: bot/osmbot_blueprint.py:303 bot/templates/details_message.md:2 -#: bot/templates/details_message.md:4 bot/templates/details_message.md:6 -#: bot/templates/inline_article.md:2 bot/templates/inline_article.md:4 -#: bot/templates/inline_article.md:6 +#: bot/osmbot.py:351 bot/osmbot.py:354 bot/osmbot.py:356 +#: bot/templates/details_message.md:2 bot/templates/details_message.md:4 +#: bot/templates/details_message.md:6 bot/templates/inline_article.md:2 +#: bot/templates/inline_article.md:4 bot/templates/inline_article.md:6 msgid "Tags for" msgstr "Značky pro" -#: bot/osmbot_blueprint.py:305 bot/osmbot_blueprint.py:307 -#: bot/templates/details_message.md:10 bot/templates/details_message.md:12 -#: bot/templates/inline_article.md:10 bot/templates/inline_article.md:12 +#: bot/osmbot.py:358 bot/osmbot.py:360 bot/templates/details_message.md:10 +#: bot/templates/details_message.md:12 bot/templates/inline_article.md:11 +#: bot/templates/inline_article.md:13 msgid "European country" msgstr "Evropu" -#: bot/osmbot_blueprint.py:309 bot/templates/details_message.md:14 -#: bot/templates/inline_article.md:14 +#: bot/osmbot.py:362 bot/templates/details_message.md:14 +#: bot/templates/inline_article.md:15 msgid "African country" msgstr "Afriku" -#: bot/osmbot_blueprint.py:311 bot/osmbot_blueprint.py:313 -#: bot/osmbot_blueprint.py:315 bot/templates/details_message.md:16 -#: bot/templates/details_message.md:18 bot/templates/details_message.md:20 -#: bot/templates/inline_article.md:16 bot/templates/inline_article.md:18 -#: bot/templates/inline_article.md:20 +#: bot/osmbot.py:364 bot/osmbot.py:366 bot/osmbot.py:368 +#: bot/templates/details_message.md:16 bot/templates/details_message.md:18 +#: bot/templates/details_message.md:20 bot/templates/inline_article.md:17 +#: bot/templates/inline_article.md:19 bot/templates/inline_article.md:21 msgid "South american country" msgstr "Jižní Ameriku" -#: bot/osmbot_blueprint.py:317 bot/osmbot_blueprint.py:319 -#: bot/templates/details_message.md:22 bot/templates/details_message.md:24 -#: bot/templates/inline_article.md:22 bot/templates/inline_article.md:24 +#: bot/osmbot.py:370 bot/osmbot.py:372 bot/templates/details_message.md:22 +#: bot/templates/details_message.md:24 bot/templates/inline_article.md:23 +#: bot/templates/inline_article.md:25 msgid "North american country" msgstr "Severní Ameriku" -#: bot/osmbot_blueprint.py:321 bot/templates/details_message.md:26 -#: bot/templates/inline_article.md:26 +#: bot/osmbot.py:374 bot/templates/details_message.md:26 +#: bot/templates/inline_article.md:27 msgid "Central american country" msgstr "Střední Ameriku" -#: bot/osmbot_blueprint.py:323 bot/osmbot_blueprint.py:325 -#: bot/templates/details_message.md:28 bot/templates/details_message.md:30 -#: bot/templates/inline_article.md:28 bot/templates/inline_article.md:30 +#: bot/osmbot.py:376 bot/osmbot.py:378 bot/templates/details_message.md:28 +#: bot/templates/details_message.md:30 bot/templates/inline_article.md:29 +#: bot/templates/inline_article.md:31 msgid "American country" msgstr "Americký kontinent" -#: bot/osmbot_blueprint.py:327 bot/templates/details_message.md:32 -#: bot/templates/inline_article.md:32 +#: bot/osmbot.py:380 bot/templates/details_message.md:32 +#: bot/templates/inline_article.md:33 msgid "Asian country" msgstr "Asii" -#: bot/osmbot_blueprint.py:329 bot/osmbot_blueprint.py:331 -#: bot/templates/details_message.md:34 bot/templates/details_message.md:36 -#: bot/templates/inline_article.md:34 bot/templates/inline_article.md:36 +#: bot/osmbot.py:382 bot/osmbot.py:384 bot/templates/details_message.md:34 +#: bot/templates/details_message.md:36 bot/templates/inline_article.md:35 +#: bot/templates/inline_article.md:37 msgid "Oceanian country" msgstr "Oceánii" -#: bot/osmbot_blueprint.py:333 bot/osmbot_blueprint.py:335 -#: bot/templates/details_message.md:38 bot/templates/details_message.md:40 -#: bot/templates/inline_article.md:38 bot/templates/inline_article.md:40 +#: bot/osmbot.py:386 bot/osmbot.py:388 bot/templates/details_message.md:38 +#: bot/templates/details_message.md:40 bot/templates/inline_article.md:39 +#: bot/templates/inline_article.md:41 msgid "Eurasian country" msgstr "Eurasijský kontinent" -#: bot/osmbot_blueprint.py:372 bot/osmbot_blueprint.py:374 -#: bot/templates/details_message.md:182 bot/templates/details_message.md:184 -#: bot/templates/inline_article.md:182 bot/templates/inline_article.md:184 +#: bot/osmbot.py:425 bot/osmbot.py:427 bot/templates/details_message.md:182 +#: bot/templates/details_message.md:184 bot/templates/inline_article.md:183 +#: bot/templates/inline_article.md:185 msgid "inhabitants" msgstr "obyvatel" -#: bot/osmbot_blueprint.py:372 bot/templates/details_message.md:182 -#: bot/templates/inline_article.md:182 +#: bot/osmbot.py:425 bot/templates/details_message.md:182 +#: bot/templates/inline_article.md:183 msgid "at" msgstr "na" -#: bot/osmbot_blueprint.py:377 bot/templates/details_message.md:187 -#: bot/templates/inline_article.md:187 +#: bot/osmbot.py:430 bot/templates/details_message.md:187 +#: bot/templates/inline_article.md:188 msgid "meters" msgstr "metrech" -#: bot/osmbot_blueprint.py:390 bot/templates/details_message.md:198 +#: bot/osmbot.py:443 bot/templates/details_message.md:197 msgid "Raw data:" msgstr "Surová data:" -#: bot/osmbot_blueprint.py:417 bot/osmbot_blueprint.py:419 -#: bot/osmbot_blueprint.py:464 bot/osmbot_blueprint.py:467 -#: bot/osmbot_blueprint.py:492 bot/osmbot_blueprint.py:495 -#: bot/osmbot_blueprint.py:510 +#: bot/osmbot.py:492 bot/osmbot.py:543 bot/osmbot.py:546 bot/osmbot.py:567 +#: bot/osmbot.py:591 msgid "OSM contributors" msgstr "Přispěvatelé OSM" -#: bot/osmbot_blueprint.py:428 bot/templates/send_location_message.md:1 +#: bot/osmbot.py:507 bot/templates/send_location_message.md:1 msgid "Please send me your location" msgstr "Prosím, sdělte mi svou pozici" -#: bot/osmbot_blueprint.py:429 +#: bot/osmbot.py:508 msgid "to receive the map" msgstr "pro přijetí mapy" -#: bot/osmbot_blueprint.py:430 bot/templates/send_location_message.md:2 +#: bot/osmbot.py:509 bot/templates/send_location_message.md:2 msgid "You can do it with the Telegram paperclip button" msgstr "Můžete tak učunit tlačítkem sponky Telegramu" -#: bot/osmbot_blueprint.py:636 bot/templates/not_recognized_message.md:1 +#: bot/osmbot.py:713 bot/templates/not_recognized_message.md:1 msgid "" "Sorry, but now I can't recognize tags for this element, perhaps with my new " "features I will do it" msgstr "Omlouvám se, ale zrovna se mi nedaří rozpoznat značku tohoto elementu, možná tak budu moci udělat s mými novými vlastnostmi" -#: bot/osmbot_blueprint.py:644 bot/osmbot_blueprint.py:659 +#: bot/osmbot.py:721 bot/osmbot.py:736 msgid "Raw data for" msgstr "Surová data pro" -#: bot/osmbot_blueprint.py:646 bot/osmbot_blueprint.py:661 +#: bot/osmbot.py:723 bot/osmbot.py:738 msgid "Raw data" msgstr "Surová data" -#: bot/osmbot_blueprint.py:809 +#: bot/osmbot.py:897 msgid "" "Please indicate what are you searching with command /search " msgstr "Prosím, uveďte co hledáte příkazem /search " -#: bot/osmbot_blueprint.py:815 +#: bot/osmbot.py:903 msgid "Use /search command to indicate what you are searching" msgstr "Použijte příkaz /search pro vyhledávání" -#: bot/osmbot_blueprint.py:899 +#: bot/osmbot_blueprint.py:97 msgid "" "OpenStreetMap bot finds any location in world from the Nominatim OSM " "database and can send links and maps from OSM" msgstr "OpenStreetMap bot hledá jakékoliv místo na světě z OSM databáze Nominatim a může odesílat odkazy a mapy z OSM" -#: bot/osmbot_blueprint.py:900 +#: bot/osmbot_blueprint.py:98 msgid "" "OpenStreetMap bot finds any location in the world from the Nominatim OSM " "database" msgstr "OpenStreetMap bot vyhledává jakékoliv místo na světě z OSM databáze Nominatim" -#: bot/osmbot_blueprint.py:901 +#: bot/osmbot_blueprint.py:99 msgid "The bot can send links and maps (jpg, png or pdf) from OSM" msgstr "Bot umí z OSM posílat odkazy a mapy (jpg, png, nebo pdf)" -#: bot/osmbot_blueprint.py:902 +#: bot/osmbot_blueprint.py:100 msgid "" "Data for all the world (cities and towns, shops -with phone number, " "email...-, Wikipedia links, etc)" msgstr "Údaje pro celý svět (města a obce, obchody - s telefonními čísly, emailovou adresou, odkazy z Wikipedie atd.)" -#: bot/osmbot_blueprint.py:903 +#: bot/osmbot_blueprint.py:101 msgid "OSMbot is multilingual and speaks *your language here*" msgstr "OSMbot je vícejazyčný, umí i česky" @@ -268,11 +261,11 @@ msgstr "Lokalizace" #: bot/templates/about_answer.md:9 msgid "DOCUMENTATION" -msgstr "" +msgstr "DOKUMENTACE" #: bot/templates/about_answer.md:10 msgid "OSMbot wiki" -msgstr "" +msgstr "Wiki OSMbot" #: bot/templates/about_answer.md:12 msgid "NEWS" @@ -280,7 +273,7 @@ msgstr "NOVINKY" #: bot/templates/about_answer.md:13 msgid "Twitter account" -msgstr "" +msgstr "Účet Twitteru" #: bot/templates/about_answer.md:14 msgid "Telegram channel" @@ -330,15 +323,15 @@ msgstr "Možná vám pomohu příkazem /help" msgid "What do you want to configure?" msgstr "Co si přejete nastavit?" -#: bot/templates/details_message.md:42 bot/templates/inline_article.md:42 +#: bot/templates/details_message.md:42 bot/templates/inline_article.md:43 msgid "Flag" -msgstr "" +msgstr "Vlajka" -#: bot/templates/details_message.md:191 bot/templates/inline_article.md:191 +#: bot/templates/details_message.md:191 bot/templates/inline_article.md:192 msgid "Wikidata" msgstr "Wikidata" -#: bot/templates/details_message.md:194 bot/templates/inline_article.md:194 +#: bot/templates/details_message.md:194 bot/templates/inline_article.md:195 msgid "Wikipedia" msgstr "Wikipedie" @@ -473,10 +466,6 @@ msgstr "Nyní budu odpovídat při zmínce" msgid "Should I answer without a mention?" msgstr "Mohu odpovídat bez zmínky?" -#: bot/templates/question_only_mention.md:1 -msgid "Answer only when mention?" -msgstr "" - #: bot/templates/send_location_message.md:1 msgid "and I'll send you the nearest element" msgstr "a pošlu vám nejbližší element" diff --git a/bot/locales/pt/LC_MESSAGES/messages.mo b/bot/locales/pt/LC_MESSAGES/messages.mo new file mode 100644 index 0000000..5216805 Binary files /dev/null and b/bot/locales/pt/LC_MESSAGES/messages.mo differ diff --git a/bot/locales/pt/LC_MESSAGES/messages.po b/bot/locales/pt/LC_MESSAGES/messages.po new file mode 100644 index 0000000..14dfb88 --- /dev/null +++ b/bot/locales/pt/LC_MESSAGES/messages.po @@ -0,0 +1,485 @@ +# Translations template for PROJECT. +# Copyright (C) 2016 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# +# Translators: +# Albert F , 2016 +# andreout , 2015 +# Rui , 2016 +# Rui , 2016 +msgid "" +msgstr "" +"Project-Id-Version: OSMbot\n" +"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" +"POT-Creation-Date: 2016-07-21 22:05+0200\n" +"PO-Revision-Date: 2016-09-11 22:29+0000\n" +"Last-Translator: Rui \n" +"Language-Team: Portuguese (http://www.transifex.com/osm-catala/osmbot/language/pt/)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 1.3\n" +"Language: pt\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: bot/maptools.py:43 bot/maptools.py:45 +msgid "Map too large!" +msgstr "Mapa demasiado grande!" + +#: bot/maptools.py:43 bot/maptools.py:45 +msgid "Please, reduce the bounding box" +msgstr "Por favor reduza a caixa de limites" + +#: bot/maptools.py:43 bot/maptools.py:45 +msgid "or the scale (zoom level)" +msgstr "ou a escala (nível de aproximação)" + +#: bot/maptools.py:47 +msgid "Invalid bounding box!" +msgstr "Caixa de limites inválida!" + +#: bot/maptools.py:47 +msgid "Please, try with /map minlon,minlat,maxlon,maxlat" +msgstr "Por favor tente com /map minlon,minlat,maxlon,maxlat" + +#: bot/maptools.py:47 +msgid "Coordinates' decimals need to be marked with a dot." +msgstr "Os decimais das coordenadas têm de ser marcados com um ponto." + +#: bot/maptools.py:47 +msgid "For example:" +msgstr "Por exemplo:" + +#: bot/maptools.py:49 +msgid "Oh,oh... An error occurred" +msgstr "Oh não... Surgiu um erro" + +#: bot/maptools.py:49 +msgid "You can try with another bounding box or scale (zoom level)" +msgstr "Pode tentar com outra caixa de limites ou outra escala (nível de aproximação)" + +#: bot/maptools.py:49 +msgid "Good luck! " +msgstr "Boa sorte!" + +#: bot/osmbot.py:249 +msgid "Results for" +msgstr "Resultados para" + +#: bot/osmbot.py:272 bot/templates/inline_article.md:198 +msgid "Map" +msgstr "Mapa" + +#: bot/osmbot.py:275 bot/osmbot.py:277 bot/osmbot.py:279 bot/osmbot.py:281 +#: bot/osmbot.py:286 bot/osmbot.py:288 bot/osmbot.py:290 bot/osmbot.py:292 +msgid "More info" +msgstr "Mais informação" + +#: bot/osmbot.py:282 +msgid "Phone" +msgstr "Telefone" + +#: bot/osmbot.py:294 bot/osmbot.py:451 bot/osmbot.py:730 bot/osmbot.py:739 +#: bot/templates/details_message.md:199 bot/templates/inline_article.md:200 +msgid "OpenStreetMap contributors" +msgstr "Contribuidores do OpenStreetMap" + +#: bot/osmbot.py:351 bot/osmbot.py:354 bot/osmbot.py:356 +#: bot/templates/details_message.md:2 bot/templates/details_message.md:4 +#: bot/templates/details_message.md:6 bot/templates/inline_article.md:2 +#: bot/templates/inline_article.md:4 bot/templates/inline_article.md:6 +msgid "Tags for" +msgstr "Etiquetas para" + +#: bot/osmbot.py:358 bot/osmbot.py:360 bot/templates/details_message.md:10 +#: bot/templates/details_message.md:12 bot/templates/inline_article.md:11 +#: bot/templates/inline_article.md:13 +msgid "European country" +msgstr "País europeu" + +#: bot/osmbot.py:362 bot/templates/details_message.md:14 +#: bot/templates/inline_article.md:15 +msgid "African country" +msgstr "País africano" + +#: bot/osmbot.py:364 bot/osmbot.py:366 bot/osmbot.py:368 +#: bot/templates/details_message.md:16 bot/templates/details_message.md:18 +#: bot/templates/details_message.md:20 bot/templates/inline_article.md:17 +#: bot/templates/inline_article.md:19 bot/templates/inline_article.md:21 +msgid "South american country" +msgstr "País sul-americano" + +#: bot/osmbot.py:370 bot/osmbot.py:372 bot/templates/details_message.md:22 +#: bot/templates/details_message.md:24 bot/templates/inline_article.md:23 +#: bot/templates/inline_article.md:25 +msgid "North american country" +msgstr "País norte-americano" + +#: bot/osmbot.py:374 bot/templates/details_message.md:26 +#: bot/templates/inline_article.md:27 +msgid "Central american country" +msgstr "País centro-americano" + +#: bot/osmbot.py:376 bot/osmbot.py:378 bot/templates/details_message.md:28 +#: bot/templates/details_message.md:30 bot/templates/inline_article.md:29 +#: bot/templates/inline_article.md:31 +msgid "American country" +msgstr "País americano" + +#: bot/osmbot.py:380 bot/templates/details_message.md:32 +#: bot/templates/inline_article.md:33 +msgid "Asian country" +msgstr "País asiático" + +#: bot/osmbot.py:382 bot/osmbot.py:384 bot/templates/details_message.md:34 +#: bot/templates/details_message.md:36 bot/templates/inline_article.md:35 +#: bot/templates/inline_article.md:37 +msgid "Oceanian country" +msgstr "País da oceania" + +#: bot/osmbot.py:386 bot/osmbot.py:388 bot/templates/details_message.md:38 +#: bot/templates/details_message.md:40 bot/templates/inline_article.md:39 +#: bot/templates/inline_article.md:41 +msgid "Eurasian country" +msgstr "País euroasiático" + +#: bot/osmbot.py:425 bot/osmbot.py:427 bot/templates/details_message.md:182 +#: bot/templates/details_message.md:184 bot/templates/inline_article.md:183 +#: bot/templates/inline_article.md:185 +msgid "inhabitants" +msgstr "habitantes" + +#: bot/osmbot.py:425 bot/templates/details_message.md:182 +#: bot/templates/inline_article.md:183 +msgid "at" +msgstr "em" + +#: bot/osmbot.py:430 bot/templates/details_message.md:187 +#: bot/templates/inline_article.md:188 +msgid "meters" +msgstr "metros" + +#: bot/osmbot.py:443 bot/templates/details_message.md:197 +msgid "Raw data:" +msgstr "Dados em bruto:" + +#: bot/osmbot.py:492 bot/osmbot.py:543 bot/osmbot.py:546 bot/osmbot.py:567 +#: bot/osmbot.py:591 +msgid "OSM contributors" +msgstr "Contribuidores do OSM" + +#: bot/osmbot.py:507 bot/templates/send_location_message.md:1 +msgid "Please send me your location" +msgstr "Por favor envie-me a sua localização" + +#: bot/osmbot.py:508 +msgid "to receive the map" +msgstr "para receber o mapa" + +#: bot/osmbot.py:509 bot/templates/send_location_message.md:2 +msgid "You can do it with the Telegram paperclip button" +msgstr "Pode fazê-lo com o botão clipe do Telegram" + +#: bot/osmbot.py:713 bot/templates/not_recognized_message.md:1 +msgid "" +"Sorry, but now I can't recognize tags for this element, perhaps with my new " +"features I will do it" +msgstr "Desculpe, mas agora não consigo reconhecer as etiquetas para este elemento, talvez quando eu tiver novas funcionalidades o consiga fazer" + +#: bot/osmbot.py:721 bot/osmbot.py:736 +msgid "Raw data for" +msgstr "Dados em bruto para" + +#: bot/osmbot.py:723 bot/osmbot.py:738 +msgid "Raw data" +msgstr "Dados em bruto" + +#: bot/osmbot.py:897 +msgid "" +"Please indicate what are you searching with command /search " +msgstr "Por favor indique o que está a procurar com o comando /search " + +#: bot/osmbot.py:903 +msgid "Use /search command to indicate what you are searching" +msgstr "Use o comando /search para indicar o que está a procurar" + +#: bot/osmbot_blueprint.py:97 +msgid "" +"OpenStreetMap bot finds any location in world from the Nominatim OSM " +"database and can send links and maps from OSM" +msgstr "O robô OpenStreetMap encontra qualquer localização no mundo na base de dados do Nominatim do OSM e pode enviar ligações e mapas do OSM" + +#: bot/osmbot_blueprint.py:98 +msgid "" +"OpenStreetMap bot finds any location in the world from the Nominatim OSM " +"database" +msgstr "O robô OpenStreetMap encontra qualquer localização no mundo na base de dados do Nominatim do OSM" + +#: bot/osmbot_blueprint.py:99 +msgid "The bot can send links and maps (jpg, png or pdf) from OSM" +msgstr "O robô pode enviar ligações e mapas (jpg, png ou pdf) do OSM" + +#: bot/osmbot_blueprint.py:100 +msgid "" +"Data for all the world (cities and towns, shops -with phone number, " +"email...-, Wikipedia links, etc)" +msgstr "Dados para todo o mundo (cidades e vilas, lojas com número de telefone, email..., hiperligações para a Wikipédia, etc.)" + +#: bot/osmbot_blueprint.py:101 +msgid "OSMbot is multilingual and speaks *your language here*" +msgstr "OSMbot é multilingue e fala português" + +#: bot/templates/about_answer.md:1 +msgid "OpenStreetMap bot info:" +msgstr "Sobre o robô OpenStreetMap" + +#: bot/templates/about_answer.md:3 +msgid "CREDITS&CODE" +msgstr "CRÉDITOS E CÓDIGO" + +#: bot/templates/about_answer.md:4 +msgid "Author:" +msgstr "Autor:" + +#: bot/templates/about_answer.md:4 +msgid "(Catalan OpenStreetMap community)" +msgstr "(Comunidade do OpenStreetMap Catalã)" + +#: bot/templates/about_answer.md:5 +msgid "Code" +msgstr "Código" + +#: bot/templates/about_answer.md:6 +msgid "License: GPLv3" +msgstr "Licença: GPLv3" + +#: bot/templates/about_answer.md:6 +msgid "http://www.gnu.org/licenses/gpl-3.0.en.html" +msgstr "http://www.gnu.org/licenses/gpl-3.0.en.html" + +#: bot/templates/about_answer.md:7 +msgid "Localization" +msgstr "Localização" + +#: bot/templates/about_answer.md:9 +msgid "DOCUMENTATION" +msgstr "DOCUMENTAÇÃO" + +#: bot/templates/about_answer.md:10 +msgid "OSMbot wiki" +msgstr "Wiki do OSMbot" + +#: bot/templates/about_answer.md:12 +msgid "NEWS" +msgstr "NOTÍCIAS" + +#: bot/templates/about_answer.md:13 +msgid "Twitter account" +msgstr "Conta Twitter" + +#: bot/templates/about_answer.md:14 +msgid "Telegram channel" +msgstr "Canal no Telegram" + +#: bot/templates/about_answer.md:16 +msgid "RATING" +msgstr "CLASSIFICAÇÃO" + +#: bot/templates/about_answer.md:17 +msgid "Rating&reviews" +msgstr "Classificações e comentários" + +#: bot/templates/about_answer.md:18 +msgid "Please rate me" +msgstr "Por favor classifique-me" + +#: bot/templates/about_answer.md:20 +msgid "Thanks for use @OSMbot!!" +msgstr "Obrigado por usar o @OSMbot!!" + +#: bot/templates/answer_always.md:1 +msgid "Now I always will answer" +msgstr "Agora eu responderei sempre" + +#: bot/templates/cant_talk_message.md:1 +msgid "Ooops! I can't talk this language" +msgstr "Ooops! Eu não entendo esta língua" + +#: bot/templates/cant_talk_message.md:1 +msgid "yet" +msgstr "para já" + +#: bot/templates/cant_talk_message.md:2 +msgid "But you can help me to learn it in Transifex" +msgstr "No entanto pode ajudar-me a aprender no Transifex" + +#: bot/templates/cant_understand_message.md:1 +msgid "Sorry, I can't understand you" +msgstr "Desculpe, não consigo entender o que escreveu" + +#: bot/templates/cant_understand_message.md:2 +msgid "Perhaps I could help you with the command /help" +msgstr "talvez eu possa ajudá-lo com o comando /hel" + +#: bot/templates/configure_question.md:1 +msgid "What do you want to configure?" +msgstr "O que pretende configurar?" + +#: bot/templates/details_message.md:42 bot/templates/inline_article.md:43 +msgid "Flag" +msgstr "Bandeira" + +#: bot/templates/details_message.md:191 bot/templates/inline_article.md:192 +msgid "Wikidata" +msgstr "Wikidata" + +#: bot/templates/details_message.md:194 bot/templates/inline_article.md:195 +msgid "Wikipedia" +msgstr "Wikipédia" + +#: bot/templates/easter_egg.md:1 +msgid "If you see strange emojis it's due a Telegram easter egg" +msgstr "Se vir algum emoticon estranho é por causa duma supresa do Telegram" + +#: bot/templates/error_message.md:1 +msgid "Something failed" +msgstr "Falhou alguma coisa" + +#: bot/templates/error_message.md:1 +msgid "please try it later" +msgstr "por favor tente mais tarde" + +#: bot/templates/help_message.md:1 +msgid "OpenStreetMap bot help:" +msgstr "Ajuda do robô OpenStreetMap:" + +#: bot/templates/help_message.md:3 +msgid "You can control me by sending these commands:" +msgstr "Pode controlar-me enviando estes comandos:" + +#: bot/templates/help_message.md:5 +msgid "" +"/about - Show info about OSMbot: credits&code, news and ratings&reviews" +msgstr "/about - Mostra informação sobre o OSMbot: créditos e código, notícias, classificações e comentários" + +#: bot/templates/help_message.md:7 +msgid "/details - Show some tags from OSM database by ID." +msgstr "/details - Mostra algumas etiquetas na base de dados do OSM pelo ID - número identificador." + +#: bot/templates/help_message.md:9 +msgid "" +"/raw - Show all tags from OSM database by ID in raw format." +msgstr "/raw - Mostra todas as etiquetas da base de dados do OSM pelo ID no formato em bruto." + +#: bot/templates/help_message.md:11 +msgid "" +"The ID is generated by /search command, but if you know an OSM ID you can " +"try it." +msgstr "O ID é gerado com o comando /search mas se conhecer algum ID do OSM, pode tentar usá-lo." + +#: bot/templates/help_message.md:13 +msgid "" +"The type it's optional and it can be nod(node), way(way) or rel(relation). " +"If you don't specify it, the bot will try to deduce it" +msgstr "O tipo é opcional e pode ser nod (nó), way (via) ou rel (relação). Se não especificar o tipo, o robô tentará adivinhar" + +#: bot/templates/help_message.md:15 +msgid "" +"/legend - Show list of pairs key=value and its emoji in OSMbot. If" +" you don't specify an , shows all pairs of key=value with emoji in " +"Osmbot" +msgstr "/legend - Mostra a lista de pares de key=value (chave=valor) e o seu emoji no OSMbot. Se não especificar uma , são mostrados todos os pares de key=value com emoji no OSMbot" + +#: bot/templates/help_message.md:17 +msgid "/map - Send a map with different options:" +msgstr "/map - Enviar um mapa com várias opções:" + +#: bot/templates/help_message.md:19 +msgid "" +" Could be a point (lat,lon) or a bounding box " +"(minlon,minlat,maxlon,maxlat). If you don't use this option can send your " +"location" +msgstr " Pode ser um ponto (lat,lon) ou uma caixa de limites (minlon,minlat,maxlon,maxlat). Se não usar esta opção pode enviar a sua localização" + +#: bot/templates/help_message.md:21 +msgid "" +" Could be png, jpeg or pdf. If you don't use this option, the bot " +"use png by default" +msgstr " Pode ser png, jpeg ou pdf. Se não especificar esta opção, o robõ usa por defeito o png" + +#: bot/templates/help_message.md:23 +msgid "" +" Level of zoom (1-19). If you don't use this option, the bot use 19 " +"by default." +msgstr " Nível de aproximação/zoom (1-19).Se não especificar esta opção, o robõ usa por defeito o nível 19" + +#: bot/templates/help_message.md:25 +msgid "" +"/search - Search from Nominatim in all OpenStreetMap database." +msgstr "/search - Procura no Nominatim em toda a base de dados do OpenStreetMap." + +#: bot/templates/help_message.md:27 +msgid "" +"/nearest - Search from Overpass the element in a " +"certain radius" +msgstr "/nearest - Procura no Overpass o elemento dentro de um determinado raio de distância" + +#: bot/templates/language_answer.md:1 +msgid "Choose the language for talk with you" +msgstr "Escolha a língua para eu falar consigo" + +#: bot/templates/new_language.md:1 +msgid "Now I will talk you with the new language" +msgstr "Agora eu falarei consigo na nova língua" + +#: bot/templates/no_emoji.md:1 +msgid "No emoji found, perhaps you should try with /legend " +msgstr "Nenhum emoji encontrado, quiçá deveria tentar com /legend " + +#: bot/templates/not_found_id_message.md:1 +msgid "Sorry but I couldn't find any result, please check the ID" +msgstr "Desculpe mas eu não consegui encontrar nenhum resultado. Confirme se o ID está correto" + +#: bot/templates/not_found_message.md:1 +msgid "Sorry but I couldn't find any result for" +msgstr "Desculpe mas eu não consegui encontrar nenhum resultado para" + +#: bot/templates/not_found_message.md:2 +msgid "But you can try to improve OpenStreetMap" +msgstr "Mas pode tentar melhorar o OpenStreetMap" + +#: bot/templates/not_found_message.md:3 +msgid "http://learnosm.org/en/" +msgstr "http://learnosm.org/pt/" + +#: bot/templates/not_found_overpass_message.md:1 +msgid "No element found" +msgstr "Não foi encontrado nenhum elemento" + +#: bot/templates/not_implemented_message.md:1 +msgid "Sorry but this query it's not implemented yet" +msgstr "Desculpe mas esta consulta ainda não está implementada" + +#: bot/templates/only_mention.md:1 +msgid "Now I only will answer when mention" +msgstr "Agora eu apenas responderei quando eu for mencionado" + +#: bot/templates/question_mention.md:1 +msgid "Should I answer without a mention?" +msgstr "Devo responder sem me mencionar?" + +#: bot/templates/send_location_message.md:1 +msgid "and I'll send you the nearest element" +msgstr "e eu enviarei para si o elemento mais próximo" + +#: bot/templates/seting_not_recognized_message.md:1 +msgid "Setting not recognized" +msgstr "Configuração não reconhecida" + +#: bot/templates/start_answer.md:1 +msgid "Hi, I'm the robot for OpenStreetMap data" +msgstr "Olá, sou um robô para os dados do OpenStreetMap" + +#: bot/templates/start_answer.md:2 +msgid "How I can help you?" +msgstr "Como posso ajudá-lo?" diff --git a/bot/locales/ru/LC_MESSAGES/messages.mo b/bot/locales/ru/LC_MESSAGES/messages.mo index 6347911..df6a416 100644 Binary files a/bot/locales/ru/LC_MESSAGES/messages.mo and b/bot/locales/ru/LC_MESSAGES/messages.mo differ diff --git a/bot/locales/ru/LC_MESSAGES/messages.po b/bot/locales/ru/LC_MESSAGES/messages.po index caac9eb..61cd87c 100644 --- a/bot/locales/ru/LC_MESSAGES/messages.po +++ b/bot/locales/ru/LC_MESSAGES/messages.po @@ -6,13 +6,14 @@ # d1g , 2016 # Albert F , 2015-2016 # Ilya Zverev , 2016 +# Max Max , 2016 msgid "" msgstr "" "Project-Id-Version: OSMbot\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2016-07-18 08:53+0200\n" -"PO-Revision-Date: 2016-07-18 08:42+0000\n" -"Last-Translator: Albert F \n" +"POT-Creation-Date: 2016-07-21 22:05+0200\n" +"PO-Revision-Date: 2016-09-11 20:26+0000\n" +"Last-Translator: Ilya Zverev \n" "Language-Team: Russian (http://www.transifex.com/osm-catala/osmbot/language/ru/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -61,177 +62,170 @@ msgstr "Попробуйте другой регион или масштаб" msgid "Good luck! " msgstr "Удачи!" -#: bot/osmbot_blueprint.py:195 +#: bot/osmbot.py:249 msgid "Results for" msgstr "Результаты для" -#: bot/osmbot_blueprint.py:218 +#: bot/osmbot.py:272 bot/templates/inline_article.md:198 msgid "Map" msgstr "Карта" -#: bot/osmbot_blueprint.py:221 bot/osmbot_blueprint.py:223 -#: bot/osmbot_blueprint.py:225 bot/osmbot_blueprint.py:227 -#: bot/osmbot_blueprint.py:232 bot/osmbot_blueprint.py:234 -#: bot/osmbot_blueprint.py:236 bot/osmbot_blueprint.py:238 +#: bot/osmbot.py:275 bot/osmbot.py:277 bot/osmbot.py:279 bot/osmbot.py:281 +#: bot/osmbot.py:286 bot/osmbot.py:288 bot/osmbot.py:290 bot/osmbot.py:292 msgid "More info" msgstr "Больше информации" -#: bot/osmbot_blueprint.py:228 +#: bot/osmbot.py:282 msgid "Phone" msgstr "Телефон" -#: bot/osmbot_blueprint.py:240 bot/osmbot_blueprint.py:398 -#: bot/osmbot_blueprint.py:653 bot/osmbot_blueprint.py:662 -#: bot/templates/details_message.md:200 bot/templates/inline_article.md:197 +#: bot/osmbot.py:294 bot/osmbot.py:451 bot/osmbot.py:730 bot/osmbot.py:739 +#: bot/templates/details_message.md:199 bot/templates/inline_article.md:200 msgid "OpenStreetMap contributors" msgstr "Участники OpenStreetMap" -#: bot/osmbot_blueprint.py:298 bot/osmbot_blueprint.py:301 -#: bot/osmbot_blueprint.py:303 bot/templates/details_message.md:2 -#: bot/templates/details_message.md:4 bot/templates/details_message.md:6 -#: bot/templates/inline_article.md:2 bot/templates/inline_article.md:4 -#: bot/templates/inline_article.md:6 +#: bot/osmbot.py:351 bot/osmbot.py:354 bot/osmbot.py:356 +#: bot/templates/details_message.md:2 bot/templates/details_message.md:4 +#: bot/templates/details_message.md:6 bot/templates/inline_article.md:2 +#: bot/templates/inline_article.md:4 bot/templates/inline_article.md:6 msgid "Tags for" msgstr "Теги для" -#: bot/osmbot_blueprint.py:305 bot/osmbot_blueprint.py:307 -#: bot/templates/details_message.md:10 bot/templates/details_message.md:12 -#: bot/templates/inline_article.md:10 bot/templates/inline_article.md:12 +#: bot/osmbot.py:358 bot/osmbot.py:360 bot/templates/details_message.md:10 +#: bot/templates/details_message.md:12 bot/templates/inline_article.md:11 +#: bot/templates/inline_article.md:13 msgid "European country" msgstr "Европейская страна" -#: bot/osmbot_blueprint.py:309 bot/templates/details_message.md:14 -#: bot/templates/inline_article.md:14 +#: bot/osmbot.py:362 bot/templates/details_message.md:14 +#: bot/templates/inline_article.md:15 msgid "African country" msgstr "Африканская страна" -#: bot/osmbot_blueprint.py:311 bot/osmbot_blueprint.py:313 -#: bot/osmbot_blueprint.py:315 bot/templates/details_message.md:16 -#: bot/templates/details_message.md:18 bot/templates/details_message.md:20 -#: bot/templates/inline_article.md:16 bot/templates/inline_article.md:18 -#: bot/templates/inline_article.md:20 +#: bot/osmbot.py:364 bot/osmbot.py:366 bot/osmbot.py:368 +#: bot/templates/details_message.md:16 bot/templates/details_message.md:18 +#: bot/templates/details_message.md:20 bot/templates/inline_article.md:17 +#: bot/templates/inline_article.md:19 bot/templates/inline_article.md:21 msgid "South american country" msgstr "Южно-Американская страна" -#: bot/osmbot_blueprint.py:317 bot/osmbot_blueprint.py:319 -#: bot/templates/details_message.md:22 bot/templates/details_message.md:24 -#: bot/templates/inline_article.md:22 bot/templates/inline_article.md:24 +#: bot/osmbot.py:370 bot/osmbot.py:372 bot/templates/details_message.md:22 +#: bot/templates/details_message.md:24 bot/templates/inline_article.md:23 +#: bot/templates/inline_article.md:25 msgid "North american country" -msgstr "Северно-Американская страна" +msgstr "Северо-Американская страна" -#: bot/osmbot_blueprint.py:321 bot/templates/details_message.md:26 -#: bot/templates/inline_article.md:26 +#: bot/osmbot.py:374 bot/templates/details_message.md:26 +#: bot/templates/inline_article.md:27 msgid "Central american country" msgstr "Центрально-Американская страна" -#: bot/osmbot_blueprint.py:323 bot/osmbot_blueprint.py:325 -#: bot/templates/details_message.md:28 bot/templates/details_message.md:30 -#: bot/templates/inline_article.md:28 bot/templates/inline_article.md:30 +#: bot/osmbot.py:376 bot/osmbot.py:378 bot/templates/details_message.md:28 +#: bot/templates/details_message.md:30 bot/templates/inline_article.md:29 +#: bot/templates/inline_article.md:31 msgid "American country" msgstr "Американская страна" -#: bot/osmbot_blueprint.py:327 bot/templates/details_message.md:32 -#: bot/templates/inline_article.md:32 +#: bot/osmbot.py:380 bot/templates/details_message.md:32 +#: bot/templates/inline_article.md:33 msgid "Asian country" msgstr "Азиатская страна" -#: bot/osmbot_blueprint.py:329 bot/osmbot_blueprint.py:331 -#: bot/templates/details_message.md:34 bot/templates/details_message.md:36 -#: bot/templates/inline_article.md:34 bot/templates/inline_article.md:36 +#: bot/osmbot.py:382 bot/osmbot.py:384 bot/templates/details_message.md:34 +#: bot/templates/details_message.md:36 bot/templates/inline_article.md:35 +#: bot/templates/inline_article.md:37 msgid "Oceanian country" msgstr "Страна из Океании" -#: bot/osmbot_blueprint.py:333 bot/osmbot_blueprint.py:335 -#: bot/templates/details_message.md:38 bot/templates/details_message.md:40 -#: bot/templates/inline_article.md:38 bot/templates/inline_article.md:40 +#: bot/osmbot.py:386 bot/osmbot.py:388 bot/templates/details_message.md:38 +#: bot/templates/details_message.md:40 bot/templates/inline_article.md:39 +#: bot/templates/inline_article.md:41 msgid "Eurasian country" msgstr "Евразийская страна" -#: bot/osmbot_blueprint.py:372 bot/osmbot_blueprint.py:374 -#: bot/templates/details_message.md:182 bot/templates/details_message.md:184 -#: bot/templates/inline_article.md:182 bot/templates/inline_article.md:184 +#: bot/osmbot.py:425 bot/osmbot.py:427 bot/templates/details_message.md:182 +#: bot/templates/details_message.md:184 bot/templates/inline_article.md:183 +#: bot/templates/inline_article.md:185 msgid "inhabitants" -msgstr "Жителей" +msgstr "жителей" -#: bot/osmbot_blueprint.py:372 bot/templates/details_message.md:182 -#: bot/templates/inline_article.md:182 +#: bot/osmbot.py:425 bot/templates/details_message.md:182 +#: bot/templates/inline_article.md:183 msgid "at" msgstr "в" -#: bot/osmbot_blueprint.py:377 bot/templates/details_message.md:187 -#: bot/templates/inline_article.md:187 +#: bot/osmbot.py:430 bot/templates/details_message.md:187 +#: bot/templates/inline_article.md:188 msgid "meters" msgstr "метров" -#: bot/osmbot_blueprint.py:390 bot/templates/details_message.md:198 +#: bot/osmbot.py:443 bot/templates/details_message.md:197 msgid "Raw data:" msgstr "Сырые данные:" -#: bot/osmbot_blueprint.py:417 bot/osmbot_blueprint.py:419 -#: bot/osmbot_blueprint.py:464 bot/osmbot_blueprint.py:467 -#: bot/osmbot_blueprint.py:492 bot/osmbot_blueprint.py:495 -#: bot/osmbot_blueprint.py:510 +#: bot/osmbot.py:492 bot/osmbot.py:543 bot/osmbot.py:546 bot/osmbot.py:567 +#: bot/osmbot.py:591 msgid "OSM contributors" msgstr "Участники OSM" -#: bot/osmbot_blueprint.py:428 bot/templates/send_location_message.md:1 +#: bot/osmbot.py:507 bot/templates/send_location_message.md:1 msgid "Please send me your location" msgstr "Пожалуйста, пришлите мне координаты" -#: bot/osmbot_blueprint.py:429 +#: bot/osmbot.py:508 msgid "to receive the map" msgstr "чтобы получить карту" -#: bot/osmbot_blueprint.py:430 bot/templates/send_location_message.md:2 +#: bot/osmbot.py:509 bot/templates/send_location_message.md:2 msgid "You can do it with the Telegram paperclip button" msgstr "Для этого есть кнопка со скрепкой в Телеграме" -#: bot/osmbot_blueprint.py:636 bot/templates/not_recognized_message.md:1 +#: bot/osmbot.py:713 bot/templates/not_recognized_message.md:1 msgid "" "Sorry, but now I can't recognize tags for this element, perhaps with my new " "features I will do it" msgstr "Увы, не могу распознать теги элемента. Может, в будущем научусь" -#: bot/osmbot_blueprint.py:644 bot/osmbot_blueprint.py:659 +#: bot/osmbot.py:721 bot/osmbot.py:736 msgid "Raw data for" msgstr "Сырые данные для" -#: bot/osmbot_blueprint.py:646 bot/osmbot_blueprint.py:661 +#: bot/osmbot.py:723 bot/osmbot.py:738 msgid "Raw data" msgstr "Сырые данные" -#: bot/osmbot_blueprint.py:809 +#: bot/osmbot.py:897 msgid "" "Please indicate what are you searching with command /search " msgstr "Что именно вы ищете? Напишите /search <строка_поиска>" -#: bot/osmbot_blueprint.py:815 +#: bot/osmbot.py:903 msgid "Use /search command to indicate what you are searching" msgstr "Укажите, что ищете, в параметре команды /search <строка_поиска>" -#: bot/osmbot_blueprint.py:899 +#: bot/osmbot_blueprint.py:97 msgid "" "OpenStreetMap bot finds any location in world from the Nominatim OSM " "database and can send links and maps from OSM" msgstr "Бот OpenStreetMap найдёт что угодно с помощью Nominatim и пришлёт ссылки и карты из OSM" -#: bot/osmbot_blueprint.py:900 +#: bot/osmbot_blueprint.py:98 msgid "" "OpenStreetMap bot finds any location in the world from the Nominatim OSM " "database" -msgstr "Бот OpenStreetMap найдёт любое место мира с помощью базы OSM Nominatim" +msgstr "Бот OpenStreetMap найдёт любое место мира с помощью OSM Nominatim" -#: bot/osmbot_blueprint.py:901 +#: bot/osmbot_blueprint.py:99 msgid "The bot can send links and maps (jpg, png or pdf) from OSM" -msgstr "Бот умеет присылать ссылки и карты OSM в формате jpg, png и pdf" +msgstr "Бот умеет присылать ссылки и карты OSM в форматах jpg, png и pdf" -#: bot/osmbot_blueprint.py:902 +#: bot/osmbot_blueprint.py:100 msgid "" "Data for all the world (cities and towns, shops -with phone number, " "email...-, Wikipedia links, etc)" msgstr "Данные обо всём мире (города и деревни, магазины — с телефоном и почтой, — ссылки на википедию и т.п.)" -#: bot/osmbot_blueprint.py:903 +#: bot/osmbot_blueprint.py:101 msgid "OSMbot is multilingual and speaks *your language here*" msgstr "OSMbot многоязычен и говорит на русском языке" @@ -269,11 +263,11 @@ msgstr "Перевод и адаптация" #: bot/templates/about_answer.md:9 msgid "DOCUMENTATION" -msgstr "" +msgstr "ДОКУМЕНТАЦИЯ " #: bot/templates/about_answer.md:10 msgid "OSMbot wiki" -msgstr "" +msgstr "OSMbot вики" #: bot/templates/about_answer.md:12 msgid "NEWS" @@ -281,7 +275,7 @@ msgstr "НОВОСТИ" #: bot/templates/about_answer.md:13 msgid "Twitter account" -msgstr "" +msgstr "Аккаунт Twitter" #: bot/templates/about_answer.md:14 msgid "Telegram channel" @@ -317,11 +311,11 @@ msgstr "пока что" #: bot/templates/cant_talk_message.md:2 msgid "But you can help me to learn it in Transifex" -msgstr "Поможешь научиться ему в Transifex?" +msgstr "Но вы можете помочь мне изучить его в Transifex" #: bot/templates/cant_understand_message.md:1 msgid "Sorry, I can't understand you" -msgstr "Извините, не понимаю" +msgstr "Извините, я не понимаю вас" #: bot/templates/cant_understand_message.md:2 msgid "Perhaps I could help you with the command /help" @@ -329,17 +323,17 @@ msgstr "Может, вам пригодится команда /help" #: bot/templates/configure_question.md:1 msgid "What do you want to configure?" -msgstr "Что настроим?" +msgstr "Что хотите настроить?" -#: bot/templates/details_message.md:42 bot/templates/inline_article.md:42 +#: bot/templates/details_message.md:42 bot/templates/inline_article.md:43 msgid "Flag" -msgstr "" +msgstr "Флаг" -#: bot/templates/details_message.md:191 bot/templates/inline_article.md:191 +#: bot/templates/details_message.md:191 bot/templates/inline_article.md:192 msgid "Wikidata" msgstr "Викиданные" -#: bot/templates/details_message.md:194 bot/templates/inline_article.md:194 +#: bot/templates/details_message.md:194 bot/templates/inline_article.md:195 msgid "Wikipedia" msgstr "Википедия" @@ -452,7 +446,7 @@ msgstr "Увы, не найти ничего по" #: bot/templates/not_found_message.md:2 msgid "But you can try to improve OpenStreetMap" -msgstr "Но вы можете добавить это в OpenStreetMap" +msgstr "Но вы можете попробовать улучшить OpenStreetMap" #: bot/templates/not_found_message.md:3 msgid "http://learnosm.org/en/" @@ -464,7 +458,7 @@ msgstr "Элемент не найден" #: bot/templates/not_implemented_message.md:1 msgid "Sorry but this query it's not implemented yet" -msgstr "Извините, эта команда пока не работает" +msgstr "Извините, но этот запрос пока не реализован" #: bot/templates/only_mention.md:1 msgid "Now I only will answer when mention" @@ -474,10 +468,6 @@ msgstr "Теперь я буду писать только в ответ" msgid "Should I answer without a mention?" msgstr "Стоит ли мне отвечать без упоминания" -#: bot/templates/question_only_mention.md:1 -msgid "Answer only when mention?" -msgstr "" - #: bot/templates/send_location_message.md:1 msgid "and I'll send you the nearest element" msgstr "и я отправлю вам ближайший элемент" diff --git a/bot/locales/sk/LC_MESSAGES/messages.mo b/bot/locales/sk/LC_MESSAGES/messages.mo index 9543d4d..d8920c3 100644 Binary files a/bot/locales/sk/LC_MESSAGES/messages.mo and b/bot/locales/sk/LC_MESSAGES/messages.mo differ diff --git a/bot/locales/sk/LC_MESSAGES/messages.po b/bot/locales/sk/LC_MESSAGES/messages.po index c93dc3f..54cddb5 100644 --- a/bot/locales/sk/LC_MESSAGES/messages.po +++ b/bot/locales/sk/LC_MESSAGES/messages.po @@ -9,9 +9,9 @@ msgid "" msgstr "" "Project-Id-Version: OSMbot\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2016-07-18 08:53+0200\n" -"PO-Revision-Date: 2016-07-18 08:42+0000\n" -"Last-Translator: Albert F \n" +"POT-Creation-Date: 2016-07-21 22:05+0200\n" +"PO-Revision-Date: 2016-08-18 21:30+0000\n" +"Last-Translator: Roman Horník \n" "Language-Team: Slovak (Slovakia) (http://www.transifex.com/osm-catala/osmbot/language/sk_SK/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -60,177 +60,170 @@ msgstr "Môžete skúsiť iné ohraničenie, alebo iné meradlo (úroveň pribl msgid "Good luck! " msgstr "Veľa šťastia!" -#: bot/osmbot_blueprint.py:195 +#: bot/osmbot.py:249 msgid "Results for" msgstr "Výsledky pre" -#: bot/osmbot_blueprint.py:218 +#: bot/osmbot.py:272 bot/templates/inline_article.md:198 msgid "Map" msgstr "Mapa" -#: bot/osmbot_blueprint.py:221 bot/osmbot_blueprint.py:223 -#: bot/osmbot_blueprint.py:225 bot/osmbot_blueprint.py:227 -#: bot/osmbot_blueprint.py:232 bot/osmbot_blueprint.py:234 -#: bot/osmbot_blueprint.py:236 bot/osmbot_blueprint.py:238 +#: bot/osmbot.py:275 bot/osmbot.py:277 bot/osmbot.py:279 bot/osmbot.py:281 +#: bot/osmbot.py:286 bot/osmbot.py:288 bot/osmbot.py:290 bot/osmbot.py:292 msgid "More info" msgstr "Viac informácií" -#: bot/osmbot_blueprint.py:228 +#: bot/osmbot.py:282 msgid "Phone" msgstr "Telefón" -#: bot/osmbot_blueprint.py:240 bot/osmbot_blueprint.py:398 -#: bot/osmbot_blueprint.py:653 bot/osmbot_blueprint.py:662 -#: bot/templates/details_message.md:200 bot/templates/inline_article.md:197 +#: bot/osmbot.py:294 bot/osmbot.py:451 bot/osmbot.py:730 bot/osmbot.py:739 +#: bot/templates/details_message.md:199 bot/templates/inline_article.md:200 msgid "OpenStreetMap contributors" msgstr "Prispievatelia OpenStreetMap" -#: bot/osmbot_blueprint.py:298 bot/osmbot_blueprint.py:301 -#: bot/osmbot_blueprint.py:303 bot/templates/details_message.md:2 -#: bot/templates/details_message.md:4 bot/templates/details_message.md:6 -#: bot/templates/inline_article.md:2 bot/templates/inline_article.md:4 -#: bot/templates/inline_article.md:6 +#: bot/osmbot.py:351 bot/osmbot.py:354 bot/osmbot.py:356 +#: bot/templates/details_message.md:2 bot/templates/details_message.md:4 +#: bot/templates/details_message.md:6 bot/templates/inline_article.md:2 +#: bot/templates/inline_article.md:4 bot/templates/inline_article.md:6 msgid "Tags for" msgstr "Značky pre" -#: bot/osmbot_blueprint.py:305 bot/osmbot_blueprint.py:307 -#: bot/templates/details_message.md:10 bot/templates/details_message.md:12 -#: bot/templates/inline_article.md:10 bot/templates/inline_article.md:12 +#: bot/osmbot.py:358 bot/osmbot.py:360 bot/templates/details_message.md:10 +#: bot/templates/details_message.md:12 bot/templates/inline_article.md:11 +#: bot/templates/inline_article.md:13 msgid "European country" msgstr "Európu" -#: bot/osmbot_blueprint.py:309 bot/templates/details_message.md:14 -#: bot/templates/inline_article.md:14 +#: bot/osmbot.py:362 bot/templates/details_message.md:14 +#: bot/templates/inline_article.md:15 msgid "African country" msgstr "Afriku" -#: bot/osmbot_blueprint.py:311 bot/osmbot_blueprint.py:313 -#: bot/osmbot_blueprint.py:315 bot/templates/details_message.md:16 -#: bot/templates/details_message.md:18 bot/templates/details_message.md:20 -#: bot/templates/inline_article.md:16 bot/templates/inline_article.md:18 -#: bot/templates/inline_article.md:20 +#: bot/osmbot.py:364 bot/osmbot.py:366 bot/osmbot.py:368 +#: bot/templates/details_message.md:16 bot/templates/details_message.md:18 +#: bot/templates/details_message.md:20 bot/templates/inline_article.md:17 +#: bot/templates/inline_article.md:19 bot/templates/inline_article.md:21 msgid "South american country" msgstr "Južnú Ameriku" -#: bot/osmbot_blueprint.py:317 bot/osmbot_blueprint.py:319 -#: bot/templates/details_message.md:22 bot/templates/details_message.md:24 -#: bot/templates/inline_article.md:22 bot/templates/inline_article.md:24 +#: bot/osmbot.py:370 bot/osmbot.py:372 bot/templates/details_message.md:22 +#: bot/templates/details_message.md:24 bot/templates/inline_article.md:23 +#: bot/templates/inline_article.md:25 msgid "North american country" msgstr "Severnú Ameriku" -#: bot/osmbot_blueprint.py:321 bot/templates/details_message.md:26 -#: bot/templates/inline_article.md:26 +#: bot/osmbot.py:374 bot/templates/details_message.md:26 +#: bot/templates/inline_article.md:27 msgid "Central american country" msgstr "Strednú Ameriku" -#: bot/osmbot_blueprint.py:323 bot/osmbot_blueprint.py:325 -#: bot/templates/details_message.md:28 bot/templates/details_message.md:30 -#: bot/templates/inline_article.md:28 bot/templates/inline_article.md:30 +#: bot/osmbot.py:376 bot/osmbot.py:378 bot/templates/details_message.md:28 +#: bot/templates/details_message.md:30 bot/templates/inline_article.md:29 +#: bot/templates/inline_article.md:31 msgid "American country" msgstr "Americký kontinent" -#: bot/osmbot_blueprint.py:327 bot/templates/details_message.md:32 -#: bot/templates/inline_article.md:32 +#: bot/osmbot.py:380 bot/templates/details_message.md:32 +#: bot/templates/inline_article.md:33 msgid "Asian country" msgstr "Áziu" -#: bot/osmbot_blueprint.py:329 bot/osmbot_blueprint.py:331 -#: bot/templates/details_message.md:34 bot/templates/details_message.md:36 -#: bot/templates/inline_article.md:34 bot/templates/inline_article.md:36 +#: bot/osmbot.py:382 bot/osmbot.py:384 bot/templates/details_message.md:34 +#: bot/templates/details_message.md:36 bot/templates/inline_article.md:35 +#: bot/templates/inline_article.md:37 msgid "Oceanian country" msgstr "Oceániu" -#: bot/osmbot_blueprint.py:333 bot/osmbot_blueprint.py:335 -#: bot/templates/details_message.md:38 bot/templates/details_message.md:40 -#: bot/templates/inline_article.md:38 bot/templates/inline_article.md:40 +#: bot/osmbot.py:386 bot/osmbot.py:388 bot/templates/details_message.md:38 +#: bot/templates/details_message.md:40 bot/templates/inline_article.md:39 +#: bot/templates/inline_article.md:41 msgid "Eurasian country" msgstr "Eurázijský kontinent" -#: bot/osmbot_blueprint.py:372 bot/osmbot_blueprint.py:374 -#: bot/templates/details_message.md:182 bot/templates/details_message.md:184 -#: bot/templates/inline_article.md:182 bot/templates/inline_article.md:184 +#: bot/osmbot.py:425 bot/osmbot.py:427 bot/templates/details_message.md:182 +#: bot/templates/details_message.md:184 bot/templates/inline_article.md:183 +#: bot/templates/inline_article.md:185 msgid "inhabitants" msgstr "obyvateľov" -#: bot/osmbot_blueprint.py:372 bot/templates/details_message.md:182 -#: bot/templates/inline_article.md:182 +#: bot/osmbot.py:425 bot/templates/details_message.md:182 +#: bot/templates/inline_article.md:183 msgid "at" msgstr "na" -#: bot/osmbot_blueprint.py:377 bot/templates/details_message.md:187 -#: bot/templates/inline_article.md:187 +#: bot/osmbot.py:430 bot/templates/details_message.md:187 +#: bot/templates/inline_article.md:188 msgid "meters" msgstr "metroch" -#: bot/osmbot_blueprint.py:390 bot/templates/details_message.md:198 +#: bot/osmbot.py:443 bot/templates/details_message.md:197 msgid "Raw data:" msgstr "Surová data:" -#: bot/osmbot_blueprint.py:417 bot/osmbot_blueprint.py:419 -#: bot/osmbot_blueprint.py:464 bot/osmbot_blueprint.py:467 -#: bot/osmbot_blueprint.py:492 bot/osmbot_blueprint.py:495 -#: bot/osmbot_blueprint.py:510 +#: bot/osmbot.py:492 bot/osmbot.py:543 bot/osmbot.py:546 bot/osmbot.py:567 +#: bot/osmbot.py:591 msgid "OSM contributors" msgstr "Prispievatelia OSM" -#: bot/osmbot_blueprint.py:428 bot/templates/send_location_message.md:1 +#: bot/osmbot.py:507 bot/templates/send_location_message.md:1 msgid "Please send me your location" msgstr "Prosím, povedzte mi svoju pozíciu" -#: bot/osmbot_blueprint.py:429 +#: bot/osmbot.py:508 msgid "to receive the map" msgstr "pre prijatie mapy" -#: bot/osmbot_blueprint.py:430 bot/templates/send_location_message.md:2 +#: bot/osmbot.py:509 bot/templates/send_location_message.md:2 msgid "You can do it with the Telegram paperclip button" msgstr "Môžete tak urobiť tlačidlom sponky Telegramu" -#: bot/osmbot_blueprint.py:636 bot/templates/not_recognized_message.md:1 +#: bot/osmbot.py:713 bot/templates/not_recognized_message.md:1 msgid "" "Sorry, but now I can't recognize tags for this element, perhaps with my new " "features I will do it" msgstr "Ospravedlňujem sa, ale zrovna sa mi nedarí rozpoznať značku tohto elementu, možno tak budem môcť urobiť s mojimi novými vlastnosťami" -#: bot/osmbot_blueprint.py:644 bot/osmbot_blueprint.py:659 +#: bot/osmbot.py:721 bot/osmbot.py:736 msgid "Raw data for" msgstr "Surová dáta pre" -#: bot/osmbot_blueprint.py:646 bot/osmbot_blueprint.py:661 +#: bot/osmbot.py:723 bot/osmbot.py:738 msgid "Raw data" msgstr "Surová dáta" -#: bot/osmbot_blueprint.py:809 +#: bot/osmbot.py:897 msgid "" "Please indicate what are you searching with command /search " msgstr "Prosím, uveďte čo hľadáte príkazom /search " -#: bot/osmbot_blueprint.py:815 +#: bot/osmbot.py:903 msgid "Use /search command to indicate what you are searching" msgstr "Použite príkaz /search pre vyhľadávanie" -#: bot/osmbot_blueprint.py:899 +#: bot/osmbot_blueprint.py:97 msgid "" "OpenStreetMap bot finds any location in world from the Nominatim OSM " "database and can send links and maps from OSM" msgstr "OpenStreetMap bot hľadá akékoľvek miesto na svete z OSM databázy Nominatim a môže odosielať odkazy a mapy z OSM" -#: bot/osmbot_blueprint.py:900 +#: bot/osmbot_blueprint.py:98 msgid "" "OpenStreetMap bot finds any location in the world from the Nominatim OSM " "database" msgstr "OpenStreetMap bot vyhľadáva akékoľvek miesto na svete z OSM databázy Nominatim" -#: bot/osmbot_blueprint.py:901 +#: bot/osmbot_blueprint.py:99 msgid "The bot can send links and maps (jpg, png or pdf) from OSM" msgstr "Bot vie z OSM posielať odkazy a mapy (jpg, png, alebo pdf)" -#: bot/osmbot_blueprint.py:902 +#: bot/osmbot_blueprint.py:100 msgid "" "Data for all the world (cities and towns, shops -with phone number, " "email...-, Wikipedia links, etc)" msgstr "Údaje pre celý svet (mestá a obce, obchody - s telefónnymi číslami, emailovými adresami, odkazy z Wikipédie atď.)" -#: bot/osmbot_blueprint.py:903 +#: bot/osmbot_blueprint.py:101 msgid "OSMbot is multilingual and speaks *your language here*" msgstr "OSM bot je viacjazyčný, vie aj po slovensky" @@ -268,11 +261,11 @@ msgstr "Lokalizácia" #: bot/templates/about_answer.md:9 msgid "DOCUMENTATION" -msgstr "" +msgstr "DOKUMENTÁCIA" #: bot/templates/about_answer.md:10 msgid "OSMbot wiki" -msgstr "" +msgstr "Wiki OSMbot" #: bot/templates/about_answer.md:12 msgid "NEWS" @@ -280,7 +273,7 @@ msgstr "NOVINKY" #: bot/templates/about_answer.md:13 msgid "Twitter account" -msgstr "" +msgstr "Účet Twitteru" #: bot/templates/about_answer.md:14 msgid "Telegram channel" @@ -330,15 +323,15 @@ msgstr "Možno vám pomôžem príkazom /help" msgid "What do you want to configure?" msgstr "Čo si prajete nastaviť?" -#: bot/templates/details_message.md:42 bot/templates/inline_article.md:42 +#: bot/templates/details_message.md:42 bot/templates/inline_article.md:43 msgid "Flag" -msgstr "" +msgstr "Vlajka" -#: bot/templates/details_message.md:191 bot/templates/inline_article.md:191 +#: bot/templates/details_message.md:191 bot/templates/inline_article.md:192 msgid "Wikidata" msgstr "Wikiúdaje" -#: bot/templates/details_message.md:194 bot/templates/inline_article.md:194 +#: bot/templates/details_message.md:194 bot/templates/inline_article.md:195 msgid "Wikipedia" msgstr "Wikipédia" @@ -473,10 +466,6 @@ msgstr "Teraz budem odpovedať pri zmienke" msgid "Should I answer without a mention?" msgstr "Mal by som odpovedať bez zmienky?" -#: bot/templates/question_only_mention.md:1 -msgid "Answer only when mention?" -msgstr "" - #: bot/templates/send_location_message.md:1 msgid "and I'll send you the nearest element" msgstr "a pošlem vám najbližší element" diff --git a/bot/osmbot.py b/bot/osmbot.py index b9e01c2..42d1e89 100644 --- a/bot/osmbot.py +++ b/bot/osmbot.py @@ -11,8 +11,14 @@ import overpass import telegram from uuid import uuid4 +import uuid from telegram import InlineQueryResultArticle, ParseMode, InputTextMessageContent, ReplyKeyboardMarkup, ReplyKeyboardHide from io import StringIO +from mapnik import Map, load_map, Box2d, render_to_file +import psycopg2 +import time +from multiprocessing import Process +import pyproj # local imports from bot.user import User @@ -22,6 +28,8 @@ from bot.overpass_query import type_query from bot.emojiflag import emojiflag from bot.error import OSMError +from bot.utils import get_data_db + def url_escape(s): @@ -34,6 +42,16 @@ def url_escape(s): return s.replace(' ', '%20').replace(')', '\\)') +def escape_underscoere(s): + """ + Used to escape underscores + + :param s: original text in data + :return: Escaped text + """ + return s.replace('_', '\\_') + + class OsmBot(object): # dict with all available languages # TODO(edgar): load this from a local config file. @@ -52,6 +70,7 @@ class OsmBot(object): 'Dutch': 'nl', 'Czech': 'cs', 'Persian': 'fa', + 'Portugese': 'pt', 'Japanese': 'ja', 'Ukrainian': 'uk', 'Chinese (Taiwan)': 'zh_TW', @@ -67,6 +86,7 @@ class OsmBot(object): """ Class that represents the OsmBot """ + def __init__(self, config, auto_init=True): """ Class constructor @@ -82,6 +102,12 @@ def __init__(self, config, auto_init=True): self.language = None self.telegram_api = None self.re_map = re.compile(" -?\d+(\.\d*)?,-?\d+(\.\d*)?,-?\d+(\.\d*)?,-?\d+(\.\d*)? ?(png|jpeg|pdf)? ?\d{0,2}") + self.db_host = '' + self.osm_db = '' + self.db = '' + self.db_user = '' + self.db_password = '' + # configure osmbot if auto_init: @@ -95,15 +121,25 @@ def init_config(self, config): :return: None """ + # TOOD(xevi): why Persian here? self.rtl_languages = ['fa'] # setup the database info from configobj import ConfigObj if config and isinstance(config, ConfigObj): - self.user = User( - config.get('host', ''), config.get('database', ''), - config.get('user', ''), config.get('password', '')) + if 'map_style' in config: + print('Loading map style') + self.map_style = Map(320, 320) + load_map(self.map_style, config['map_style']) + + self.db_host = config.get('host', '') + self.osm_db = config.get('osm_database', '') + self.db = config.get('database', '') + self.db_user = config.get('user', '') + self.db_password = config.get('password', '') + + self.user = User(self.db_host, self.db, self.db_user, self.db_password) else: raise OSMError('No config file: ' \ 'Please provide a ConfigObj object instance.') @@ -112,6 +148,7 @@ def init_config(self, config): # TODO(xevi): Should we set a default language? self.jinja_env = Environment(extensions=['jinja2.ext.i18n']) self.jinja_env.filters['url_escape'] = url_escape + self.jinja_env.filters['escape_underscoere'] = escape_underscoere self.language = None # setup the telegram API. Before check token existence @@ -122,6 +159,23 @@ def init_config(self, config): raise OSMError('No token in config file: ' \ 'Please check that token is in the config file.') + def set_group(self, is_group): + """ + Setter for the group property + + :param is_group: + :return: None + """ + self.is_group = is_group + + def get_group(self): + """ + Returns if the message is from a group + + :return: Boolean , true if its a group + """ + return self.is_group + def load_language(self, language): """ Function to load the language of the answer @@ -187,7 +241,7 @@ def _get_template(self, template_name): template_text = f.read() return self.jinja_env.from_string(template_text) - def set_only_mention(self, message, user_id, chat_id, user, group): + def set_only_mention(self, message, user_id, chat_id, user): """ Manages the set only mention requests @@ -195,16 +249,15 @@ def set_only_mention(self, message, user_id, chat_id, user, group): :param user_id: User id :param chat_id: Chat ud :param user: Dict with user configuration - :param group: Boolean to indicate if is a group :return: None """ onlymentions = message == 'Yes' - if group: - user.set_field(chat_id, 'onlymentions', onlymentions, group=group) - user.set_field(chat_id, 'mode', 'normal', group=group) + if self.get_group(): + user.set_field(chat_id, 'onlymentions', onlymentions, group=self.get_group()) + user.set_field(chat_id, 'mode', 'normal', group=self.get_group()) else: - user.set_field(user_id, 'onlymentions', onlymentions, group=group) - user.set_field(user_id, 'mode', 'normal', group=group) + user.set_field(user_id, 'onlymentions', onlymentions, group=self.get_group()) + user.set_field(user_id, 'mode', 'normal', group=self.get_group()) if not onlymentions: text = self._get_template('only_mention.md').render() self.telegram_api.sendMessage( @@ -220,9 +273,8 @@ def set_only_mention(self, message, user_id, chat_id, user, group): text, 'Markdown', reply_markup=ReplyKeyboardHide()) - return [] - def set_language_command(self, message, user_id, chat_id, u, group=False): + def set_language_command(self, message, user_id, chat_id, u): """ Answers the language command @@ -234,12 +286,12 @@ def set_language_command(self, message, user_id, chat_id, u, group=False): :return: None """ if message in self.get_languages(): - if group: - u.set_field(chat_id, 'lang', self.get_languages()[message], group=group) - u.set_field(chat_id, 'mode', 'normal', group=group) + if self.get_group(): + u.set_field(chat_id, 'lang', self.get_languages()[message], group=self.get_group()) + u.set_field(chat_id, 'mode', 'normal', group=self.get_group()) else: - u.set_field(user_id, 'lang', self.get_languages()[message], group=group) - u.set_field(user_id, 'mode', 'normal', group=group) + u.set_field(user_id, 'lang', self.get_languages()[message], group=self.get_group()) + u.set_field(user_id, 'mode', 'normal', group=self.get_group()) self.load_language(self.get_languages()[message]) template = self._get_template('new_language.md') text = template.render(is_rtl=self.get_is_rtl()) @@ -251,7 +303,7 @@ def set_language_command(self, message, user_id, chat_id, u, group=False): reply_markup=k) else: - if group: + if self.get_group(): u.set_field(chat_id, 'mode', 'normal', group=True) else: u.set_field(user_id, 'mode', 'normal') @@ -274,7 +326,7 @@ def answer_command(self, chat_id, user): self.telegram_api.sendMessage(chat_id, text, reply_markup=keyboard) user.set_field(chat_id, 'mode', 'setonlymention', group=True) - def language_command(self, message, user_id, chat_id, user, group=False): + def language_command(self, message, user_id, chat_id, user): """ Handles the Language command and sends the lis of languages @@ -282,19 +334,18 @@ def language_command(self, message, user_id, chat_id, user, group=False): :param user_id: User id :param chat_id: Chat id :param user: Dict with user configuration - :param group: Indicates if the message comes from a group :return: None """ languages = [[lang] for lang in sorted(self.get_languages().keys())] keyboard = ReplyKeyboardMarkup(languages, one_time_keyboard=True) text = self._get_template('language_answer.md').render() self.telegram_api.sendMessage(chat_id, text, reply_markup=keyboard) - if group: - user.set_field(chat_id, 'mode', 'setlanguage', group=group) + if self.get_group(): + user.set_field(chat_id, 'mode', 'setlanguage', group=self.get_group()) else: - user.set_field(user_id, 'mode', 'setlanguage', group=group) + user.set_field(user_id, 'mode', 'setlanguage', group=self.get_group()) - def settings_command(self, message, user_id, chat_id, u, group=False): + def settings_command(self, message, user_id, chat_id, u): """ Answers the settings command @@ -306,18 +357,18 @@ def settings_command(self, message, user_id, chat_id, u, group=False): :return: None """ - if group: + if self.get_group(): text = self._get_template('question_only_mention.md').render() k = ReplyKeyboardMarkup([['Language'], [text]], one_time_keyboard=True) else: k = ReplyKeyboardMarkup([['Language']], one_time_keyboard=True) text = self._get_template('configure_question.md').render() self.telegram_api.sendMessage(chat_id, text, reply_markup=k) - if group: + if self.get_group(): identifier = chat_id else: identifier = user_id - u.set_field(identifier, 'mode', 'settings', group=group) + u.set_field(identifier, 'mode', 'settings', group=self.get_group()) def legend_command(self, message, chat_id): """ @@ -642,7 +693,7 @@ def map_command(self, message, chat_id, user_id, user, zoom=None, imgformat='png bbox = genBBOX(lat, lon, halfside) try: data = download(bbox, _, imageformat=imgformat, zoom=zoom) - f = StringIO(data) + f = BytesIO(data) except ValueError as v: self.telegram_api.sendMessage(chat_id, v.message) else: @@ -684,7 +735,7 @@ def map_command(self, message, chat_id, user_id, user, zoom=None, imgformat='png user_config = user.get_user(user_id, group=False) lang = gettext.translation('messages', localedir='./bot/locales/', languages=[user_config['lang'], 'en']) data = download(bbox, lang.gettext, imageformat=imgformat, zoom=zoom) - f = StringIO(data) + f = BytesIO(data) except ValueError as v: self.telegram_api.sendMessage(chat_id, v.message) else: @@ -711,7 +762,7 @@ def map_command(self, message, chat_id, user_id, user, zoom=None, imgformat='png data = download( [bbox1, bbox2, bbox3, bbox4], _, imgformat, zoom=zoom) - f = StringIO(data) + f = BytesIO(data) except ValueError as v: self.telegram_api.sendMessage(chat_id, v.message) else: @@ -734,7 +785,7 @@ def map_command(self, message, chat_id, user_id, user, zoom=None, imgformat='png auto_scale = getScale([bbox[0], bbox[2], bbox[1], bbox[3]]) try: data = download([bbox[2], bbox[0], bbox[3], bbox[1]], _, scale=auto_scale) - f = StringIO(data) + f = BytesIO(data) except ValueError as v: self.telegram_api.sendMessage(chat_id, v.message) else: @@ -825,11 +876,19 @@ def details_command(self, message, user_config, chat_id): 'is_rtl': self.get_is_rtl() } text = template.render(**template_params) + raw_text = self._get_template('raw_data.md').render() + keyboard = [[InlineKeyboardButton( + raw_text, + callback_data='/raw{}{} {}'.format(element_type, identifier,chat_id) + )]] + reply_markup = InlineKeyboardMarkup(keyboard) self.telegram_api.sendMessage( chat_id, text, disable_web_page_preview=(not preview), - parse_mode='Markdown') + parse_mode='Markdown', + reply_markup=reply_markup + ) def nearest_command(self, message, chat_id, user_id, user, config=None, lat=None, lon=None, type=None, distance=None): """ @@ -928,7 +987,7 @@ def raw_command(self, message, chat_id): else: t = '\xE2\x9C\x8F '+_('Raw data') + '({0}/{1})\n\n'.format(parts, max_parts) t += '\n\xC2\xA9 ' + _('OpenStreetMap contributors') - self.telegram_api.sendMessage(chat_id, t) + self.telegram_api.sendMessage(chat_id, t, disable_web_page_preview=True) def answer_inline(self, message, query, user_config): """ @@ -948,7 +1007,7 @@ def answer_inline(self, message, query, user_config): inline_query_id = query['inline_query']['id'] results = [] if search_results: - for index, r in enumerate(search_results[:10]): + for index, r in enumerate(search_results[:5]): element_type = '' if r.get('osm_type', '') == 'node': element_type = 'nod' @@ -956,7 +1015,9 @@ def answer_inline(self, message, query, user_config): element_type = 'way' elif r.get('osm_type', '') == 'relation': element_type = 'rel' - osm_data = getData(r['osm_id'], geom_type=element_type) + osm_data = get_data_db(r['osm_id'], element_type, self.db_host, self.osm_db, self.db_user, self.db_password) + if osm_data == {}: + osm_data = getData(r['osm_id'], element_type) params = { 'data': osm_data, 'type': element_type, 'identifier': r['osm_id'], 'user_config': user_config, @@ -974,21 +1035,91 @@ def answer_inline(self, message, query, user_config): text, parse_mode=ParseMode.MARKDOWN))) else: + filename = self._check_render_cache(r['boundingbox']) + if not filename: + filename = str(uuid.uuid4())+'.png' + p = Process(target=self._render_map, args=(filename, r['boundingbox'])) + p.start() + print('http://xevib.ddns.net:81/osmbot/img/' + filename) + p = Process(target=self._add_render_cache, args=(filename, r['boundingbox'])) + p.start() + results.append(InlineQueryResultArticle( id=uuid4(), - title=osm_data['tag']['name'], + title=osm_data['tag'].get('name', r['display_name']), description=r['display_name'], + thumb_url='http://xevib.ddns.net:81/osmbot/img/' + filename, input_message_content=InputTextMessageContent( text, parse_mode=ParseMode.MARKDOWN))) - + time.sleep(4) self.telegram_api.answerInlineQuery( inline_query_id, results, is_personal=True, cache_time=86400) - def answer_message(self, message, query, chat_id, user_id, user_config, is_group, user, message_type): + def answer_callback(self, query): + """ + Handles the callbacks + + :param query: Query as dict + :return: None + """ + + data = query.get('callback_query', {}).get('data') + identifier = data.split()[-1] + command = data.split()[0] + self.raw_command(command, identifier) + + def _check_render_cache(self, bbox): + """ + Checks if a bbox is in the render cache + + :param bbox: List of bounding box + :return: Filename if it exists otherways None + """ + import logging + print('host:%s'% self.db_host) + print('database:%s' %self.db) + print('user:%s'% self.db_user) + print('password:%s'% self.db_password) + + conn = psycopg2.connect(host=self.db_host, database=self.db, user=self.db_user, password=self.db_password) + cur = conn.cursor() + sql = 'SELECT filename FROM render_cache where bbox=%s LIMIT 1;' + cur.execute(sql, (','.join(bbox),)) + data = cur.fetchone() + conn.close() + if data: + return data[0][0] + else: + return False + + def _add_render_cache(self, filename, bbox): + conn = psycopg2.connect(host=self.db_host, database=self.osm_db, + user=self.db_user, password=self.db_password) + cur = conn.cursor() + conn.commit() + conn.close() + + def _render_map(self, filename, bbox): + print('iniciant render') + import time + start = time.time() + final_url = os.path.join('/tmp/osmbot/img', filename) + wsg_84 = pyproj.Proj(init='epsg:4326') + dest_proj = pyproj.Proj(init='epsg:3857') + p1 = pyproj.transform(wsg_84, dest_proj, bbox[2], bbox[0]) + p2 = pyproj.transform(wsg_84, dest_proj, bbox[3], bbox[1]) + + mbbox = (Box2d(p1[0], p1[1], p2[0], p2[1])) + self.map_style.zoom_to_box(mbbox) + render_to_file(self.map_style, final_url) + end = time.time() + print('fet {} en {}'.format(final_url, end - start)) + + def answer_message(self, message, query, chat_id, user_id, user_config, user, message_type): """ Function that handles messages and sends to the concrete functions diff --git a/bot/osmbot_blueprint.py b/bot/osmbot_blueprint.py index 133c9d3..09fa580 100644 --- a/bot/osmbot_blueprint.py +++ b/bot/osmbot_blueprint.py @@ -33,24 +33,25 @@ def attend_webhook(token): user = u.User(config['host'], config['database'], config['user'], config['password']) current_app.logger.debug('token:%s', token) + osmbot.set_group(False) if token == config['token']: try: query = request.json + if 'edited_message' in query: return 'OK' - is_group = False message_type = '' if 'message' in query: message_dict = query['message'] message_type = 'query' if 'from' in message_dict and 'id' in message_dict['from']: - is_group = query['message']['chat']['type'] == u'group' - if is_group: + osmbot.set_group(query['message']['chat']['type'] == u'group') + if osmbot.get_group(): identifier = message_dict['chat']['id'] else: identifier = message_dict['from']['id'] - user_config = user.get_user(identifier, group=is_group) + user_config = user.get_user(identifier, group=osmbot.get_group()) user_id = message_dict['from']['id'] elif 'inline_query' in query: message_type = 'inline' @@ -69,16 +70,21 @@ def attend_webhook(token): message = '' chat_id = query['message']['chat']['id'] - if is_group and (not user_config['onlymentions'] and user_config['onlymentions'] is not None)and '@osmbot' not in message.lower(): + if osmbot.get_group() and (not user_config['onlymentions'] and user_config['onlymentions'] is not None)and '@osmbot' not in message.lower(): if message not in ['Yes', 'No', 'Language', 'Answer only when mention?'] and message not in osmbot.get_languages().keys(): return 'OK' else: message = message.replace('@osmbot', '') message = message.replace('@OSMbot', '') - - message = osmbot.clean_message(message) - osmbot.load_language(user_config['lang']) - osmbot.answer_message(message, query, chat_id, user_id, user_config, is_group, user, message_type) + if not 'callback_query' in query: + message = osmbot.clean_message(message) + osmbot.load_language(user_config['lang']) + if message_type == 'inline': + osmbot.answer_inline(message,query,user_config) + else: + osmbot.answer_message(message, query, chat_id, user_id, user_config, user, message_type) + else: + osmbot.answer_callback(query) return 'OK' except Exception as e: if e.message == 'Unauthorized': @@ -88,8 +94,9 @@ def attend_webhook(token): traceback.print_exc() current_app.sentry.captureException() osmbot.load_language(user_config['lang']) - text = osmbot._get_template('error_message.md').render() - telegram_api.sendMessage(chat_id, text) + if 'inline_query' not in request.json: + text = osmbot._get_template('error_message.md').render() + telegram_api.sendMessage(chat_id, text) return 'OK' else: return 'NOT ALLOWED' diff --git a/bot/templates/details_message.md b/bot/templates/details_message.md index 5397b42..77a08c7 100644 --- a/bot/templates/details_message.md +++ b/bot/templates/details_message.md @@ -194,6 +194,5 @@ {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F4D2'}} [{{_("Wikipedia")}}](http://wikipedia.org/wiki/{{data.tag["wikipedia"]|url_escape()}}) {% endif %}{% if 'wikidata' in data.tag or 'wikipedia' in data.tag %} {% endif -%} -{% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{_('Raw data:')}} /raw{{type}}{{identifier}} {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U000000A9'}} {{_('OpenStreetMap contributors')}} diff --git a/bot/templates/inline_article.md b/bot/templates/inline_article.md index bd56ba0..f6a19f1 100644 --- a/bot/templates/inline_article.md +++ b/bot/templates/inline_article.md @@ -44,7 +44,7 @@ {% endif %}{% if 'currency' in data.tag -%} {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F4B5'}} {{data.tag['currency']}} {% endif %}{% if 'timezone' in data.tag -%} -{% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F552'}}{{'\U0001F310'}} {{data.tag['timezone']}} +{% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F552'}}{{'\U0001F310'}} {{data.tag['timezone']|escape_underscoere()}} {% endif %}{% if 'is_in:continent' in data.tag or 'flag' in data.tag or 'currency' in data.tag or 'timezone' in data.tag %} {% endif -%} {% if 'addr:full' in data.tag -%} @@ -105,7 +105,7 @@ {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F513'}}{{'\U0001F695'}} {{data.tag['taxi']}} {% endif -%}{% if 'emergency' in data.tag -%} {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F513'}}{{'\U0001F6A8'}} {{data.tag['emergency']}} -{% endif -%}{% if 'ref' in data.tag or 'lanes' in data.tag or 'maxspeed' in data.tag or 'access' in data.tag or 'foot' in data.tag or 'horse' in data.tag or 'bicycle' in data.tag or 'motor_vehicle' in data.tag or 'motorcycle' in data.tag or 'motorcar' in data.tag or 'hgv' in data.tag or 'agricultural' in data.tag or 'bus' in data.tag or 'taxi' in data.tag or 'emergency' in data.tag in data.tag %} +{% endif -%}{% if 'ref' in data.tag or 'lanes' in data.tag or 'maxspeed' in data.tag or 'access' in data.tag or 'foot' in data.tag or 'horse' in data.tag or 'bicycle' in data.tag or 'motor_vehicle' in data.tag or 'motorcycle' in data.tag or 'motorcar' in data.tag or 'hgv' in data.tag or 'agricultural' in data.tag or 'bus' in data.tag or 'taxi' in data.tag or 'emergency' in data.tag %} {% endif -%} {% if 'phone' in data.tag -%} {% if is_rtl -%}{{'\U0000200F'}}{% endif -%}{{'\U0001F4DE'}} {% if is_rtl -%}{{'\U0000200E'}}{% endif -%}{{data.tag['phone']}} diff --git a/bot/templates/raw_data.md b/bot/templates/raw_data.md new file mode 100644 index 0000000..5e7a804 --- /dev/null +++ b/bot/templates/raw_data.md @@ -0,0 +1 @@ +{{_('Raw data')}} \ No newline at end of file diff --git a/bot/utils.py b/bot/utils.py index 31c0b2a..c132316 100644 --- a/bot/utils.py +++ b/bot/utils.py @@ -1,20 +1,42 @@ from osmapi import OsmApi +import psycopg2 -def getData(id, geom_type=None): +def get_data_db(idenfiticador, geom_type=None, host='localhost', database='osm', user=None, password=None): + """ + Returns the OpenStreetMap data from database + + :param idenfiticador: osm id + :param geom_type: type of geometry + :param host: Database host + :param database: Database + :param user: Database user + :param password: Database password + :return: + """ + conn = psycopg2.connect(host=host, database=database, user=user, password=password) + psycopg2.extras.register_hstore(conn) + cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) + + if geom_type == 'nod': + cursor.execute('SELECT tags FROM planet_osm_point WHERE osm_id=%s limit 1;', (idenfiticador,)) + elif geom_type == 'way': + cursor.execute('SELECT tags FROM planet_osm_line WHERE osm_id=%s limit 1;', (idenfiticador,)) + elif geom_type == 'rel': + cursor.execute('SELECT tags FROM planet_osm_polygon WHERE osm_id=%s limit 1;', (idenfiticador,)) + else: + return {} + data = cursor.fetchone() + if data: + return {'tag': data[0], 'id': idenfiticador} + else: + return {} + + +def getData(id, geom_type='nod'): osm_data = None api = OsmApi() - if geom_type is None: - try: - osm_data = api.NodeGet(int(id)) - if osm_data is None: - try: - osm_data = api.WayGet(int(id)) - except: - osm_data = api.RelationGet(int(id)) - except: - osm_data = None - elif geom_type == 'nod': + if geom_type == 'nod': osm_data = api.NodeGet(int(id)) elif geom_type == 'way': osm_data = api.WayGet(int(id)) diff --git a/requirements.txt b/requirements.txt index e45f025..3686275 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,4 +7,7 @@ psycopg2 overpass lxml osmapi -python-telegram-bot \ No newline at end of file +python-telegram-bot +pyproj +mapnik +blinker diff --git a/taginfo/taginfo.json b/taginfo/taginfo.json index bdc7336..396bf9a 100644 --- a/taginfo/taginfo.json +++ b/taginfo/taginfo.json @@ -1598,6 +1598,304 @@ "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/4b/d4/4bd4eef2e016e0e731adfd4bce01e26a.png" }, + { + "key": "addr:street", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:housenumber", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:housename", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:city", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:postcode", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:district", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:suburb", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:province", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:state", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "addr:country", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/23/3d/233d517b860f0aa185da2aed93fbe1da.png" + }, + { + "key": "ref", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/9c/ae/9caeec5f11cf26a686536f387877f2df.png" + }, + { + "key": "lanes", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message" + }, + { + "key": "maxspeed", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/65/31/653126960f1ab24587bb8acf6b535030.png" + }, + { + "key": "access", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "foot", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "horse", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "bicycle", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "motor_vehicle", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "motorcycle", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "motorcar", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "hgv", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "agricultural", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "bus", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "taxi", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "emergency", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/26/54/2654c152e37ab33dccd71f8b5606ee0e.png" + }, + { + "key": "phone", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/0e/46/0e467e6540da67b516e4008b09e51e5e.png" + }, + { + "key": "contact:phone", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/0e/46/0e467e6540da67b516e4008b09e51e5e.png" + }, + { + "key": "fax", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/88/b7/88b7ff5231da0ed737b75431838e64cc.png" + }, + { + "key": "contact:fax", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/88/b7/88b7ff5231da0ed737b75431838e64cc.png" + }, + { + "key": "email", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/4f/be/4fbe8b8445664253650cb40ccafb351b.png" + }, + { + "key": "contact:email", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/4f/be/4fbe8b8445664253650cb40ccafb351b.png" + }, + { + "key": "website", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/db/40/db40b90186e898fbad7384a0c1209b66.png" + }, + { + "key": "contact:website", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/db/40/db40b90186e898fbad7384a0c1209b66.png" + }, + { + "key": "opening_hours", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/9c/99/9c9962be511897c3b3ac524e69b58187.png" + }, + { + "key": "internet_access", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/dd/a8/dda83c2f603a722724f7503f10e71f7e.png" + }, + { + "key": "internet_access:fee", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message" + }, + { + "key": "rooms", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/2a/80/2a80a079191d67b5f01e8f19eb94942d.png" + }, + { + "key": "beds", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/68/cf/68cfeb85990b3b70ec7ace2799c603b1.png" + }, + { + "key": "toilets", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/01/ad/01adc45a08e796991fc740bc8b576850.png" + }, + { + "key": "wheelchair", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/c2/ac/c2acf72025e32c618ede65db686d2218.png" + }, + { + "key": "toilets:wheelchair", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message" + }, + { + "key": "dogs", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/1c/e9/1ce945f364719c92f31d1d3a359a213f.png" + }, + { + "key": "smoking", + "object_types": ["way", "area", "node", "relation"], + "description": "Used in Details message and Inline bot answer", + "doc_url": "https://github.com/Xevib/osmbot/wiki/details#info-in-details-message", + "icon_url": "http://emojipedia-us.s3.amazonaws.com/cache/28/fd/28fdb0f2484625057bf1fbb31e3d9c9a.png" + }, { "key": "wikidata", "object_types": ["way", "area", "node", "relation"], diff --git a/test/test.py b/test/test.py index 5a5dce6..aebbda2 100644 --- a/test/test.py +++ b/test/test.py @@ -1,14 +1,18 @@ # -*- coding: UTF-8 -*- -from __future__ import absolute_import +from __future__ import absolute_import, unicode_literals import unittest import os +from six.moves import reload_module import sys -reload(sys) +reload_module(sys) sys.setdefaultencoding('utf-8') from bot.osmbot import OsmBot from bot.error import OSMError +from bot.utils import getData +from bot.user import User +from configobj import ConfigObj class OsmBotMock(OsmBot): @@ -17,18 +21,32 @@ def __init__(self, *args, **kwargs): class BotTest(unittest.TestCase): - # instantiate OsmBotMock class - b = OsmBotMock({}, auto_init=False) + """ + Unittest for the bot + """ + def setUp(self): + """ + Unittest setup + :return: Noe + """ + # instantiate OsmBotMock class + config = { + 'host': 'localhost', + 'database': 'bot', + 'user': 'postgres', + 'token': '32111224414:AAF0BqwSgFKTzkgTkJLcLBKVb2ebrSXbWX4' + } + self.osmbot = OsmBotMock(ConfigObj(config), auto_init=True) def test_config_file(self): """ - Test for configuraciont file + Test for configuration file :return:None """ from configobj import ConfigObj config = ConfigObj('test/bot.conf') - + self.assertEqual(config['database' ], 'bot') self.assertEqual(config['user' ], 'postgres') self.assertEqual(config['host' ], '127.0.0.1') @@ -48,12 +66,12 @@ def test_init_config_error(self): from configobj import ConfigObj config = ConfigObj() - + # no config and empty config - self.assertRaises(OSMError, self.b.init_config, 0) - self.assertRaises(OSMError, self.b.init_config, True) - self.assertRaises(OSMError, self.b.init_config, 'random_string') - self.assertRaises(OSMError, self.b.init_config, config) + self.assertRaises(OSMError, self.osmbot.init_config, 0) + self.assertRaises(OSMError, self.osmbot.init_config, True) + self.assertRaises(OSMError, self.osmbot.init_config, 'random_string') + self.assertRaises(OSMError, self.osmbot.init_config, config) def test_init_config(self): from configobj import ConfigObj @@ -74,9 +92,9 @@ def test_languages(self): msg = '{} not found in directory in avaible languages but found in bo/locales' for lang_dir in lang_dirs: is_dir = os.path.isdir(os.path.join('bot/locales', lang_dir)) - if is_dir and lang_dir not in self.b.get_languages().values(): + if is_dir and lang_dir not in self.osmbot.get_languages().values(): print(msg.format(lang_dir)) - self.assertTrue(lang_dir in self.b.get_languages().values()) + self.assertTrue(lang_dir in self.osmbot.get_languages().values()) def test_templates(self): """ @@ -99,6 +117,23 @@ def test_templates(self): except exceptions.UndefinedError: pass + def test_getData(self): + getData(343535, 'rel') + getData(423454728, 'way') + getData(2482096156, 'nod') + + def test_user(self): + u = User('localhost', 'bot', 'postgres', 'empty') + + def test_render_cache(self): + """ + Test to check the render_cache method + :return: None + """ + + self.assertFalse(self.osmbot._check_render_cache('')) + self.assertEqual(self.osmbot._check_render_cache('1,1,1,1'), 'ok') + if __name__ == '__main__': unittest.main()