diff --git a/packages/osu/Dockerfile b/packages/osu/Dockerfile index f650a97f..a5cd959c 100644 --- a/packages/osu/Dockerfile +++ b/packages/osu/Dockerfile @@ -1,5 +1,5 @@ # Use the official Bun image -FROM oven/bun:1 AS base +FROM oven/bun AS base WORKDIR /usr/src/app # Install dependencies into temp directory (cache them to speed up future builds) @@ -31,4 +31,4 @@ COPY . . # Run the app USER bun EXPOSE 3000/tcp -ENTRYPOINT [ "bun", "run", "src/index.ts" ] \ No newline at end of file +ENTRYPOINT [ "bun", "run", "src/index.ts" ] diff --git a/packages/osu/bun.lockb b/packages/osu/bun.lockb index eca206d2..37127957 100644 Binary files a/packages/osu/bun.lockb and b/packages/osu/bun.lockb differ diff --git a/packages/osu/package.json b/packages/osu/package.json index 5ed08290..8af483b2 100644 --- a/packages/osu/package.json +++ b/packages/osu/package.json @@ -14,7 +14,8 @@ "dependencies": { "@types/express": "^5.0.0", "@types/irc": "^0.5.4", + "axios": "^1.7.9", "express": "^4.21.2", "irc": "0.5.0" } -} \ No newline at end of file +} diff --git a/packages/osu/src/index.ts b/packages/osu/src/index.ts index 0003014c..2d9746dd 100644 --- a/packages/osu/src/index.ts +++ b/packages/osu/src/index.ts @@ -1,8 +1,9 @@ import { Client } from "irc"; import express from "express"; +import axios from "axios"; function setupIrc() { - const client = new Client("irc.ppy.sh", process.env.IRC_USERNAME, { + const client = new Client("irc.ppy.sh", process.env.IRC_USERNAME!, { channels: ["#osu"], userName: process.env.IRC_USERNAME, password: process.env.IRC_PASSWORD, @@ -16,14 +17,18 @@ function setupIrc() { console.log("Registered", message); }); - client.addListener("message", function (from, to, message) { - console.log(from + " => " + to + ": " + message); + client.addListener("message", async function (from, to, message) { + await axios.post("http://laravel.test/api/osu_messages", { + username: from, + channel: to, + message, + }); }); return client; } -function setupExpress(ircClient) { +function setupExpress(ircClient: Client) { const app = express(); app.use(express.json()); diff --git a/packages/osu/workflows/docker-image.yml b/packages/osu/workflows/docker-image.yml index 3f53646d..21fbfa4a 100644 --- a/packages/osu/workflows/docker-image.yml +++ b/packages/osu/workflows/docker-image.yml @@ -2,17 +2,15 @@ name: Docker Image CI on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: - build: - runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - name: Build the Docker image - run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) + - uses: actions/checkout@v4 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/packages/web/app/Http/Controllers/OsuMessageController.php b/packages/web/app/Http/Controllers/OsuMessageController.php new file mode 100644 index 00000000..fffc21be --- /dev/null +++ b/packages/web/app/Http/Controllers/OsuMessageController.php @@ -0,0 +1,74 @@ +validate([ + 'username' => 'required', + 'channel' => 'required', + 'message' => 'required', + ]); + + OsuMessage::create($validated); + } + + /** + * Display the specified resource. + */ + public function show(OsuMessage $osuMessage) + { + // + } + + /** + * Show the form for editing the specified resource. + */ + public function edit(OsuMessage $osuMessage) + { + // + } + + /** + * Update the specified resource in storage. + */ + public function update(Request $request, OsuMessage $osuMessage) + { + // + } + + /** + * Remove the specified resource from storage. + */ + public function destroy(OsuMessage $osuMessage) + { + // + } +} diff --git a/packages/web/app/Models/OsuMessage.php b/packages/web/app/Models/OsuMessage.php new file mode 100644 index 00000000..0d3cb148 --- /dev/null +++ b/packages/web/app/Models/OsuMessage.php @@ -0,0 +1,10 @@ +listenForMessages(); - } + public function __construct() {} public function getAccessToken() { diff --git a/packages/web/database/migrations/2024_10_31_202800_make_app_models.php b/packages/web/database/migrations/2024_10_31_202800_make_app_models.php index 43c9d282..daa6402f 100644 --- a/packages/web/database/migrations/2024_10_31_202800_make_app_models.php +++ b/packages/web/database/migrations/2024_10_31_202800_make_app_models.php @@ -225,6 +225,15 @@ public function up(): void $table->timestamps(); }); + Schema::create('osu_messages', function (Blueprint $table) { + $table->id(); + $table->string('message'); + $table->string('channel'); + $table->string('username'); + $table->foreignIdFor(Profile::class)->nullable(); + $table->timestamps(); + }); + } /** diff --git a/packages/web/routes/api.php b/packages/web/routes/api.php new file mode 100644 index 00000000..d3d9cb2d --- /dev/null +++ b/packages/web/routes/api.php @@ -0,0 +1,6 @@ +