def set(self, ctx, lamp, state):
"""
Set lamp state.
Changes state of [lamp] to [state] and sends server response
"""
tmp = await self.bot.send_message(ctx.message.channel, "Requesting")
payload = {'lamp': lamp, 'state': state, 'user_agent': 'AutomaBot'}
r = ""
try:
async with aiohttp.ClientSession() as session:
async with session.post(self.url_post, data=payload) as resp:
r = await resp.text()
except aiohttp.errors.ClientOSError:
raise APIconnectionError()
embed = make_embed_message("*Result!*", json.loads(r), self.bot,
ctx.message)
await self.bot.edit_message(tmp, new_content='Right now : ',
embed=embed)
评论列表
文章目录