feat(dodo): [A] 增加飞书机器人部署逻辑
[A] 增加飞书机器人部署逻辑 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
2280fd25c1
commit
e2ed14784a
@ -12,6 +12,8 @@ import logging
|
||||
import redis
|
||||
import requests
|
||||
import time
|
||||
import subprocess
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
APP_VERIFICATION_TOKEN = 'uKQQiOVMYg2cTgrjkyBmodrHTUaCXzG3'
|
||||
APP_ID = 'cli_a115fe8b83f9100c'
|
||||
@ -181,23 +183,39 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
open_id = {"open_id": event.get("sender", {}).get(
|
||||
'sender_id', {}).get('open_id')}
|
||||
self.response("")
|
||||
if orig_text.startswith('/'):
|
||||
redis_cli.set(event_id, int(time.time()), ex=60*60*7)
|
||||
if orig_text not in ['/last', '/del']:
|
||||
if not orig_text.startswith('/deploy '):
|
||||
self.msg_compoment(access_token, open_id, '指令错误')
|
||||
return
|
||||
if orig_text == '/last':
|
||||
try:
|
||||
statuses = mastodon.account_statuses(KEDAI_ID, limit=1)
|
||||
s_text = BeautifulSoup(statuses[0]['content'], 'html.parser')
|
||||
self.msg_compoment(access_token, open_id,
|
||||
statuses[0]['content'])
|
||||
s_text.get_text(''))
|
||||
except Exception as exc:
|
||||
logger.error('operation error: %s', str(exc))
|
||||
elif orig_text == '/del':
|
||||
try:
|
||||
statuses = mastodon.account_statuses(KEDAI_ID, limit=1)
|
||||
Mastodon.status_delete(statuses[0]['id'])
|
||||
s_text = BeautifulSoup(statuses[0]['content'], 'html.parser')
|
||||
self.msg_compoment(access_token, open_id,
|
||||
'已删除: ' + statuses[0]['content'])
|
||||
'已删除: ' + 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
|
||||
|
||||
try:
|
||||
toot_resp = mastodon.status_post(text)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user