Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Commit 66910ca

Browse files
committed
Prepare for switch to gateway-proxy
1 parent a97eeed commit 66910ca

File tree

7 files changed

+50
-41
lines changed

7 files changed

+50
-41
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
application.yml
22
commands.txt
33
/config.toml
4+
/config.json
45
__pycache__
56
*.pyc
67
nohup.out

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Note: This requires you to have Podman and Git working. Development instances wi
2525
git clone https://git.travitia.xyz/Kenvyra/IdleRPG.git
2626
cd IdleRPG
2727
./scripts/beta.sh
28-
podman build -t idlerpg:latest --build-arg beta=yes .
29-
podman run --rm -it --name idlerpg --pod idlerpgbeta -v /path/to/config.py:/idlerpg/config.py idlerpg:latest
28+
podman build -t idlerpg:latest .
29+
podman run --rm -it --name idlerpg --pod idlerpgbeta -v $(pwd)/config.py:/idlerpg/config.py:Z idlerpg:latest
3030
```
3131

3232
### For hosting permanently

classes/bot.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,6 @@ def __init__(self, **kwargs):
9494
Cooldown(3, 3, 1, 2, commands.BucketType.user)
9595
)
9696

97-
async def before_identify_hook(
98-
self, shard_id: int | None, *, initial: bool = False
99-
) -> None:
100-
# Overwrite the default identify hook that just waits 5s with a call to twilight-gateway-queue
101-
if shard_id is None:
102-
self.logger.warn("Got no shard ID in before_identify_hook")
103-
return
104-
105-
self.logger.info(f"Requesting gateway queue for shard {shard_id}")
106-
107-
# This can take a while
108-
timeout = aiohttp.ClientTimeout(total=None)
109-
await self.session.get(
110-
f"http://localhost:5112/?shard={shard_id}", timeout=timeout
111-
)
112-
113-
self.logger.info(f"Gateway queue permitted shard {shard_id}")
114-
11597
def __repr__(self):
11698
return "<Bot>"
11799

cogs/miscellaneous/__init__.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,6 @@ async def streak(self, ctx):
210210
)
211211
)
212212

213-
@commands.command(brief=_("Show the bot's ping"))
214-
@locale_doc
215-
async def ping(self, ctx):
216-
_("""Shows you the bot's current websocket latency in milliseconds.""")
217-
await ctx.send(
218-
embed=discord.Embed(
219-
title=_("Pong!"),
220-
description=_("My current latency is {lat}ms").format(
221-
lat=round(self.bot.latency * 1000, 2)
222-
),
223-
color=0xF1C60C,
224-
)
225-
)
226-
227213
@commands.command(aliases=["shorten"], brief=_("Shorten an image URL."))
228214
@locale_doc
229215
async def imgur(self, ctx, given_url: ImageUrl(ImageFormat.all) = None):

launcher.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
"""
1818
from __future__ import annotations
1919

20-
import asyncio
2120
import sys
2221

22+
if sys.version_info < (3, 9):
23+
raise Exception("IdleRPG requires Python 3.9")
24+
25+
import asyncio
26+
2327
from enum import Enum
2428
from pathlib import Path
2529
from time import time
@@ -32,9 +36,6 @@
3236
from utils import random
3337
from utils.config import ConfigLoader
3438

35-
if sys.version_info < (3, 9):
36-
raise Exception("IdleRPG requires Python 3.9")
37-
3839
config = ConfigLoader("config.toml")
3940

4041
__version__ = "1.0.0"

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ discord.py
1414
aiowiki
1515
sentry_sdk
1616
aioredis[hiredis]
17+
aiohttp[speedups]
1718
tomli

scripts/beta.sh

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,46 @@
33
podman pull docker://docker.io/library/redis:6-alpine
44
podman pull docker://docker.io/library/postgres:14-alpine
55
podman pull quay.io/gelbpunkt/stockfish:latest
6+
podman pull docker://docker.io/twilightrs/http-proxy:latest
7+
podman pull docker://docker.io/gelbpunkt/gateway-proxy:latest
68
podman pod create --name idlerpgbeta -p 5432:5432 -p 6379:6379
7-
podman run --rm -d --pod idlerpgbeta --name redis-beta redis:6-alpine
9+
10+
TOKEN=$(python3 -c 'from utils.config import ConfigLoader; config = ConfigLoader("config.toml"); print(config.bot.token)')
11+
12+
podman run --rm -it -d --pod idlerpgbeta --name http-proxy -e HOST=0.0.0.0 -e PORT=5113 -e DISCORD_TOKEN=$TOKEN http-proxy:latest
13+
14+
cat <<EOF > config.json
15+
{
16+
"log_level": "info",
17+
"token": "$TOKEN",
18+
"intents": 13827,
19+
"port": 5112,
20+
"activity": {
21+
"type": 0,
22+
"name": "https://idlerpg.xyz"
23+
},
24+
"status": "idle",
25+
"backpressure": 100,
26+
"twilight_http_proxy": "127.0.0.1:5113",
27+
"shards": 5,
28+
"cache": {
29+
"channels": true,
30+
"presences": false,
31+
"emojis": false,
32+
"current_member": true,
33+
"members": false,
34+
"roles": true,
35+
"stage_instances": false,
36+
"stickers": false,
37+
"users": false,
38+
"voice_states": false
39+
}
40+
}
41+
EOF
42+
43+
podman run --rm -it -d --pod idlerpgbeta --name gateway-proxy -v $(pwd)/config.json:/config.json:Z gateway-proxy:latest
44+
45+
podman run --rm -it -d --pod idlerpgbeta --name redis-beta redis:6-alpine
846
cat <<EOF > start.sh
947
createdb idlerpg
1048
psql idlerpg -c "CREATE ROLE jens WITH PASSWORD 'owo';"
@@ -18,7 +56,7 @@ DONE
1856
EOF
1957

2058
chmod 777 start.sh
21-
podman run --rm -d --pod idlerpgbeta --name postgres-beta -e POSTGRES_PASSWORD="test" -v $(pwd)/start.sh:/docker-entrypoint-initdb.d/init.sh:Z postgres:14-alpine
59+
podman run --rm -it -d --pod idlerpgbeta --name postgres-beta -e POSTGRES_PASSWORD="test" -v $(pwd)/start.sh:/docker-entrypoint-initdb.d/init.sh:Z postgres:14-alpine
2260
sleep 15
2361
rm start.sh
24-
podman run --rm -d --pod idlerpgbeta --name stockfish-beta gelbpunkt/stockfish:latest
62+
podman run --rm -it -d --pod idlerpgbeta --name stockfish-beta gelbpunkt/stockfish:latest

0 commit comments

Comments
 (0)