fix(dodo): 修复删除嘟文时报错的问题
修复删除嘟文时报错的问题 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
e2ed14784a
commit
33631e2b94
@ -26,7 +26,7 @@ KEDAI_ID = '107263380636355825'
|
|||||||
logging.basicConfig(filename='/root/develop/log/dodo.log', level=logging.INFO)
|
logging.basicConfig(filename='/root/develop/log/dodo.log', level=logging.INFO)
|
||||||
logger = logging.getLogger('/root/develop/log/dodo.log')
|
logger = logging.getLogger('/root/develop/log/dodo.log')
|
||||||
|
|
||||||
mastodon = Mastodon(
|
mastodon_cli = Mastodon(
|
||||||
access_token = 'Ug_bUMWCk3RLamOnqYIytmeB0nO6aNfjdmf06mAj2bE',
|
access_token = 'Ug_bUMWCk3RLamOnqYIytmeB0nO6aNfjdmf06mAj2bE',
|
||||||
api_base_url = 'https://nofan.xyz'
|
api_base_url = 'https://nofan.xyz'
|
||||||
)
|
)
|
||||||
@ -83,7 +83,8 @@ def get_tenant_access_token(): # 获取token
|
|||||||
if code != 0:
|
if code != 0:
|
||||||
logger.error("get tenant_access_token error, code =%s", code)
|
logger.error("get tenant_access_token error, code =%s", code)
|
||||||
return ""
|
return ""
|
||||||
token = redis_cli.set('tenant_access_token_%s' % APP_ID,
|
token = rsp_dict.get("tenant_access_token", "")
|
||||||
|
redis_cli.set('tenant_access_token_%s' % APP_ID,
|
||||||
rsp_dict.get("tenant_access_token", ""),
|
rsp_dict.get("tenant_access_token", ""),
|
||||||
ex=60*30)
|
ex=60*30)
|
||||||
|
|
||||||
@ -113,6 +114,10 @@ def get_group_name(chat_id):
|
|||||||
|
|
||||||
|
|
||||||
class RequestHandler(BaseHTTPRequestHandler):
|
class RequestHandler(BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
"""Serve a GET request."""
|
||||||
|
self.response("")
|
||||||
|
|
||||||
def do_POST(self):
|
def do_POST(self):
|
||||||
# 解析请求 body
|
# 解析请求 body
|
||||||
req_body = self.rfile.read(int(self.headers['content-length']))
|
req_body = self.rfile.read(int(self.headers['content-length']))
|
||||||
@ -191,7 +196,7 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
if orig_text == '/last':
|
if orig_text == '/last':
|
||||||
try:
|
try:
|
||||||
statuses = mastodon.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(''))
|
||||||
@ -199,8 +204,8 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
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.account_statuses(KEDAI_ID, limit=1)
|
statuses = mastodon_cli.account_statuses(KEDAI_ID, limit=1)
|
||||||
Mastodon.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(''))
|
||||||
@ -218,7 +223,7 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
toot_resp = mastodon.status_post(text)
|
toot_resp = mastodon_cli.status_post(text)
|
||||||
if toot_resp.get('id'):
|
if toot_resp.get('id'):
|
||||||
self.msg_compoment(access_token, open_id, '📟 dodo 📟')
|
self.msg_compoment(access_token, open_id, '📟 dodo 📟')
|
||||||
redis_cli.set(event_id, int(time.time()), ex=60*60*7)
|
redis_cli.set(event_id, int(time.time()), ex=60*60*7)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user