Skip to content

Commit

Permalink
clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
vincelwt committed Dec 26, 2024
1 parent 1bfb983 commit cc05397
Show file tree
Hide file tree
Showing 7 changed files with 2 additions and 112 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ bun run index.ts
2. Once connected, you can:
- Use `/help` to see available commands
- Start conversations with the AI
- Join rooms using `/join roomname`
- Select models using `/model modelname`

## Development and Contribution
Expand All @@ -73,7 +72,6 @@ bun run index.ts

- `index.ts`: Main entry point, sets up the SSH server
- `clientSession.ts`: Manages individual client sessions and interactions
- `room.ts`: Implements room-based chat functionality
- `database.ts`: Handles database operations
- `types.ts`: Contains TypeScript type definitions
- `utils.ts`: Utility functions
Expand Down
6 changes: 0 additions & 6 deletions clientSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,6 @@ export class ClientSession implements IClientSession {
await this.handleInteractiveAuth("login");
return true;

case "/join":
case "/leave":
case "/rooms":
this.writeCommandOutput("Room functionality is currently disabled.");
return true;

case "/char":
if (!this.userId) {
this.writeCommandOutput(
Expand Down
12 changes: 0 additions & 12 deletions database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,4 @@ export async function testDatabaseConnection() {
}
}

export async function resetCredits() {
try {
await sql`
UPDATE accounts SET credits = 30 WHERE credits < 30;
UPDATE accounts SET credits = 10 WHERE credits < 10 AND email IS NULL;
`;
console.log("Credits reset completed");
} catch (error) {
console.error("Error resetting credits:", error);
}
}

export { sql };
9 changes: 2 additions & 7 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createServer, createHttpServer } from "./server";
import { testDatabaseConnection, resetCredits } from "./database";
import cron from "node-cron";
import { testDatabaseConnection } from "./database";

import OpenAI from "openai";
import { fetchAndCacheModelList } from "./clientSession";

Expand All @@ -21,11 +21,6 @@ export const openai = new OpenAI({
},
});

cron.schedule("0 0 * * *", async () => {
console.log("Running daily credit reset");
await resetCredits();
});

process.on("SIGINT", () => {
console.log("\nShutting down servers...");
sshServer.close();
Expand Down
67 changes: 0 additions & 67 deletions room.ts

This file was deleted.

15 changes: 0 additions & 15 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,6 @@ export interface ClientSession {
streamResponse(userMessage: string): Promise<void>;
}

export interface Room {
id: string;
name: string;
members: Set<ClientSession>;
addMember(session: ClientSession): void;
removeMember(session: ClientSession): void;
addMessage(
content: string,
userId: string | null,
isSystemMessage?: boolean
): Promise<void>;
broadcast(message: string, sender: ClientSession): Promise<void>;
getRecentMessages(limit?: number): Promise<any[]>;
}

export interface Character {
id: string;
name: string;
Expand Down
3 changes: 0 additions & 3 deletions utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ Available Commands:
/retry 0.8
/register - Register a new account
/login - Login to an existing account
/join <room_name> - Join a room (requires login)
/leave - Leave the current room (requires login)
/rooms - List all available rooms (requires login)
/char - Manage characters (use /char for subcommands)
/adventure - Start a text-based RPG adventure
/model - List available models or select a model:
Expand Down

0 comments on commit cc05397

Please sign in to comment.