feat(dodo.py): [M] 增加上一条和删除上一条嘟嘟的功能
[M] 增加上一条和删除上一条嘟嘟的功能 Signed-off-by: Ching <loooching@gmail.com>
This commit is contained in:
parent
78ef05b68e
commit
047bd00545
@ -19,6 +19,7 @@ APP_SECRET = 'yuSQenId0VfvwdZ3qL9wMd8FpCMEUL0u'
|
||||
ENCRYPT_KEY = '4XfjcA5xou3pztBD4g5V7dgHtr0BBYDE'
|
||||
EVENT_TYPE = ['im.message.receive_v1']
|
||||
ADD_GROUP_NAME = True
|
||||
KEDAI_ID = '107263380636355825'
|
||||
|
||||
logging.basicConfig(filename='/root/develop/log/dodo.log', level=logging.INFO)
|
||||
logger = logging.getLogger('/root/develop/log/dodo.log')
|
||||
@ -166,11 +167,13 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
|
||||
# 机器人回复收到的消息
|
||||
text = json.loads(msg.get('content')).get('text')
|
||||
orig_text = text
|
||||
if msg.get('chat_type') == 'group' and msg.get('mentions'):
|
||||
open_id = {"open_chat_id": msg.get("chat_id")}
|
||||
for mention in msg.get('mentions'):
|
||||
text = text.replace(mention['key'], '')
|
||||
text = text.lstrip()
|
||||
orig_text = text
|
||||
if ADD_GROUP_NAME:
|
||||
group_name = get_group_name(msg.get("chat_id"))
|
||||
text = '%s #%s' % (text, group_name)
|
||||
@ -178,6 +181,24 @@ class RequestHandler(BaseHTTPRequestHandler):
|
||||
open_id = {"open_id": event.get("sender", {}).get(
|
||||
'sender_id', {}).get('open_id')}
|
||||
self.response("")
|
||||
if orig_text == '/last':
|
||||
try:
|
||||
statuses = mastodon.account_statuses(KEDAI_ID, limit=1)
|
||||
self.msg_compoment(access_token, open_id,
|
||||
statuses[0]['content'])
|
||||
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'])
|
||||
self.msg_compoment(access_token, open_id,
|
||||
'已删除: ' + statuses[0]['content'])
|
||||
except Exception as exc:
|
||||
logger.error('operation error: %s', str(exc))
|
||||
|
||||
|
||||
|
||||
try:
|
||||
toot_resp = mastodon.status_post(text)
|
||||
if toot_resp.get('id'):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user