def _strawpoll(self, ctx, *, question, options=None):
"""Makes a poll based on questions and choices or options. must be divided by "; "
Examples:
[p]strawpoll What is this person?; Who is this person?; Where is this person?; When is this person coming?
[p]strawpoll What; Who?; Where?; When?; Why?"""
options_list = question.split('; ')
title = options_list[0]
options_list.remove(title)
if len(options_list) < 2:
await self.bot.say("You need to specify 2 or more options")
else:
normal = {"title": title, "options": options_list}
request = dict(normal, **self.settings)
async with aiohttp.request('POST', 'http://strawpoll.me/api/v2/polls',
headers={'content-type': 'application/json'},
data=json.dumps(request)) as resp:
test = await resp.content.read()
test = json.loads(test.decode())
sid = test["id"]
await self.bot.say("Here's your strawpoll link: http://strawpoll.me/{}".format(sid))
评论列表
文章目录