fix(dodo): 修复指令执行后当成嘟嘟发送的问题

修复指令执行后当成嘟嘟发送的问题

Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
Ching 2022-01-21 14:22:22 +08:00
parent e51ab984fd
commit a0fa3ac98c

View File

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