automation.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:AutomaBot 作者: 73VW 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号