Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Delitel-WEB committed Sep 28, 2023
2 parents 07d481e + 6ecaf33 commit 37a45f5
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ python main.py
| Фото |||
| Видео |||
| Кружки |||
| Геолокация || |
| Геолокация || |
| Гифки |||
| **Действия с чатами** | | |
| Изменение Фото |||
Expand Down
1 change: 1 addition & 0 deletions sync/vk/handlers/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import geo
from . import circles
from . import videos
from . import photos
Expand Down
37 changes: 37 additions & 0 deletions sync/vk/handlers/geo.py
Original file line number Diff line number Diff line change
@@ -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"<a href='{create_vk_link(message.from_id)}'>{user_info[0].first_name} {user_info[0].last_name}</a>\n",
parse_mode="html",
disable_web_page_preview=True,
disable_notification=True,
)

0 comments on commit 37a45f5

Please sign in to comment.