返回提交历史
Modified
projects/discord-bot/.env.example
+4
-0
Modified
projects/discord-bot/README.md
+2
-0
Modified
projects/discord-bot/bot.py
+5
-3
Modified
projects/discord-bot/live_feed.py
+1
-0
XFEstudio/gpt4free
fix(discord-bot): make live feed config reliable
Co-authored-by: hlohaus <983577+hlohaus@users.noreply.github.com>
1ebaa215
代码差异
4 个文件
+12
-3
@@ -52,6 +52,10 @@ G4F_MAX_HISTORY=12
52
52
# Base URL of the g4f API server (where /api/logs is served).
53
53
# G4F_API_BASE=http://localhost:8080
54
54
55
# Optional API key for reading /api/logs when the API server is protected.
56
# Uses the same key you configured for the g4f API server.
57
# G4F_API_KEY=
58
55
59
# Public base URL for Discord-accessible image/thumbnail links.
56
60
# Defaults to G4F_API_BASE. Set this if the API server is behind a tunnel
57
61
# or reverse proxy and Discord needs a different host to fetch images.
@@ -169,6 +169,7 @@ To keep the channel readable, at most `G4F_FEED_MAX_POSTS_PER_CYCLE` embeds are
169
169
```bash
170
170
G4F_LIVE_FEED_CHANNEL=123456789012345678
171
171
G4F_API_BASE=http://localhost:8080 # where the g4f API runs
172
G4F_API_KEY=your-g4f-api-key # optional; required if /api/logs is protected
172
173
G4F_PUBLIC_BASE=https://your-public-host # optional, for Discord-accessible image links
173
174
G4F_MEMBERS_BASE=https://g4f.dev # set empty to disable new-user posts
174
175
```
@@ -181,6 +182,7 @@ G4F_MEMBERS_BASE=https://g4f.dev # set empty to disable new-user post
181
182
|---|---|---|
182
183
| `G4F_LIVE_FEED_CHANNEL` | *(unset)* | Discord channel ID for the feed. Unset = disabled. |
183
184
| `G4F_API_BASE` | `http://localhost:8080` | g4f API base URL (must expose `/api/logs`). |
185
| `G4F_API_KEY` | *(unset)* | Optional API key used to read `/api/logs` on protected g4f API servers. |
184
186
| `G4F_PUBLIC_BASE` | = `G4F_API_BASE` | Public base URL for Discord-accessible image/thumbnail links. |
185
187
| `G4F_MEMBERS_BASE` | `https://g4f.dev` | g4f.dev base URL for new-user posts. Empty = disabled. |
186
188
| `G4F_FEED_POLL_INTERVAL` | `15` | Seconds between polls. |
@@ -62,8 +62,10 @@ MAX_TOOL_LOOPS = int(os.getenv("G4F_MAX_TOOL_LOOPS", "4")) # safety cap
62
62
LIVE_FEED_CHANNEL = int(os.getenv("G4F_LIVE_FEED_CHANNEL", "0") or "0")
63
63
API_BASE = os.getenv("G4F_API_BASE", "http://localhost:8080")
64
64
PUBLIC_BASE = os.getenv("G4F_PUBLIC_BASE", API_BASE)
65
PUBLIC_API_KEY = os.getenv("G4F_PUBLIC_API_KEY", "")
66
MEMBERS_BASE = os.getenv("G4F_MEMBERS_BASE", "https://auth.g4f.dev")
65
# Optional API key used to read /api/logs when the g4f API is protected.
66
# Prefer G4F_API_KEY; keep G4F_PUBLIC_API_KEY as a backwards-compatible alias.
67
FEED_API_KEY = os.getenv("G4F_API_KEY") or os.getenv("G4F_PUBLIC_API_KEY", "")
68
MEMBERS_BASE = os.getenv("G4F_MEMBERS_BASE", "https://g4f.dev")
67
69
FEED_POLL_INTERVAL = int(os.getenv("G4F_FEED_POLL_INTERVAL", "15"))
68
70
HEAVY_TOKEN_THRESHOLD = int(os.getenv("G4F_HEAVY_TOKEN_THRESHOLD", "10000"))
69
71
FEED_SUMMARY_INTERVAL = int(os.getenv("G4F_FEED_SUMMARY_INTERVAL", "3600"))
@@ -768,7 +770,7 @@ async def on_ready():
768
770
channel_id=LIVE_FEED_CHANNEL,
769
771
api_base=API_BASE,
770
772
public_base=PUBLIC_BASE,
771
api_key=PUBLIC_API_KEY,
773
api_key=FEED_API_KEY,
772
774
members_base=MEMBERS_BASE or None,
773
775
poll_interval=FEED_POLL_INTERVAL,
774
776
heavy_token_threshold=HEAVY_TOKEN_THRESHOLD,
@@ -352,6 +352,7 @@ class LiveFeed(commands.Cog):
352
352
self._providers: Counter = Counter()
353
353
self._last_summary: float = time.time()
354
354
355
self.poll.change_interval(seconds=max(1, poll_interval))
355
356
self.poll.start()
356
357
log.info(
357
358
"LiveFeed cog started — channel=%s api=%s members=%s interval=%ds",