Move model docstrings into the class level, out of init
This commit is contained in:
@@ -3,21 +3,25 @@ from __future__ import unicode_literals
|
||||
|
||||
|
||||
class Attachment(object):
|
||||
"""Represents a Facebook attachment"""
|
||||
|
||||
#: The attachment ID
|
||||
uid = None
|
||||
|
||||
def __init__(self, uid=None):
|
||||
"""Represents a Facebook attachment"""
|
||||
self.uid = uid
|
||||
|
||||
|
||||
class UnsentMessage(Attachment):
|
||||
"""Represents an unsent message attachment"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Represents an unsent message attachment"""
|
||||
super(UnsentMessage, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class ShareAttachment(Attachment):
|
||||
"""Represents a shared item (eg. URL) that has been sent as a Facebook attachment"""
|
||||
|
||||
#: ID of the author of the shared post
|
||||
author = None
|
||||
#: Target URL
|
||||
@@ -56,7 +60,6 @@ class ShareAttachment(Attachment):
|
||||
attachments=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Represents a shared item (eg. URL) that has been sent as a Facebook attachment"""
|
||||
super(ShareAttachment, self).__init__(**kwargs)
|
||||
self.author = author
|
||||
self.url = url
|
||||
|
@@ -5,6 +5,8 @@ from ._attachment import Attachment
|
||||
|
||||
|
||||
class FileAttachment(Attachment):
|
||||
"""Represents a file that has been sent as a Facebook attachment"""
|
||||
|
||||
#: Url where you can download the file
|
||||
url = None
|
||||
#: Size of the file in bytes
|
||||
@@ -15,7 +17,6 @@ class FileAttachment(Attachment):
|
||||
is_malicious = None
|
||||
|
||||
def __init__(self, url=None, size=None, name=None, is_malicious=None, **kwargs):
|
||||
"""Represents a file that has been sent as a Facebook attachment"""
|
||||
super(FileAttachment, self).__init__(**kwargs)
|
||||
self.url = url
|
||||
self.size = size
|
||||
@@ -24,6 +25,8 @@ class FileAttachment(Attachment):
|
||||
|
||||
|
||||
class AudioAttachment(Attachment):
|
||||
"""Represents an audio file that has been sent as a Facebook attachment"""
|
||||
|
||||
#: Name of the file
|
||||
filename = None
|
||||
#: Url of the audio file
|
||||
@@ -36,7 +39,6 @@ class AudioAttachment(Attachment):
|
||||
def __init__(
|
||||
self, filename=None, url=None, duration=None, audio_type=None, **kwargs
|
||||
):
|
||||
"""Represents an audio file that has been sent as a Facebook attachment"""
|
||||
super(AudioAttachment, self).__init__(**kwargs)
|
||||
self.filename = filename
|
||||
self.url = url
|
||||
@@ -45,6 +47,12 @@ class AudioAttachment(Attachment):
|
||||
|
||||
|
||||
class ImageAttachment(Attachment):
|
||||
"""Represents an image that has been sent as a Facebook attachment
|
||||
|
||||
To retrieve the full image url, use: :func:`fbchat.Client.fetchImageUrl`, and pass
|
||||
it the uid of the image attachment
|
||||
"""
|
||||
|
||||
#: The extension of the original image (eg. 'png')
|
||||
original_extension = None
|
||||
#: Width of original image
|
||||
@@ -91,11 +99,6 @@ class ImageAttachment(Attachment):
|
||||
animated_preview=None,
|
||||
**kwargs
|
||||
):
|
||||
"""
|
||||
Represents an image that has been sent as a Facebook attachment
|
||||
To retrieve the full image url, use: :func:`fbchat.Client.fetchImageUrl`,
|
||||
and pass it the uid of the image attachment
|
||||
"""
|
||||
super(ImageAttachment, self).__init__(**kwargs)
|
||||
self.original_extension = original_extension
|
||||
if width is not None:
|
||||
@@ -127,6 +130,8 @@ class ImageAttachment(Attachment):
|
||||
|
||||
|
||||
class VideoAttachment(Attachment):
|
||||
"""Represents a video that has been sent as a Facebook attachment"""
|
||||
|
||||
#: Size of the original video in bytes
|
||||
size = None
|
||||
#: Width of original video
|
||||
@@ -171,7 +176,6 @@ class VideoAttachment(Attachment):
|
||||
large_image=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Represents a video that has been sent as a Facebook attachment"""
|
||||
super(VideoAttachment, self).__init__(**kwargs)
|
||||
self.size = size
|
||||
self.width = width
|
||||
|
@@ -5,6 +5,8 @@ from ._thread import ThreadType, Thread
|
||||
|
||||
|
||||
class Group(Thread):
|
||||
"""Represents a Facebook group. Inherits `Thread`"""
|
||||
|
||||
#: Unique list (set) of the group thread's participant user IDs
|
||||
participants = None
|
||||
#: A dict, containing user nicknames mapped to their IDs
|
||||
@@ -36,7 +38,6 @@ class Group(Thread):
|
||||
privacy_mode=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Represents a Facebook group. Inherits `Thread`"""
|
||||
super(Group, self).__init__(ThreadType.GROUP, uid, **kwargs)
|
||||
if participants is None:
|
||||
participants = set()
|
||||
@@ -57,11 +58,12 @@ class Group(Thread):
|
||||
|
||||
|
||||
class Room(Group):
|
||||
"""Deprecated. Use :class:`Group` instead"""
|
||||
|
||||
# True is room is not discoverable
|
||||
privacy_mode = None
|
||||
|
||||
def __init__(self, uid, privacy_mode=None, **kwargs):
|
||||
"""Deprecated. Use :class:`Group` instead"""
|
||||
super(Room, self).__init__(uid, **kwargs)
|
||||
self.type = ThreadType.ROOM
|
||||
self.privacy_mode = privacy_mode
|
||||
|
@@ -5,7 +5,10 @@ from ._attachment import Attachment
|
||||
|
||||
|
||||
class LocationAttachment(Attachment):
|
||||
"""Latitude and longitude OR address is provided by Facebook"""
|
||||
"""Represents a user location
|
||||
|
||||
Latitude and longitude OR address is provided by Facebook
|
||||
"""
|
||||
|
||||
#: Latitude of the location
|
||||
latitude = None
|
||||
@@ -23,7 +26,6 @@ class LocationAttachment(Attachment):
|
||||
address = None
|
||||
|
||||
def __init__(self, latitude=None, longitude=None, address=None, **kwargs):
|
||||
"""Represents a user location"""
|
||||
super(LocationAttachment, self).__init__(**kwargs)
|
||||
self.latitude = latitude
|
||||
self.longitude = longitude
|
||||
@@ -31,6 +33,8 @@ class LocationAttachment(Attachment):
|
||||
|
||||
|
||||
class LiveLocationAttachment(LocationAttachment):
|
||||
"""Represents a live user location"""
|
||||
|
||||
#: Name of the location
|
||||
name = None
|
||||
#: Timestamp when live location expires
|
||||
@@ -39,7 +43,6 @@ class LiveLocationAttachment(LocationAttachment):
|
||||
is_expired = None
|
||||
|
||||
def __init__(self, name=None, expiration_time=None, is_expired=None, **kwargs):
|
||||
"""Represents a live user location"""
|
||||
super(LiveLocationAttachment, self).__init__(**kwargs)
|
||||
self.expiration_time = expiration_time
|
||||
self.is_expired = is_expired
|
||||
|
@@ -26,6 +26,8 @@ class MessageReaction(Enum):
|
||||
|
||||
|
||||
class Mention(object):
|
||||
"""Represents a @mention"""
|
||||
|
||||
#: The thread ID the mention is pointing at
|
||||
thread_id = None
|
||||
#: The character where the mention starts
|
||||
@@ -34,7 +36,6 @@ class Mention(object):
|
||||
length = None
|
||||
|
||||
def __init__(self, thread_id, offset=0, length=10):
|
||||
"""Represents a @mention"""
|
||||
self.thread_id = thread_id
|
||||
self.offset = offset
|
||||
self.length = length
|
||||
@@ -49,6 +50,8 @@ class Mention(object):
|
||||
|
||||
|
||||
class Message(object):
|
||||
"""Represents a Facebook message"""
|
||||
|
||||
#: The actual message
|
||||
text = None
|
||||
#: A list of :class:`Mention` objects
|
||||
@@ -87,7 +90,6 @@ class Message(object):
|
||||
attachments=None,
|
||||
quick_replies=None,
|
||||
):
|
||||
"""Represents a Facebook message"""
|
||||
self.text = text
|
||||
if mentions is None:
|
||||
mentions = []
|
||||
|
@@ -5,6 +5,8 @@ from ._thread import ThreadType, Thread
|
||||
|
||||
|
||||
class Page(Thread):
|
||||
"""Represents a Facebook page. Inherits `Thread`"""
|
||||
|
||||
#: The page's custom url
|
||||
url = None
|
||||
#: The name of the page's location city
|
||||
@@ -26,7 +28,6 @@ class Page(Thread):
|
||||
category=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Represents a Facebook page. Inherits `Thread`"""
|
||||
super(Page, self).__init__(ThreadType.PAGE, uid, **kwargs)
|
||||
self.url = url
|
||||
self.city = city
|
||||
|
@@ -3,6 +3,8 @@ from __future__ import unicode_literals
|
||||
|
||||
|
||||
class Plan(object):
|
||||
"""Represents a plan"""
|
||||
|
||||
#: ID of the plan
|
||||
uid = None
|
||||
#: Plan time (unix time stamp), only precise down to the minute
|
||||
@@ -23,7 +25,6 @@ class Plan(object):
|
||||
invited = None
|
||||
|
||||
def __init__(self, time, title, location=None, location_id=None):
|
||||
"""Represents a plan"""
|
||||
self.time = int(time)
|
||||
self.title = title
|
||||
self.location = location or ""
|
||||
|
@@ -3,6 +3,8 @@ from __future__ import unicode_literals
|
||||
|
||||
|
||||
class Poll(object):
|
||||
"""Represents a poll"""
|
||||
|
||||
#: ID of the poll
|
||||
uid = None
|
||||
#: Title of the poll
|
||||
@@ -13,7 +15,6 @@ class Poll(object):
|
||||
options_count = None
|
||||
|
||||
def __init__(self, title, options):
|
||||
"""Represents a poll"""
|
||||
self.title = title
|
||||
self.options = options
|
||||
|
||||
@@ -27,6 +28,8 @@ class Poll(object):
|
||||
|
||||
|
||||
class PollOption(object):
|
||||
"""Represents a poll option"""
|
||||
|
||||
#: ID of the poll option
|
||||
uid = None
|
||||
#: Text of the poll option
|
||||
@@ -39,7 +42,6 @@ class PollOption(object):
|
||||
votes_count = None
|
||||
|
||||
def __init__(self, text, vote=False):
|
||||
"""Represents a poll option"""
|
||||
self.text = text
|
||||
self.vote = vote
|
||||
|
||||
|
@@ -5,6 +5,8 @@ from ._attachment import Attachment
|
||||
|
||||
|
||||
class QuickReply(object):
|
||||
"""Represents a quick reply"""
|
||||
|
||||
#: Payload of the quick reply
|
||||
payload = None
|
||||
#: External payload for responses
|
||||
@@ -15,7 +17,6 @@ class QuickReply(object):
|
||||
is_response = None
|
||||
|
||||
def __init__(self, payload=None, data=None, is_response=False):
|
||||
"""Represents a quick reply"""
|
||||
self.payload = payload
|
||||
self.data = data
|
||||
self.is_response = is_response
|
||||
@@ -28,6 +29,8 @@ class QuickReply(object):
|
||||
|
||||
|
||||
class QuickReplyText(QuickReply):
|
||||
"""Represents a text quick reply"""
|
||||
|
||||
#: Title of the quick reply
|
||||
title = None
|
||||
#: URL of the quick reply image (optional)
|
||||
@@ -36,41 +39,43 @@ class QuickReplyText(QuickReply):
|
||||
_type = "text"
|
||||
|
||||
def __init__(self, title=None, image_url=None, **kwargs):
|
||||
"""Represents a text quick reply"""
|
||||
super(QuickReplyText, self).__init__(**kwargs)
|
||||
self.title = title
|
||||
self.image_url = image_url
|
||||
|
||||
|
||||
class QuickReplyLocation(QuickReply):
|
||||
"""Represents a location quick reply (Doesn't work on mobile)"""
|
||||
|
||||
#: Type of the quick reply
|
||||
_type = "location"
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""Represents a location quick reply (Doesn't work on mobile)"""
|
||||
super(QuickReplyLocation, self).__init__(**kwargs)
|
||||
self.is_response = False
|
||||
|
||||
|
||||
class QuickReplyPhoneNumber(QuickReply):
|
||||
"""Represents a phone number quick reply (Doesn't work on mobile)"""
|
||||
|
||||
#: URL of the quick reply image (optional)
|
||||
image_url = None
|
||||
#: Type of the quick reply
|
||||
_type = "user_phone_number"
|
||||
|
||||
def __init__(self, image_url=None, **kwargs):
|
||||
"""Represents a phone number quick reply (Doesn't work on mobile)"""
|
||||
super(QuickReplyPhoneNumber, self).__init__(**kwargs)
|
||||
self.image_url = image_url
|
||||
|
||||
|
||||
class QuickReplyEmail(QuickReply):
|
||||
"""Represents an email quick reply (Doesn't work on mobile)"""
|
||||
|
||||
#: URL of the quick reply image (optional)
|
||||
image_url = None
|
||||
#: Type of the quick reply
|
||||
_type = "user_email"
|
||||
|
||||
def __init__(self, image_url=None, **kwargs):
|
||||
"""Represents an email quick reply (Doesn't work on mobile)"""
|
||||
super(QuickReplyEmail, self).__init__(**kwargs)
|
||||
self.image_url = image_url
|
||||
|
@@ -5,6 +5,8 @@ from ._attachment import Attachment
|
||||
|
||||
|
||||
class Sticker(Attachment):
|
||||
"""Represents a Facebook sticker that has been sent to a thread as an attachment"""
|
||||
|
||||
#: The sticker-pack's ID
|
||||
pack = None
|
||||
#: Whether the sticker is animated
|
||||
@@ -32,5 +34,4 @@ class Sticker(Attachment):
|
||||
label = None
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Represents a Facebook sticker that has been sent to a Facebook thread as an attachment"""
|
||||
super(Sticker, self).__init__(*args, **kwargs)
|
||||
|
@@ -43,6 +43,8 @@ class ThreadColor(Enum):
|
||||
|
||||
|
||||
class Thread(object):
|
||||
"""Represents a Facebook thread"""
|
||||
|
||||
#: The unique identifier of the thread. Can be used a `thread_id`. See :ref:`intro_threads` for more info
|
||||
uid = None
|
||||
#: Specifies the type of thread. Can be used a `thread_type`. See :ref:`intro_threads` for more info
|
||||
@@ -68,7 +70,6 @@ class Thread(object):
|
||||
message_count=None,
|
||||
plan=None,
|
||||
):
|
||||
"""Represents a Facebook thread"""
|
||||
self.uid = str(uid)
|
||||
self.type = _type
|
||||
self.photo = photo
|
||||
|
@@ -13,6 +13,8 @@ class TypingStatus(Enum):
|
||||
|
||||
|
||||
class User(Thread):
|
||||
"""Represents a Facebook user. Inherits `Thread`"""
|
||||
|
||||
#: The profile url
|
||||
url = None
|
||||
#: The users first name
|
||||
@@ -49,7 +51,6 @@ class User(Thread):
|
||||
emoji=None,
|
||||
**kwargs
|
||||
):
|
||||
"""Represents a Facebook user. Inherits `Thread`"""
|
||||
super(User, self).__init__(ThreadType.USER, uid, **kwargs)
|
||||
self.url = url
|
||||
self.first_name = first_name
|
||||
|
Reference in New Issue
Block a user