openclaw-agent / pusher_proxy.py
Jacky2305's picture
Upload pusher_proxy.py with huggingface_hub
02f0051 verified
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)