|
|
@@ -1,4 +1,4 @@
|
|
|
-from flask import Flask, request
|
|
|
+from flask import Flask, request, abort, send_file
|
|
|
import pandas as pd
|
|
|
from openai import OpenAI
|
|
|
import requests
|
|
|
@@ -277,7 +277,6 @@ def chat():
|
|
|
elif notice_type == "notify" and data['target_id'] == data['self_id']:
|
|
|
user_id = data['user_id']
|
|
|
print(f"我被{user_id}戳了一下!")
|
|
|
- send_group_poke(group_id,user_id)
|
|
|
if get_week()=="星期四":
|
|
|
# 触发疯狂星期四文案
|
|
|
# 生成一个0到99之间的随机整数,控制特殊文案概率为40%
|
|
|
@@ -286,10 +285,44 @@ def chat():
|
|
|
send_group_message_word(group_id,get_v50()) if rand_num < 30 else send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
|
else:
|
|
|
send_group_message_word(group_id,"₍^ >ヮ<^₎")
|
|
|
+ send_group_poke(group_id, user_id)
|
|
|
elif data_type == "meta_event":
|
|
|
if data["meta_event_type"] == "heartbeat" and data["status"]['online'] == True:
|
|
|
last_heartbeat_time = data['time']
|
|
|
return ""
|
|
|
|
|
|
+
|
|
|
+# 允许的图片文件扩展名
|
|
|
+ALLOWED_EXTENSIONS = {'.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp'}
|
|
|
+
|
|
|
+
|
|
|
+@app.route('/pic', methods=['GET'])
|
|
|
+def pic_send():
|
|
|
+ # 获取URL参数中的path
|
|
|
+ image_path = request.args.get('path')
|
|
|
+
|
|
|
+ # 检查path参数是否存在
|
|
|
+ if not image_path:
|
|
|
+ abort(400, description="缺少path参数")
|
|
|
+
|
|
|
+ # 检查文件是否存在
|
|
|
+ if not os.path.exists(image_path):
|
|
|
+ abort(404, description="图片文件不存在")
|
|
|
+
|
|
|
+ # 检查文件是否为图片类型
|
|
|
+ file_ext = os.path.splitext(image_path)[1].lower()
|
|
|
+ if file_ext not in ALLOWED_EXTENSIONS:
|
|
|
+ abort(400, description="不支持的文件类型,仅允许图片文件")
|
|
|
+
|
|
|
+ # 检查是否为文件(不是目录)
|
|
|
+ if not os.path.isfile(image_path):
|
|
|
+ abort(400, description="指定路径不是文件")
|
|
|
+
|
|
|
+ try:
|
|
|
+ # 返回图片文件
|
|
|
+ return send_file(image_path)
|
|
|
+ except Exception as e:
|
|
|
+ abort(500, description=f"服务器错误:{str(e)}")
|
|
|
+
|
|
|
if __name__ == '__main__':
|
|
|
app.run(host='0.0.0.0', port=3100)
|