|
@@ -39,6 +39,8 @@ prompt_less = config_get("prompt_less")
|
|
|
|
|
|
# 一个比较没用的变量,用来限制绘画cd的,现在默认是0就是无cd
|
|
# 一个比较没用的变量,用来限制绘画cd的,现在默认是0就是无cd
|
|
last_request_time = 0
|
|
last_request_time = 0
|
|
|
|
+# 最近一次的心跳上报时间,用来记录服务状态
|
|
|
|
+last_heartbeat_time = time.time()
|
|
|
|
|
|
def on_my_message(group_id, user_id, user_name, raw_message, message):
|
|
def on_my_message(group_id, user_id, user_name, raw_message, message):
|
|
"""
|
|
"""
|
|
@@ -200,8 +202,14 @@ def change2girl(raw_message,group_id,user_id):
|
|
else:
|
|
else:
|
|
print('未找到 QQ 号')
|
|
print('未找到 QQ 号')
|
|
|
|
|
|
|
|
+
|
|
|
|
+@app.route('/stat', methods=['GET'])
|
|
|
|
+def stat_get():
|
|
|
|
+ return {"heartbeat": last_heartbeat_time}
|
|
|
|
+
|
|
@app.route('/cat', methods=['POST'])
|
|
@app.route('/cat', methods=['POST'])
|
|
def chat():
|
|
def chat():
|
|
|
|
+ global last_heartbeat_time
|
|
data = request.json
|
|
data = request.json
|
|
data_type = data['post_type']
|
|
data_type = data['post_type']
|
|
# 管理员模式,目前只有开启主机功能
|
|
# 管理员模式,目前只有开启主机功能
|
|
@@ -278,6 +286,9 @@ def chat():
|
|
send_group_message_word(group_id,get_v50()) if rand_num < 30 else send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
send_group_message_word(group_id,get_v50()) if rand_num < 30 else send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
else:
|
|
else:
|
|
send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
|
|
+ elif data_type == "meta_event":
|
|
|
|
+ if data["meta_event_type"] == "heartbeat":
|
|
|
|
+ last_heartbeat_time = data['time']
|
|
return ""
|
|
return ""
|
|
|
|
|
|
if __name__ == '__main__':
|
|
if __name__ == '__main__':
|