An async python wrapper for the Strawpoll API.
A named tuple containing the five components of the version number in a similar manner as sys.version_info.
API(*, loop=None, requests_policy=<RequestsPolicy.asynchronous: 0>)¶
Represents the strawpoll API.
Parameters: loop – The event loop to use for the asynchronous calls. Defaults to None, which will grab the default event loop instead.
get_poll(arg, *, request_policy=None)¶
Retrieves a poll from strawpoll.
- arg – Either the ID of the poll or its strawpoll url.
- request_policy (Optional[
RequestsPolicy]) – Overrides
API.requests_policyfor that request.
HTTPException – Requesting the poll failed.
A poll constructed with the requested data.
submit_poll(poll, *, request_policy=None)¶
Submits a poll on strawpoll.
Parameters: Raises: Returns:
The given poll updated with the data sent back from the submission.
Only polls that have a non empty title and between 2 and 30 options can be submitted.
Poll(title, options, **kwargs)¶
Represents a poll from strawpoll.
- title (str) – The question that the poll is asking.
- options (iterable) – An iterable of elements accepting the
- id (int) – The poll ID on strawpoll. If the poll has not been submitted on or retrieved from strawpoll, it’s None instead.
- multi (bool) – Specifies if the polls accepts multiple votes from one user. Defaults to
- dupcheck (str) – Defines how to handle checking for duplicate votes. Defaults to
- captcha (bool) – Specifies if the poll requires users to pass a captcha to vote. Defaults to
Returns a list of strings to represent the options for the poll, in the order they were given when the poll was created.
Return a list of integers that correspond to the same indexed option which specify the current votes for that option.
Returns the total number of votes on the poll.
Returns the url of the poll. If the poll has not been submitted yet, an empty string is returned instead.
Returns a list of tuples each containing a string representing an option and an int which specify the current votes for that option, ordered by their votes count.
Parameters: limit (int) – The maximum number of results to return. If not specified, every results will be returned.
Returns a tuple containing a string representing the option and an int which specify the current votes for that option.
Parameters: index (int) – The index of the wanted option in the options list.
Base class of all the other exceptions in strawpoll.py
Exception thrown when an attempt to submit a poll that already has been submitted is made.
Exception thrown when an HTTP request failed.
- response (aiohttp.ClientResponse) – The failed HTTP request’s response.
- text (str) – The error message extracted from the response. Can be an empty string.
- code (int) – The error code extracted from the response. Can be 0 if no error code was found.