From 47168e682d5e147d7a88d50bb5bff6fb6a0e6dae Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 5 Aug 2018 21:56:32 +0200 Subject: [PATCH] Added Poll and PollOption models --- fbchat/models.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/fbchat/models.py b/fbchat/models.py index a380599..fee71f3 100644 --- a/fbchat/models.py +++ b/fbchat/models.py @@ -436,6 +436,50 @@ class Mention(object): def __unicode__(self): return ''.format(self.thread_id, self.offset, self.length) +class Poll(object): + #: ID of the poll + uid = None + #: Title of the poll + title = None + #: List of :class:`PollOption` + 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 ''.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's of the persons 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 ''.format(self.uid, repr(self.text), self.voters) + class Enum(enum.Enum): """Used internally by fbchat to support enumerations""" def __repr__(self):