Remove deprecated arguments, methods, and classes

This commit is contained in:
Mads Marquart
2019-09-08 15:50:32 +02:00
parent 2e88bd49d4
commit c70a39c568
4 changed files with 3 additions and 103 deletions

View File

@@ -14,7 +14,7 @@ from . import _core, _util
from ._exception import FBchatException, FBchatFacebookError, FBchatUserError from ._exception import FBchatException, FBchatFacebookError, FBchatUserError
from ._thread import ThreadType, ThreadLocation, ThreadColor, Thread from ._thread import ThreadType, ThreadLocation, ThreadColor, Thread
from ._user import TypingStatus, User, ActiveStatus from ._user import TypingStatus, User, ActiveStatus
from ._group import Group, Room from ._group import Group
from ._page import Page from ._page import Page
from ._message import EmojiSize, MessageReaction, Mention, Message from ._message import EmojiSize, MessageReaction, Mention, Message
from ._attachment import Attachment, UnsentMessage, ShareAttachment from ._attachment import Attachment, UnsentMessage, ShareAttachment

View File

@@ -789,12 +789,11 @@ class Client:
return messages return messages
def fetchThreadList( def fetchThreadList(
self, offset=None, limit=20, thread_location=ThreadLocation.INBOX, before=None self, limit=20, thread_location=ThreadLocation.INBOX, before=None
): ):
"""Fetch the client's thread list. """Fetch the client's thread list.
Args: Args:
offset: Deprecated. Do not use!
limit (int): Max. number of threads to retrieve. Capped at 20 limit (int): Max. number of threads to retrieve. Capped at 20
thread_location (ThreadLocation): INBOX, PENDING, ARCHIVED or OTHER thread_location (ThreadLocation): INBOX, PENDING, ARCHIVED or OTHER
before (datetime.datetime): The point from which to retrieve threads before (datetime.datetime): The point from which to retrieve threads
@@ -805,13 +804,6 @@ class Client:
Raises: Raises:
FBchatException: If request failed FBchatException: If request failed
""" """
if offset is not None:
log.warning(
"Using `offset` in `fetchThreadList` is no longer supported, "
"since Facebook migrated to the use of GraphQL in this request. "
"Use `before` instead."
)
if limit > 20 or limit < 1: if limit > 20 or limit < 1:
raise FBchatUserError("`limit` should be between 1 and 20") raise FBchatUserError("`limit` should be between 1 and 20")
@@ -1063,26 +1055,6 @@ class Client:
data.update(message._to_send_data()) data.update(message._to_send_data())
return self._doSendRequest(data) return self._doSendRequest(data)
def sendMessage(self, message, thread_id=None, thread_type=ThreadType.USER):
"""Deprecated. Use :func:`fbchat.Client.send` instead."""
return self.send(
Message(text=message), thread_id=thread_id, thread_type=thread_type
)
def sendEmoji(
self,
emoji=None,
size=EmojiSize.SMALL,
thread_id=None,
thread_type=ThreadType.USER,
):
"""Deprecated. Use :func:`fbchat.Client.send` instead."""
return self.send(
Message(text=emoji, emoji_size=size),
thread_id=thread_id,
thread_type=thread_type,
)
def wave(self, wave_first=True, thread_id=None, thread_type=None): def wave(self, wave_first=True, thread_id=None, thread_type=None):
"""Wave hello to a thread. """Wave hello to a thread.
@@ -1337,48 +1309,6 @@ class Client:
files=files, message=message, thread_id=thread_id, thread_type=thread_type files=files, message=message, thread_id=thread_id, thread_type=thread_type
) )
def sendImage(
self,
image_id,
message=None,
thread_id=None,
thread_type=ThreadType.USER,
is_gif=False,
):
"""Deprecated."""
if is_gif:
mimetype = "image/gif"
else:
mimetype = "image/png"
return self._sendFiles(
files=[(image_id, mimetype)],
message=message,
thread_id=thread_id,
thread_type=thread_type,
)
def sendRemoteImage(
self, image_url, message=None, thread_id=None, thread_type=ThreadType.USER
):
"""Deprecated. Use :func:`fbchat.Client.sendRemoteFiles` instead."""
return self.sendRemoteFiles(
file_urls=[image_url],
message=message,
thread_id=thread_id,
thread_type=thread_type,
)
def sendLocalImage(
self, image_path, message=None, thread_id=None, thread_type=ThreadType.USER
):
"""Deprecated. Use :func:`fbchat.Client.sendLocalFiles` instead."""
return self.sendLocalFiles(
file_paths=[image_path],
message=message,
thread_id=thread_id,
thread_type=thread_type,
)
def forwardAttachment(self, attachment_id, thread_id=None): def forwardAttachment(self, attachment_id, thread_id=None):
"""Forward an attachment. """Forward an attachment.
@@ -1801,11 +1731,6 @@ class Client:
} }
j = self._payload_post("/ajax/eventreminder/rsvp", data) j = self._payload_post("/ajax/eventreminder/rsvp", data)
def eventReminder(self, thread_id, time, title, location="", location_id=""):
"""Deprecated. Use :func:`fbchat.Client.createPlan` instead."""
plan = Plan(time=time, title=title, location=location, location_id=location_id)
self.createPlan(plan=plan, thread_id=thread_id)
def createPoll(self, poll, thread_id=None): def createPoll(self, poll, thread_id=None):
"""Create poll in a group thread. """Create poll in a group thread.
@@ -2728,7 +2653,6 @@ class Client:
self.onMessage( self.onMessage(
mid=message.uid, mid=message.uid,
author_id=message.author, author_id=message.author,
message=message.text,
message_object=message, message_object=message,
thread_id=thread_id, thread_id=thread_id,
thread_type=thread_type, thread_type=thread_type,
@@ -2743,7 +2667,6 @@ class Client:
self.onMessage( self.onMessage(
mid=mid, mid=mid,
author_id=author_id, author_id=author_id,
message=delta.get("body", ""),
message_object=Message._from_pull( message_object=Message._from_pull(
delta, delta,
mid=mid, mid=mid,
@@ -2877,21 +2800,15 @@ class Client:
""" """
self.listening = True self.listening = True
def doOneListen(self, markAlive=None): def doOneListen(self):
"""Do one cycle of the listening loop. """Do one cycle of the listening loop.
This method is useful if you want to control the client from an external event This method is useful if you want to control the client from an external event
loop. loop.
Warning:
``markAlive`` parameter is deprecated, use :func:`Client.setActiveStatus`
or ``markAlive`` parameter in :func:`Client.listen` instead.
Returns: Returns:
bool: Whether the loop should keep running bool: Whether the loop should keep running
""" """
if markAlive is not None:
self._markAlive = markAlive
try: try:
if self._markAlive: if self._markAlive:
self._ping() self._ping()
@@ -2996,7 +2913,6 @@ class Client:
self, self,
mid=None, mid=None,
author_id=None, author_id=None,
message=None,
message_object=None, message_object=None,
thread_id=None, thread_id=None,
thread_type=ThreadType.USER, thread_type=ThreadType.USER,
@@ -3009,7 +2925,6 @@ class Client:
Args: Args:
mid: The message ID mid: The message ID
author_id: The ID of the author author_id: The ID of the author
message: (deprecated. Use ``message_object.text`` instead)
message_object (Message): The message (As a `Message` object) message_object (Message): The message (As a `Message` object)
thread_id: Thread ID that the message was sent to. See :ref:`intro_threads` thread_id: Thread ID that the message was sent to. See :ref:`intro_threads`
thread_type (ThreadType): Type of thread that the message was sent to. See :ref:`intro_threads` thread_type (ThreadType): Type of thread that the message was sent to. See :ref:`intro_threads`

View File

@@ -103,16 +103,3 @@ class Group(Thread):
def _to_send_data(self): def _to_send_data(self):
return {"thread_fbid": self.uid} return {"thread_fbid": self.uid}
@attr.s(cmp=False, init=False)
class Room(Group):
"""Deprecated. Use `Group` instead."""
# True is room is not discoverable
privacy_mode = attr.ib(None)
def __init__(self, uid, privacy_mode=None, **kwargs):
super(Room, self).__init__(uid, **kwargs)
self.type = ThreadType.ROOM
self.privacy_mode = privacy_mode

View File

@@ -10,7 +10,6 @@ class ThreadType(Enum):
USER = 1 USER = 1
GROUP = 2 GROUP = 2
ROOM = 2
PAGE = 3 PAGE = 3
def _to_class(self): def _to_class(self):
@@ -20,7 +19,6 @@ class ThreadType(Enum):
return { return {
ThreadType.USER: _user.User, ThreadType.USER: _user.User,
ThreadType.GROUP: _group.Group, ThreadType.GROUP: _group.Group,
ThreadType.ROOM: _group.Room,
ThreadType.PAGE: _page.Page, ThreadType.PAGE: _page.Page,
}[self] }[self]