diff --git a/scripts/dodo.py b/scripts/dodo.py index 2359424..dd3f81f 100644 --- a/scripts/dodo.py +++ b/scripts/dodo.py @@ -209,43 +209,42 @@ class RequestHandler(BaseHTTPRequestHandler): if not flag: self.msg_compoment(access_token, open_id, '指令错误') return - if orig_text == '/last': - try: - statuses = mastodon_cli.account_statuses(KEDAI_ID, limit=1) - s_text = BeautifulSoup(statuses[0]['content'], 'html.parser') - self.msg_compoment(access_token, open_id, - s_text.get_text('')) - except Exception as exc: - logger.error('operation error: %s', str(exc)) - elif orig_text == '/del': - try: - statuses = mastodon_cli.account_statuses(KEDAI_ID, limit=1) - mastodon_cli.status_delete(statuses[0]['id']) - s_text = BeautifulSoup(statuses[0]['content'], 'html.parser') - self.msg_compoment(access_token, open_id, - '已删除: ' + s_text.get_text('')) - except Exception as exc: - logger.error('operation error: %s', str(exc)) - elif orig_text.startswith('/deploy '): - site_ = orig_text.split('/deploy ')[1] - if site_ == 'dsite': - self.msg_compoment(access_token, open_id, '🚧 %s 开始部署 🚧' % site_) - subprocess.call("/root/deploy/dsite_prepare.sh") - subprocess.run(["supervisorctl", "restart", "dsite"]) - self.msg_compoment(access_token, open_id, '🎉 %s 部署成功 🎉' % site_) - else: - self.msg_compoment(access_token, open_id, '⚠️ %s 不存在 ⚠️' % site_) - return - elif orig_text.startswith('/菜谱 '): - content = orig_text.split('/菜谱 ')[1] - recipe_ = recipe.models.Recipe.create_from_str(content) - if recipe_: - self.msg_compoment(access_token, open_id, None, - const.LARK_WEBHOOK_MSG_TYPE_INTERACTIVE, - recipe_.construct_lart_card()) - else: - self.msg_compoment(access_token, open_id, '⚠️ 创建失败 ⚠️') - return + if orig_text == '/last': + try: + statuses = mastodon_cli.account_statuses(KEDAI_ID, limit=1) + s_text = BeautifulSoup(statuses[0]['content'], 'html.parser') + self.msg_compoment(access_token, open_id, + s_text.get_text('')) + except Exception as exc: + logger.error('operation error: %s', str(exc)) + elif orig_text == '/del': + try: + statuses = mastodon_cli.account_statuses(KEDAI_ID, limit=1) + mastodon_cli.status_delete(statuses[0]['id']) + s_text = BeautifulSoup(statuses[0]['content'], 'html.parser') + self.msg_compoment(access_token, open_id, + '已删除: ' + s_text.get_text('')) + except Exception as exc: + logger.error('operation error: %s', str(exc)) + elif orig_text.startswith('/deploy '): + site_ = orig_text.split('/deploy ')[1] + if site_ == 'dsite': + self.msg_compoment(access_token, open_id, '🚧 %s 开始部署 🚧' % site_) + subprocess.call("/root/deploy/dsite_prepare.sh") + subprocess.run(["supervisorctl", "restart", "dsite"]) + self.msg_compoment(access_token, open_id, '🎉 %s 部署成功 🎉' % site_) + else: + self.msg_compoment(access_token, open_id, '⚠️ %s 不存在 ⚠️' % site_) + elif orig_text.startswith('/菜谱 '): + content = orig_text.split('/菜谱 ')[1] + recipe_ = recipe.models.Recipe.create_from_str(content) + if recipe_: + self.msg_compoment(access_token, open_id, None, + const.LARK_WEBHOOK_MSG_TYPE_INTERACTIVE, + recipe_.construct_lart_card()) + else: + self.msg_compoment(access_token, open_id, '⚠️ 创建失败 ⚠️') + return try: toot_resp = mastodon_cli.status_post(text)