Split models.py into several files (#398)
* Move exception models into separate file * Move thread model into separate file * Move user model into separate file * Move group and room models into separate file * Move page model into separate file * Move message model into separate file * Move basic attachment models into separate file * Move sticker model into separate file * Move location models into separate file * Move file attachment models into separate file * Move mention model to reside with message model * Move quick reply models into separate file * Move poll models into separate file * Move plan model into separate file * Move active status model to reside with user model * Move core enum model into separate file * Move thread-related enums to reside with thread model * Move typingstatus model to reside with user model * Move emojisize and reaction enums to reside wtih message model
This commit is contained in:
52
fbchat/_poll.py
Normal file
52
fbchat/_poll.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# -*- coding: UTF-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
|
||||
class Poll(object):
|
||||
#: ID of the poll
|
||||
uid = None
|
||||
#: Title of the poll
|
||||
title = None
|
||||
#: List of :class:`PollOption`, can be fetched with :func:`fbchat.Client.fetchPollOptions`
|
||||
options = None
|
||||
#: Options count
|
||||
options_count = None
|
||||
|
||||
def __init__(self, title, options):
|
||||
"""Represents a poll"""
|
||||
self.title = title
|
||||
self.options = options
|
||||
|
||||
def __repr__(self):
|
||||
return self.__unicode__()
|
||||
|
||||
def __unicode__(self):
|
||||
return "<Poll ({}): {} options={}>".format(
|
||||
self.uid, repr(self.title), self.options
|
||||
)
|
||||
|
||||
|
||||
class PollOption(object):
|
||||
#: ID of the poll option
|
||||
uid = None
|
||||
#: Text of the poll option
|
||||
text = None
|
||||
#: Whether vote when creating or client voted
|
||||
vote = None
|
||||
#: ID of the users who voted for this poll option
|
||||
voters = None
|
||||
#: Votes count
|
||||
votes_count = None
|
||||
|
||||
def __init__(self, text, vote=False):
|
||||
"""Represents a poll option"""
|
||||
self.text = text
|
||||
self.vote = vote
|
||||
|
||||
def __repr__(self):
|
||||
return self.__unicode__()
|
||||
|
||||
def __unicode__(self):
|
||||
return "<PollOption ({}): {} voters={}>".format(
|
||||
self.uid, repr(self.text), self.voters
|
||||
)
|
Reference in New Issue
Block a user