mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-13 09:32:27 +03:00
add new_join_request
This commit is contained in:
parent
08bb72ea6b
commit
918e03f707
|
@ -267,7 +267,7 @@ async def sign_up(
|
||||||
|
|
||||||
result = await self(_tl.fn.auth.SignUp(
|
result = await self(_tl.fn.auth.SignUp(
|
||||||
phone_number=phone,
|
phone_number=phone,
|
||||||
phone_code_hash=phone_code_hash,
|
phone_code_hash=self._phone_code_hash,
|
||||||
first_name=first_name,
|
first_name=first_name,
|
||||||
last_name=last_name
|
last_name=last_name
|
||||||
))
|
))
|
||||||
|
|
|
@ -2,6 +2,7 @@ import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import itertools
|
import itertools
|
||||||
import random
|
import random
|
||||||
|
import functools
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -225,7 +226,7 @@ class Entities:
|
||||||
self._client = client
|
self._client = client
|
||||||
self._entities = {e.id: e for e in itertools.chain(
|
self._entities = {e.id: e for e in itertools.chain(
|
||||||
(User._new(client, u) for u in users),
|
(User._new(client, u) for u in users),
|
||||||
(Chat._new(client, c) for u in chats),
|
(Chat._new(client, c) for c in chats),
|
||||||
)}
|
)}
|
||||||
|
|
||||||
def get(self, peer):
|
def get(self, peer):
|
||||||
|
|
|
@ -13,6 +13,7 @@ class ChatAction(EventBuilder):
|
||||||
* Whenever a new message is pinned.
|
* Whenever a new message is pinned.
|
||||||
* Whenever a user scores in a game.
|
* Whenever a user scores in a game.
|
||||||
* Whenever a user joins or is added to the group.
|
* Whenever a user joins or is added to the group.
|
||||||
|
* Whenever a new chat join request is sent.
|
||||||
* Whenever a user is removed or leaves a group if it has
|
* Whenever a user is removed or leaves a group if it has
|
||||||
less than 50 members or the removed user was a bot.
|
less than 50 members or the removed user was a bot.
|
||||||
|
|
||||||
|
@ -48,6 +49,9 @@ class ChatAction(EventBuilder):
|
||||||
`True` if the user's join request was approved.
|
`True` if the user's join request was approved.
|
||||||
along with `user_joined` will be also True.
|
along with `user_joined` will be also True.
|
||||||
|
|
||||||
|
new_join_request (:tl:`ExportedChatInvite`, optional):
|
||||||
|
Chat Invite, if the new chat join request was sent (Only Bots get this Update).
|
||||||
|
|
||||||
created (`bool`, optional):
|
created (`bool`, optional):
|
||||||
`True` if this chat was just created.
|
`True` if this chat was just created.
|
||||||
|
|
||||||
|
@ -80,6 +84,7 @@ class ChatAction(EventBuilder):
|
||||||
kicked_by = None
|
kicked_by = None
|
||||||
created = None
|
created = None
|
||||||
from_approval = None
|
from_approval = None
|
||||||
|
new_join_request = None
|
||||||
users = None
|
users = None
|
||||||
new_title = None
|
new_title = None
|
||||||
pin_ids = None
|
pin_ids = None
|
||||||
|
@ -109,6 +114,11 @@ class ChatAction(EventBuilder):
|
||||||
kicked_by = True
|
kicked_by = True
|
||||||
users = update.user_id
|
users = update.user_id
|
||||||
|
|
||||||
|
elif isinstance(update, _tl.UpdateBotChatInviteRequester):
|
||||||
|
users = update.user_id
|
||||||
|
where = _tl.PeerChat(update.chat_id)
|
||||||
|
new_join_request = update.invite
|
||||||
|
|
||||||
# UpdateChannel is sent if we leave a channel, and the update._entities
|
# UpdateChannel is sent if we leave a channel, and the update._entities
|
||||||
# set by _process_update would let us make some guesses. However it's
|
# set by _process_update would let us make some guesses. However it's
|
||||||
# better not to rely on this. Rely only in MessageActionChatDeleteUser.
|
# better not to rely on this. Rely only in MessageActionChatDeleteUser.
|
||||||
|
@ -161,11 +171,14 @@ class ChatAction(EventBuilder):
|
||||||
new_photo = True
|
new_photo = True
|
||||||
elif isinstance(action, _tl.MessageActionPinMessage) and msg.reply_to:
|
elif isinstance(action, _tl.MessageActionPinMessage) and msg.reply_to:
|
||||||
where = msg
|
where = msg
|
||||||
pin_ids=[msg.reply_to_msg_id]
|
pin_ids=[msg.reply_to.reply_to_msg_id]
|
||||||
elif isinstance(action, _tl.MessageActionGameScore):
|
elif isinstance(action, _tl.MessageActionGameScore):
|
||||||
where = msg
|
where = msg
|
||||||
new_score = action.score
|
new_score = action.score
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
return
|
||||||
self = cls.__new__(cls)
|
self = cls.__new__(cls)
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
|
@ -196,6 +209,7 @@ class ChatAction(EventBuilder):
|
||||||
self.user_added = True
|
self.user_added = True
|
||||||
self._added_by = added_by
|
self._added_by = added_by
|
||||||
self.user_approved = from_approval
|
self.user_approved = from_approval
|
||||||
|
self.new_join_request = new_join_request
|
||||||
|
|
||||||
# If `from_id` was not present (it's `True`) or the affected
|
# If `from_id` was not present (it's `True`) or the affected
|
||||||
# user was "kicked by itself", then it left. Else it was kicked.
|
# user was "kicked by itself", then it left. Else it was kicked.
|
||||||
|
@ -290,6 +304,17 @@ class ChatAction(EventBuilder):
|
||||||
|
|
||||||
return self._pinned_messages
|
return self._pinned_messages
|
||||||
|
|
||||||
|
async def approve_user(self, approved: bool = True):
|
||||||
|
"""
|
||||||
|
Approve or disapprove chat join request of user.
|
||||||
|
"""
|
||||||
|
if self.new_join_request:
|
||||||
|
return await self._client(_tl.fn.messages.HideChatJoinRequest(
|
||||||
|
await self.get_input_chat(),
|
||||||
|
user_id=self.user_id,
|
||||||
|
approved=approved
|
||||||
|
))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def added_by(self):
|
def added_by(self):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -2,6 +2,8 @@ from typing import Optional, List, TYPE_CHECKING
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
|
||||||
|
from ..._sessions.types import Entity
|
||||||
from .chatgetter import ChatGetter
|
from .chatgetter import ChatGetter
|
||||||
from .sendergetter import SenderGetter
|
from .sendergetter import SenderGetter
|
||||||
from .messagebutton import MessageButton
|
from .messagebutton import MessageButton
|
||||||
|
|
Loading…
Reference in New Issue
Block a user