WIP: answer hamstudy by reaction

This commit is contained in:
Abigail Gold 2020-01-20 20:50:55 -05:00
parent 776ff72581
commit b6f6d0408c
No known key found for this signature in database
GPG Key ID: CF88335E873C3FB4
2 changed files with 18 additions and 6 deletions

View File

@ -44,7 +44,11 @@ emojis = SimpleNamespace(check_mark='✅',
warning='⚠️', warning='⚠️',
question='', question='',
no_entry='', no_entry='',
bangbang='‼️') bangbang='‼️',
a='🇦',
b='🇧',
c='🇨',
d='🇩')
paths = SimpleNamespace(data=Path("./data/"), paths = SimpleNamespace(data=Path("./data/"),
resources=Path("./resources/"), resources=Path("./resources/"),

View File

@ -152,16 +152,24 @@ class StudyCog(commands.Cog):
embed.description = self.source embed.description = self.source
embed.colour = cmn.colours.good embed.colour = cmn.colours.good
embed.add_field(name='Question:', value=question['text'], inline=False) embed.add_field(name='Question:', value=question['text'], inline=False)
embed.add_field(name='Answers:', value='**A:** ' + question['answers']['A'] embed.add_field(name='Answers:',
+ '\n**B:** ' + question['answers']['B'] value=(f"**{cmn.emojis.a}** {question['answers']['A']}"
+ '\n**C:** ' + question['answers']['C'] f"\n**{cmn.emojis.b}** {question['answers']['B']}"
+ '\n**D:** ' + question['answers']['D'], inline=False) f"\n**{cmn.emojis.c}** {question['answers']['C']}"
f"\n**{cmn.emojis.d}** {question['answers']['D']}"),
inline=False)
embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False) embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False)
if 'image' in question: if 'image' in question:
image_url = f'https://hamstudy.org/_1330011/images/{pool.split("_",1)[1]}/{question["image"]}' image_url = f'https://hamstudy.org/_1330011/images/{pool.split("_",1)[1]}/{question["image"]}'
embed.set_image(url=image_url) embed.set_image(url=image_url)
self.lastq[ctx.message.channel.id] = (question['id'], question['answer']) self.lastq[ctx.message.channel.id] = (question['id'], question['answer'])
await ctx.send(embed=embed) q_msg = await ctx.send(embed=embed)
await cmn.add_react(q_msg, cmn.emojis.a)
await cmn.add_react(q_msg, cmn.emojis.b)
await cmn.add_react(q_msg, cmn.emojis.c)
await cmn.add_react(q_msg, cmn.emojis.d)
@commands.command(name="hamstudyanswer", aliases=['rqa', 'randomquestionanswer', 'randomqa', 'hamstudya'], category=cmn.cat.study) @commands.command(name="hamstudyanswer", aliases=['rqa', 'randomquestionanswer', 'randomqa', 'hamstudya'], category=cmn.cat.study)
async def _q_answer(self, ctx: commands.Context, answer: str = None): async def _q_answer(self, ctx: commands.Context, answer: str = None):