-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |