File size: 916 Bytes
02f0051
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from flask import Flask, request
import pusher
import os

app = Flask(__name__)

# 从 Space Storage 加载 Pusher 凭证
if os.path.exists('/data/pusher_credentials.json'):
    import json
    with open('/data/pusher_credentials.json') as f:
        credentials = json.load(f)
    pusher_client = pusher.Pusher(
        app_id=credentials['app_id'],
        key=credentials['key'],
        secret=credentials['secret'],
        cluster='mt1',
        ssl=True
    )
else:
    # 默认占位凭证(请替换)
    pusher_client = pusher.Pusher(
        app_id='YOUR_APP_ID',
        key='YOUR_KEY',
        secret='YOUR_SECRET',
        cluster='mt1',
        ssl=True
    )

@app.route('/webhook', methods=['POST'])
def webhook():
    update = request.json
    pusher_client.trigger('openclaw_bot', 'telegram_message', update)
    return '', 200

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=3031)