{"id":368075,"date":"2024-05-21T03:34:59","date_gmt":"2024-05-21T03:34:59","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=368075"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=368075","title":{"rendered":"<span>Telegram bot \u0434\u043b\u044f \u043d\u0430\u0448\u0438\u0445 bmw G \u0441\u0435\u0440\u0438\u0438 \u0447\u0430\u0441\u0442\u044c 2<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/793112\/\" rel=\"noopener noreferrer nofollow\"><u>\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/u><\/a> \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0437\u0430\u0447\u0435\u043c \u043c\u043d\u0435 \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0430\u0434\u043e \u0438 \u0434\u0430\u043b \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 &#8212; \u043a\u0430\u043a \u044f \u0434\u043e\u0441\u0442\u0430\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0430\u0432\u0442\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0432\u044b\u0441\u043b\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0443 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0432\u043e\u0442 \u044d\u0442\u0438\u0445:<\/p>\n<figure class=\"float full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/96f\/004\/a56\/96f004a56775ae92d1e51d8613af125d.png\" width=\"740\" height=\"959\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/96f\/004\/a56\/96f004a56775ae92d1e51d8613af125d.png\"\/><\/figure>\n<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p><code>pip install logging<\/code><br \/><code>pip install telebot<\/code><br \/><code>pip install http.client<\/code><br \/><code>pip install schedule<\/code><br \/><code>pip install time<\/code><br \/><code>pip install math<\/code><\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0421\u043a\u0435\u0434\u0443\u043b\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437 \u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a-\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043f\u043b\u0438\u0432\u0430.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0441\u044b\u043b\u0430\u0442\u044c \u0432 \u0442\u0435\u043b\u0435\u0433\u0443 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e TOKEN. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 <a href=\"https:\/\/t.me\/BotFather\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/BotFather<\/a> \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \/newbot. \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0438\u043c\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u0432\u0443\u0430\u043b\u044f &#8212; \u0431\u043e\u0442 \u0433\u043e\u0442\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0422\u041e\u041a\u0415\u041d \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e73\/2b2\/b8c\/e732b2b8c8c5336697973382b9b003e0.png\" width=\"729\" height=\"714\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e73\/2b2\/b8c\/e732b2b8c8c5336697973382b9b003e0.png\"\/><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u0442\u043e\u043c \u044f \u0432\u044b\u0431\u0440\u0430\u043b telebot, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041c\u0435\u043d\u044f \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u043e, \u0442\u043e \u0447\u0442\u043e telebot \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u0432\u0435\u043b\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043c\u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">def haversine(lat1, lon1, lat2, lon2):     # \u0420\u0430\u0434\u0438\u0443\u0441 \u0417\u0435\u043c\u043b\u0438 \u0432 \u043a\u043c     R = 6371.0     # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u044b     lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])     # \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0448\u0438\u0440\u043e\u0442\u0430\u043c\u0438 \u0438 \u0434\u043e\u043b\u0433\u043e\u0442\u0430\u043c\u0438     dlat = lat2 - lat1     dlon = lon2 - lon1     # \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0433\u0430\u0432\u0435\u0440\u0441\u0438\u043d\u0443\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f     a = sin(dlat \/ 2)**2 + cos(lat1) * cos(lat2) * sin(dlon \/ 2)**2     c = 2 * atan2(sqrt(a), sqrt(1 - a))     # \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438     distance = R * c     return distance  def check_proximity(lat1, lon1, lat2, lon2, radius=1.0):     # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 (lat1, lon1) \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u043e\u0442 \u0442\u043e\u0447\u043a\u0438 (lat2, lon2)     distance = haversine(lat1, lon1, lat2, lon2)     return distance &lt;= radius<\/code><\/pre>\n<p>\u0411\u0435\u0440\u0435\u043c \u0434\u0432\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u043b\u043e\u043a\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u0434\u0438\u0443\u0441\u0435 1 \u043a\u043c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c TRUE. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u043b\u043e\u043a\u0430\u0446\u0438\u044e \u0430\u0432\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043d\u0438\u0436\u0435, \u0434\u0430, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u0435\u0435, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442)). \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0437\u0430\u043c\u0430\u0437\u0430\u043b&#8230;<\/p>\n<pre><code class=\"python\">def run_periodic_notificationX3_location():     asyncio.run(periodic_notificationX3_location(chat_id))   async def periodic_notificationX3_location(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Checking of X3 location\ufe0f \")     print(\"Checking of X3 location\")     # \u041a\u043e\u0441\u0442\u0440\u043e\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430     target_KF_lon = 40.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KF_lat = 57.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443     # \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e          target_KAL_lon = 40.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KAL_lat = 57.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443      conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)           print(row[1])     print(row[2])     global Flat_location     global Kalinino_location     global previous_lat     global previous_lon          if row:         current_lat = row[1]         bot.send_message(chat_id, current_lat)         current_lon = row[2]         bot.send_message(chat_id, current_lon)                           # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435         if Flat_location and not check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n')             Flat_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if Kalinino_location and not check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443         if not Flat_location and check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n\")             bot.send_message(chat_id, 'X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n')             Flat_location = True          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if not Kalinino_location and check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = True          # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)         previous_lat = current_lat         previous_lon = current_lon         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)     else:         print(\"\u041d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0435.\") <\/code><\/pre>\n<p>\u0422\u043e\u043f\u043b\u0438\u0432\u043e \u0432 \u0431\u0430\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def run_periodic_notificationX3():     asyncio.run(periodic_notificationX3(chat_id))   async def periodic_notificationX3(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Testing \ufe0fX3 \")     print(\"test X3\")     conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)     fuel_value = row[3]     if fuel_value &lt;= 10.0:         bot.send_message(chat_id, f'\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u043e\u043f\u043b\u0438\u0432\u0430: {fuel_value} \u043b\u0438\u0442\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u04253\\n')<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u043a\u0435\u0434\u0443\u043b\u0435\u0440\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c &#8212; \u0434\u043b\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437 \u0432 30 \u043c\u0438\u043d\u0443\u0442, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u0442\u043e\u043f\u043b\u0438\u0432\u0430 &#8212; \u0440\u0430\u0437 \u0432 120 \u043c\u0438\u043d\u0443\u0442. \u0421\u0430\u043c\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u044e \u0440\u0430\u0437 \u0432 30 \u043c\u0438\u043d\u0443\u0442, \u0438\u0431\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0447\u0430\u0449\u0435 \u043f\u043e\u0431\u043e\u044f\u043b\u0441\u044f, \u0447\u0442\u043e BMW \u0437\u0430\u0431\u0430\u043d\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0447\u0430\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. <\/p>\n<pre><code class=\"python\">schedule.every(120).minutes.do(lambda: asyncio.run(periodic_notificationX3(chat_id))) schedule.every(30).minutes.do(lambda: asyncio.run(periodic_notificationX3_location(chat_id)))<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043c\u0435\u043d\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<pre><code class=\"python\"> #telegramm bot notification import logging import telebot import http.client import schedule import time import asyncio import sqlite3 from math import radians, sin, cos, sqrt, atan2 Flat_location = False  # \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u0430 \u043d\u0435 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435 Kalinino_location = False  # \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u0430 \u043d\u0435 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e # \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043c\u0430\u0448\u0438\u043d\u044b previous_lon = 40.XXX previous_lat = 57.XXX   def haversine(lat1, lon1, lat2, lon2):     # \u0420\u0430\u0434\u0438\u0443\u0441 \u0417\u0435\u043c\u043b\u0438 \u0432 \u043a\u043c     R = 6371.0     # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u044b     lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])     # \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0448\u0438\u0440\u043e\u0442\u0430\u043c\u0438 \u0438 \u0434\u043e\u043b\u0433\u043e\u0442\u0430\u043c\u0438     dlat = lat2 - lat1     dlon = lon2 - lon1     # \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0433\u0430\u0432\u0435\u0440\u0441\u0438\u043d\u0443\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f     a = sin(dlat \/ 2)**2 + cos(lat1) * cos(lat2) * sin(dlon \/ 2)**2     c = 2 * atan2(sqrt(a), sqrt(1 - a))     # \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438     distance = R * c     return distance  def check_proximity(lat1, lon1, lat2, lon2, radius=1.0):     # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 (lat1, lon1) \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u043e\u0442 \u0442\u043e\u0447\u043a\u0438 (lat2, lon2)     distance = haversine(lat1, lon1, lat2, lon2)     return distance &lt;= radius  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 'YOUR_BOT_TOKEN' \u043d\u0430 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442 BotFather TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' bot = telebot.TeleBot(TOKEN) chat_id = XXXXXXXXXXXXXX # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 asyncio.run() def run_periodic_notificationX3():     asyncio.run(periodic_notificationX3(chat_id))   async def periodic_notificationX3(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Testing \ufe0fX3 \")     print(\"test X3\")     conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)     fuel_value = row[3]     if fuel_value &lt;= 10.0:         bot.send_message(chat_id, f'\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u043e\u043f\u043b\u0438\u0432\u0430: {fuel_value} \u043b\u0438\u0442\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u04253\\n')   def run_periodic_notificationX3_location():     asyncio.run(periodic_notificationX3_location(chat_id))   async def periodic_notificationX3_location(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Checking of X3 location\ufe0f \")     print(\"Checking of X3 location\")     # \u041a\u043e\u0441\u0442\u0440\u043e\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430     target_KF_lon = 40.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KF_lat = 57.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443     # \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e          target_KAL_lon = 40.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KAL_lat = 57.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443      conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)           print(row[1])     print(row[2])     global Flat_location     global Kalinino_location     global previous_lat     global previous_lon          if row:         current_lat = row[1]         bot.send_message(chat_id, current_lat)         current_lon = row[2]         bot.send_message(chat_id, current_lon)                  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435         if Flat_location and not check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n')             Flat_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if Kalinino_location and not check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443         if not Flat_location and check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n\")             bot.send_message(chat_id, 'X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n')             Flat_location = True          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if not Kalinino_location and check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = True          # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)         previous_lat = current_lat         previous_lon = current_lon         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)     else:         print(\"\u041d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0435.\")  # \u0420\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0440\u0430\u0437 \u0432 \u043f\u043e\u043b\u0447\u0430\u0441\u0430 schedule.every(120).minutes.do(lambda: asyncio.run(periodic_notificationX3(chat_id))) schedule.every(30).minutes.do(lambda: asyncio.run(periodic_notificationX3_location(chat_id)))  # \u0424\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435 def main():     pass   if __name__ == '__main__':     while True:         try:             main()             schedule.run_pending()         except Exception as e:             print(f\"\u041f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430 \u043e\u0448\u0438\u0431\u043a\u0430: {e}\")             time.sleep(600)         time.sleep(1)       <\/code><\/pre>\n<p>\u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0437\u0430\u043a\u0440\u044b\u0442\u044b \u0425\u0425\u0425, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<p>\u041a\u043e\u0434 \u0432\u044b\u0448\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u0442\u0430\u043a \u043b\u0435\u043d\u044c \u0447\u0442\u043e \u0442\u043e \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u044b\u0432\u0430\u0442\u044c)&#8230;<\/p>\n<p>\u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043a\u043e\u0434\u0430 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 \u0443\u0436\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e, \u043d\u043e \u0441\u043e \u0448\u0442\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u0430 \u0438 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u044b\u043c \u043f\u043e\u0441\u0442\u043e\u044f\u043d\u043d\u043e Python. \u041c\u043d\u0435 \u044d\u0442\u043e\u0433\u043e \u0431\u044b\u043b\u043e \u043d\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u044f \u0445\u043e\u0442\u0435\u043b \u0438\u043c\u0435\u0442\u044c \u043f\u043e\u043b\u043d\u0443\u044e \u0430\u0432\u0442\u043e\u043d\u043e\u043c\u043d\u043e\u0441\u0442\u044c \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 \u043d\u0430 VPS, \u0432\u044b\u0434\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430 \u043d\u0430 WEB, \u043d\u0443 \u0438\u043b\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u043b\u0435\u0444\u043e\u043d\u0430&#8230; \u041e\u0431 \u044d\u0442\u043e\u043c \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0435 \u0441\u043b\u0435\u0434\u0443\u0435\u0442&#8230;<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/793394\/\"> https:\/\/habr.com\/ru\/articles\/793394\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0412 <a href=\"https:\/\/habr.com\/ru\/articles\/793112\/\" rel=\"noopener noreferrer nofollow\"><u>\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/u><\/a> \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u043b\u0441\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0437\u0430\u0447\u0435\u043c \u043c\u043d\u0435 \u044d\u0442\u043e \u0432\u0441\u0435 \u043d\u0430\u0434\u043e \u0438 \u0434\u0430\u043b \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0435 &#8212; \u043a\u0430\u043a \u044f \u0434\u043e\u0441\u0442\u0430\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u0430\u0432\u0442\u043e. \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c\u0441\u044f \u043a\u0430\u043a \u0432\u044b\u0441\u043b\u0430\u0442\u044c \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0442\u0435\u043b\u0435\u0433\u0443 \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u043e\u0434\u043e\u0431\u0438\u0435 \u0432\u043e\u0442 \u044d\u0442\u0438\u0445:<\/p>\n<figure class=\"float full-width\"><\/figure>\n<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0434\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438.<\/p>\n<p><code>pip install logging<\/code><br \/><code>pip install telebot<\/code><br \/><code>pip install http.client<\/code><br \/><code>pip install schedule<\/code><br \/><code>pip install time<\/code><br \/><code>pip install math<\/code><\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0421\u043a\u0435\u0434\u0443\u043b\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437 \u0432 \u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0442\u044c \u043b\u043e\u043a\u0430\u0446\u0438\u0438, \u0430 \u0442\u0430\u043a-\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043f\u043b\u0438\u0432\u0430.<\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0431\u0443\u0434\u0435\u043c \u0432\u044b\u0441\u044b\u043b\u0430\u0442\u044c \u0432 \u0442\u0435\u043b\u0435\u0433\u0443 \u0447\u0435\u0440\u0435\u0437 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430.<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0435\u0433\u043e TOKEN. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0443 <a href=\"https:\/\/t.me\/BotFather\" rel=\"noopener noreferrer nofollow\">https:\/\/t.me\/BotFather<\/a> \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u043c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u044b \/newbot. \u0414\u0430\u043b\u0435\u0435 \u043d\u0430\u0434\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u0432\u0435\u0441\u0442\u0438 \u0438\u043c\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u0431\u043e\u0442\u0430 \u0438 \u0432\u0443\u0430\u043b\u044f &#8212; \u0431\u043e\u0442 \u0433\u043e\u0442\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0439 \u0422\u041e\u041a\u0415\u041d \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u043d.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u043e\u0442\u043e\u043c \u044f \u0432\u044b\u0431\u0440\u0430\u043b telebot, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u043d\u0435 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u041c\u0435\u043d\u044f \u0443\u0441\u0442\u0440\u043e\u0438\u043b\u043e, \u0442\u043e \u0447\u0442\u043e telebot \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u0432\u0435\u043b\u0441\u044f \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/p>\n<p>\u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043f\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0442\u043e\u0447\u043a\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0438\u043b \u043c\u043d\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435.<\/p>\n<pre><code class=\"python\">def haversine(lat1, lon1, lat2, lon2):     # \u0420\u0430\u0434\u0438\u0443\u0441 \u0417\u0435\u043c\u043b\u0438 \u0432 \u043a\u043c     R = 6371.0     # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u044b     lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])     # \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0448\u0438\u0440\u043e\u0442\u0430\u043c\u0438 \u0438 \u0434\u043e\u043b\u0433\u043e\u0442\u0430\u043c\u0438     dlat = lat2 - lat1     dlon = lon2 - lon1     # \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0433\u0430\u0432\u0435\u0440\u0441\u0438\u043d\u0443\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f     a = sin(dlat \/ 2)**2 + cos(lat1) * cos(lat2) * sin(dlon \/ 2)**2     c = 2 * atan2(sqrt(a), sqrt(1 - a))     # \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438     distance = R * c     return distance  def check_proximity(lat1, lon1, lat2, lon2, radius=1.0):     # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 (lat1, lon1) \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u043e\u0442 \u0442\u043e\u0447\u043a\u0438 (lat2, lon2)     distance = haversine(lat1, lon1, lat2, lon2)     return distance &lt;= radius<\/code><\/pre>\n<p>\u0411\u0435\u0440\u0435\u043c \u0434\u0432\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u0438\u0445 \u043b\u043e\u043a\u0430\u0446\u0438\u0438. \u0415\u0441\u043b\u0438 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u0432 \u0440\u0430\u0434\u0438\u0443\u0441\u0435 1 \u043a\u043c, \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c TRUE. \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u043b\u043e\u043a\u0430\u0446\u0438\u044e \u0430\u0432\u0442\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e\u0439 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439. \u041d\u043e \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0438\u0436\u0435.<\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043b \u043d\u0438\u0436\u0435, \u0434\u0430, \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0449\u0435 \u0438 \u0433\u0440\u0430\u043c\u043e\u0442\u043d\u0435\u0435, \u043d\u043e \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043c\u0435\u043d\u044f \u0432\u0441\u0435 \u0443\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u0442)). \u041a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0437\u0430\u043c\u0430\u0437\u0430\u043b&#8230;<\/p>\n<pre><code class=\"python\">def run_periodic_notificationX3_location():     asyncio.run(periodic_notificationX3_location(chat_id))   async def periodic_notificationX3_location(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Checking of X3 location\ufe0f \")     print(\"Checking of X3 location\")     # \u041a\u043e\u0441\u0442\u0440\u043e\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430     target_KF_lon = 40.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KF_lat = 57.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443     # \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e          target_KAL_lon = 40.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KAL_lat = 57.XXXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443      conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)           print(row[1])     print(row[2])     global Flat_location     global Kalinino_location     global previous_lat     global previous_lon          if row:         current_lat = row[1]         bot.send_message(chat_id, current_lat)         current_lon = row[2]         bot.send_message(chat_id, current_lon)                           # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435         if Flat_location and not check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n')             Flat_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if Kalinino_location and not check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443         if not Flat_location and check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n\")             bot.send_message(chat_id, 'X3 \u0443 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u044b\\n')             Flat_location = True          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if not Kalinino_location and check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = True          # \u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)         previous_lat = current_lat         previous_lon = current_lon         bot.send_message(chat_id, previous_lat)         bot.send_message(chat_id, previous_lon)     else:         print(\"\u041d\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0431\u0430\u0437\u0435.\") <\/code><\/pre>\n<p>\u0422\u043e\u043f\u043b\u0438\u0432\u043e \u0432 \u0431\u0430\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u0435\u0437 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"python\">def run_periodic_notificationX3():     asyncio.run(periodic_notificationX3(chat_id))   async def periodic_notificationX3(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Testing \ufe0fX3 \")     print(\"test X3\")     conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)     fuel_value = row[3]     if fuel_value &lt;= 10.0:         bot.send_message(chat_id, f'\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u043e\u043f\u043b\u0438\u0432\u0430: {fuel_value} \u043b\u0438\u0442\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u04253\\n')<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432 \u0441\u043a\u0435\u0434\u0443\u043b\u0435\u0440\u0435 \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u043d\u043e\u0441\u0442\u044c &#8212; \u0434\u043b\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0440\u0430\u0437 \u0432 30 \u043c\u0438\u043d\u0443\u0442, \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0443\u0440\u043e\u0432\u043d\u044f \u0442\u043e\u043f\u043b\u0438\u0432\u0430 &#8212; \u0440\u0430\u0437 \u0432 120 \u043c\u0438\u043d\u0443\u0442. \u0421\u0430\u043c\u0443 \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043f\u043e\u043b\u043d\u044f\u044e \u0440\u0430\u0437 \u0432 30 \u043c\u0438\u043d\u0443\u0442, \u0438\u0431\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0447\u0430\u0449\u0435 \u043f\u043e\u0431\u043e\u044f\u043b\u0441\u044f, \u0447\u0442\u043e BMW \u0437\u0430\u0431\u0430\u043d\u0438\u0442 \u0438\u0437-\u0437\u0430 \u0447\u0430\u0441\u0442\u044b\u0445 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. <\/p>\n<pre><code class=\"python\">schedule.every(120).minutes.do(lambda: asyncio.run(periodic_notificationX3(chat_id))) schedule.every(30).minutes.do(lambda: asyncio.run(periodic_notificationX3_location(chat_id)))<\/code><\/pre>\n<p>\u0410 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0438\u0436\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0443 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u043c \u0431\u043e\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443 \u043c\u0435\u043d\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<pre><code class=\"python\"> #telegramm bot notification import logging import telebot import http.client import schedule import time import asyncio import sqlite3 from math import radians, sin, cos, sqrt, atan2 Flat_location = False  # \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u0430 \u043d\u0435 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435 Kalinino_location = False  # \u0418\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e \u0441\u0447\u0438\u0442\u0430\u0435\u043c, \u0447\u0442\u043e \u043c\u0430\u0448\u0438\u043d\u0430 \u043d\u0435 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e # \u041f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043c\u0430\u0448\u0438\u043d\u044b previous_lon = 40.XXX previous_lat = 57.XXX   def haversine(lat1, lon1, lat2, lon2):     # \u0420\u0430\u0434\u0438\u0443\u0441 \u0417\u0435\u043c\u043b\u0438 \u0432 \u043a\u043c     R = 6371.0     # \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u044b     lat1, lon1, lat2, lon2 = map(radians, [lat1, lon1, lat2, lon2])     # \u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043c\u0435\u0436\u0434\u0443 \u0448\u0438\u0440\u043e\u0442\u0430\u043c\u0438 \u0438 \u0434\u043e\u043b\u0433\u043e\u0442\u0430\u043c\u0438     dlat = lat2 - lat1     dlon = lon2 - lon1     # \u0424\u043e\u0440\u043c\u0443\u043b\u0430 \u0433\u0430\u0432\u0435\u0440\u0441\u0438\u043d\u0443\u0441\u0430 \u0434\u043b\u044f \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f \u0440\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u044f     a = sin(dlat \/ 2)**2 + cos(lat1) * cos(lat2) * sin(dlon \/ 2)**2     c = 2 * atan2(sqrt(a), sqrt(1 - a))     # \u0420\u0430\u0441\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0434\u0432\u0443\u043c\u044f \u0442\u043e\u0447\u043a\u0430\u043c\u0438     distance = R * c     return distance  def check_proximity(lat1, lon1, lat2, lon2, radius=1.0):     # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 (lat1, lon1) \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0440\u0430\u0434\u0438\u0443\u0441\u0430 \u043e\u0442 \u0442\u043e\u0447\u043a\u0438 (lat2, lon2)     distance = haversine(lat1, lon1, lat2, lon2)     return distance &lt;= radius  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 'YOUR_BOT_TOKEN' \u043d\u0430 \u0442\u043e\u043a\u0435\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043e\u0442 BotFather TOKEN = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' bot = telebot.TeleBot(TOKEN) chat_id = XXXXXXXXXXXXXX # \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 asyncio.run() def run_periodic_notificationX3():     asyncio.run(periodic_notificationX3(chat_id))   async def periodic_notificationX3(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Testing \ufe0fX3 \")     print(\"test X3\")     conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)     fuel_value = row[3]     if fuel_value &lt;= 10.0:         bot.send_message(chat_id, f'\u041e\u0441\u0442\u0430\u0442\u043e\u043a \u0442\u043e\u043f\u043b\u0438\u0432\u0430: {fuel_value} \u043b\u0438\u0442\u0440\u043e\u0432. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0437\u0430\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u04253\\n')   def run_periodic_notificationX3_location():     asyncio.run(periodic_notificationX3_location(chat_id))   async def periodic_notificationX3_location(chat_id):     bot = telebot.TeleBot(TOKEN)     bot.send_message(chat_id, \"Checking of X3 location\ufe0f \")     print(\"Checking of X3 location\")     # \u041a\u043e\u0441\u0442\u0440\u043e\u043c\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0430     target_KF_lon = 40.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KF_lat = 57.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443     # \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e          target_KAL_lon = 40.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0448\u0438\u0440\u043e\u0442\u0443     target_KAL_lat = 57.XXX  # \u0417\u0430\u043c\u0435\u043d\u0438\u0442\u0435 \u043d\u0430 \u0436\u0435\u043b\u0430\u0435\u043c\u0443\u044e \u0434\u043e\u043b\u0433\u043e\u0442\u0443      conn = sqlite3.connect('mydatabase.db')     cursor = conn.cursor()     cursor.execute('SELECT * FROM bmw ORDER BY id DESC LIMIT 1')     row = cursor.fetchone()     conn.close()     print(row)           print(row[1])     print(row[2])     global Flat_location     global Kalinino_location     global previous_lat     global previous_lon          if row:         current_lat = row[1]         bot.send_message(chat_id, current_lat)         current_lon = row[2]         bot.send_message(chat_id, current_lon)                  # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0435         if Flat_location and not check_proximity(current_lat, current_lon, target_KF_lat, target_KF_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443\\n')             Flat_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0440\u0430\u043d\u0435\u0435 \u0431\u044b\u043b\u0430 \u0432 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e         if Kalinino_location and not check_proximity(current_lat, current_lon, target_KAL_lat, target_KAL_lon):             print(\"X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n\")             bot.send_message(chat_id, 'X3 \u043f\u043e\u043a\u0438\u043d\u0443\u043b\u0430 \u041a\u0430\u043b\u0438\u043d\u0438\u043d\u043e\\n')             Kalinino_location = False          # \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430, \u0435\u0441\u043b\u0438 \u043c\u0430\u0448\u0438\u043d\u0430 \u0432\u0445\u043e\u0434\u0438\u0442 \u0432 \u043a\u0432\u0430\u0440\u0442\u0438\u0440\u0443         if<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-368075","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368075"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/368075\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}