rr-server-temp QQ 发不了图可以用

koishi-plugin-rr-server-temp

npm

一个官方 server-temp 的不完全实现,开箱即用

server-temp 服务就像眼镜,当你需要它的时候你就知道,它有什么用。

更新日志

  • 0.0.2 初始版本
  • 0.0.5 代码丢了,对着构建产物誊抄了一份…
3 个赞
2 个赞

目前搭建在 共享实例 上,如果对数据隐私有任何一点要求,或者你是赛博佛祖 T4,请自建

自建了为什么不直接用官方的呢(

Copilot 写的,我不知道这是啥
from flask import Flask, request, send_from_directory, abort
import os
import threading
import time
import uuid
import logging


MAX_UPLOAD_SIZE_MB = 10
UPLOAD_FOLDER = "uploads"
IP_ADDRESS = "42.193.147.60"
PORT = 4244

logging.basicConfig(level=logging.INFO)
app = Flask(__name__)
app.config["MAX_CONTENT_LENGTH"] = MAX_UPLOAD_SIZE_MB * 1024 * 1024
os.makedirs(UPLOAD_FOLDER, exist_ok=True)


@app.route("/portal/push", methods=["POST"])
def push_something():
    if "file" not in request.files:
        return "No file part", 400
    file = request.files["file"]
    if file:
        filename = str(uuid.uuid4())
        filepath = os.path.join(UPLOAD_FOLDER, filename)
        logging.info(f"Saving file: {filename}")
        file.save(filepath)
        threading.Thread(target=delete_file, args=(filepath,)).start()
        return f"http://{IP_ADDRESS}:{PORT}/portal/pull/{filename}"


@app.route("/portal/pull/<filename>", methods=["GET"])
def pull_something(filename):
    if filename:
        filepath = os.path.join(UPLOAD_FOLDER, filename)
        if os.path.exists(filepath):
            logging.info(f"Serving file: {filename}")
            return send_from_directory(UPLOAD_FOLDER, filename, as_attachment=True)
        else:
            abort(404)
    else:
        return "File parameter is missing", 400


def delete_file(filepath):
    time.sleep(60)
    if os.path.exists(filepath):
        os.remove(filepath)
        logging.info(f"Deleted file: {os.path.basename(filepath)}")


if __name__ == "__main__":
    for filename in os.listdir(UPLOAD_FOLDER):
        filepath = os.path.join(UPLOAD_FOLDER, filename)
        if os.path.isfile(filepath):
            os.remove(filepath)
            logging.info(f"Deleted file: {filename}")
    
    app.run(host="0.0.0.0", port=PORT)

2 个赞

rr 系列,复活!

1 个赞

快去群里给夜猫子们宣传一下(x

2 个赞

为什么等我把服务器弄好了你才发:sob:

3 个赞

42是神!

3 个赞

顺便发到GG网盘备份了一个

1 个赞

GG Drive!

2 个赞

QQ 适配器不再需要 server-temp 服务,完结撒花~

我服务器也完结撒花了(
image

不!我的插件还需要server-temp服务呢!:sob:

2 个赞

啊,怎么个事?不用servertemp可以发图了?

2 个赞
3 个赞