From cdf7f64ffd68f653975cba30d39c7a182fea7273 Mon Sep 17 00:00:00 2001 From: Delitel Date: Thu, 28 Sep 2023 05:44:30 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=9E=D1=82=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B3=D0=B5=D0=BE=D0=BF=D0=BE=D0=B7=D0=B8=D1=86=D0=B8?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BE=20=D1=81=D1=82=D0=BE=D1=80=D0=BE=D0=BD?= =?UTF-8?q?=D1=8B=20=D0=B2=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sync/vk/handlers/__init__.py | 1 + sync/vk/handlers/geo.py | 37 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 sync/vk/handlers/geo.py diff --git a/sync/vk/handlers/__init__.py b/sync/vk/handlers/__init__.py index e659813..d371ad5 100644 --- a/sync/vk/handlers/__init__.py +++ b/sync/vk/handlers/__init__.py @@ -1,3 +1,4 @@ +from . import geo from . import circles from . import videos from . import photos diff --git a/sync/vk/handlers/geo.py b/sync/vk/handlers/geo.py new file mode 100644 index 0000000..f471948 --- /dev/null +++ b/sync/vk/handlers/geo.py @@ -0,0 +1,37 @@ +from ..core import bot +from vkbottle.user import Message +from ...tg.core import bot as tg +from ..utils import create_vk_link, check_bundle +from vkbottle.dispatch.rules import ABCRule + + +class GeoRule(ABCRule[Message]): + """ + Кастомное правило которое будет срабатывать если + будет отправлена геолокация + """ + + async def check(self, event: Message): + if event.geo: + return True + + return False + + +@bot.on.message(GeoRule()) +@check_bundle +async def on_geo(message: Message, bundle): + user_info = await bot.api.users.get(message.from_id) + + latitude = message.geo.coordinates.latitude + longitude = message.geo.coordinates.longitude + + geo_message = await tg.send_location( + bundle.tg_id, latitude=latitude, longitude=longitude + ) + await geo_message.reply( + f"{user_info[0].first_name} {user_info[0].last_name}\n", + parse_mode="html", + disable_web_page_preview=True, + disable_notification=True, + ) From 6ecaf33919571567a5f0a9c213ecf799efb821aa Mon Sep 17 00:00:00 2001 From: Delitel Date: Thu, 28 Sep 2023 05:45:17 +0300 Subject: [PATCH 2/2] =?UTF-8?q?`=D0=93=D0=B5=D0=BE=D0=BB=D0=BE=D0=BA=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F`=20=D0=BE=D1=82=D0=BC=D0=B5=D1=87=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B2=20`README`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6398e52..b8a4838 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ python main.py | Фото | ❌ | ✅ | | Видео | ❌ | ✅ | | Кружки | ❌ | ✅ | -| Геолокация | ❌ | ❌ | +| Геолокация | ❌ | ✅ | | Гифки | ❌ | ❌ | | **Действия с чатами** | | | | Изменение Фото | ❌ | ❌ |