Remove get_nearby_chats method

This commit is contained in:
KurimuzonAkuma 2024-09-10 21:31:39 +03:00
parent 6684eaf427
commit 40e6578ea8
4 changed files with 0 additions and 87 deletions

View File

@ -232,7 +232,6 @@ def pyrogram_api():
get_dialogs
get_dialogs_count
set_chat_username
get_nearby_chats
archive_chats
unarchive_chats
add_chat_members

View File

@ -44,7 +44,6 @@ from .get_dialogs_count import GetDialogsCount
from .get_folders import GetFolders
from .get_forum_topics import GetForumTopics
from .get_forum_topics_by_id import GetForumTopicsByID
from .get_nearby_chats import GetNearbyChats
from .get_personal_channels import GetPersonalChannels
from .get_send_as_chats import GetSendAsChats
from .join_chat import JoinChat
@ -121,7 +120,6 @@ class Chats(
DeleteSupergroup,
EditForumTopic,
ExportFolderLink,
GetNearbyChats,
GetPersonalChannels,
SetAdministratorTitle,
SetSlowMode,

View File

@ -1,78 +0,0 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
#
# This file is part of Pyrogram.
#
# Pyrogram is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Pyrogram is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
from typing import List
import pyrogram
from pyrogram import raw
from pyrogram import types
from pyrogram import utils
class GetNearbyChats:
async def get_nearby_chats(
self: "pyrogram.Client",
latitude: float,
longitude: float
) -> List["types.Chat"]:
"""Get nearby chats.
.. include:: /_includes/usable-by/users.rst
Parameters:
latitude (``float``):
Latitude of the location.
longitude (``float``):
Longitude of the location.
Returns:
List of :obj:`~pyrogram.types.Chat`: On success, a list of nearby chats is returned.
Example:
.. code-block:: python
chats = await app.get_nearby_chats(latitude, longitude)
print(chats)
"""
r = await self.invoke(
raw.functions.contacts.GetLocated(
geo_point=raw.types.InputGeoPoint(
lat=latitude,
long=longitude
)
)
)
if not r.updates:
return []
chats = types.List([types.Chat._parse_chat(self, chat) for chat in r.chats])
peers = r.updates[0].peers
for peer in peers:
if isinstance(peer.peer, raw.types.PeerChannel):
chat_id = utils.get_channel_id(peer.peer.channel_id)
for chat in chats:
if chat.id == chat_id:
chat.distance = peer.distance
break
return chats

View File

@ -180,10 +180,6 @@ class Chat(Object):
permissions (:obj:`~pyrogram.types.ChatPermissions` *optional*):
Default chat member permissions, for groups and supergroups.
distance (``int``, *optional*):
Distance in meters of this group chat from your location.
Returned only in :meth:`~pyrogram.Client.get_nearby_chats`.
personal_channel (:obj:`~pyrogram.types.Chat`, *optional*):
The personal channel linked to this chat.
Returned only in :meth:`~pyrogram.Client.get_chat`.
@ -306,7 +302,6 @@ class Chat(Object):
members_count: int = None,
restrictions: List["types.Restriction"] = None,
permissions: "types.ChatPermissions" = None,
distance: int = None,
personal_channel: "types.Chat" = None,
personal_channel_message: "types.Message" = None,
linked_chat: "types.Chat" = None,
@ -377,7 +372,6 @@ class Chat(Object):
self.members_count = members_count
self.restrictions = restrictions
self.permissions = permissions
self.distance = distance
self.personal_channel = personal_channel
self.personal_channel_message = personal_channel_message
self.linked_chat = linked_chat