feat(bots): built-in bot runner + steamfree from UI
- BotRunner: server-side goroutine manager for built-in bot types - steamfree bot embedded in server (polls Steam API, posts free games) - bot_type + config JSONB columns on bots table - Create/Update/Delete handlers manage runner lifecycle - GET /bots/types returns registered bot types - BotManager: type selector dropdown + config fields on create - No SSH needed: create a 'Steam Free Games' bot from /bots/manage
This commit is contained in:
+23
-4
@@ -6,6 +6,8 @@ export interface Bot {
|
||||
name: string;
|
||||
avatar: string | null;
|
||||
description: string;
|
||||
bot_type: string;
|
||||
config: Record<string, unknown>;
|
||||
owner_id: string;
|
||||
created_at: string;
|
||||
}
|
||||
@@ -31,13 +33,15 @@ export interface StoreBot {
|
||||
interface BotState {
|
||||
bots: Bot[];
|
||||
storeBots: StoreBot[];
|
||||
botTypes: string[];
|
||||
loading: boolean;
|
||||
error: string | null;
|
||||
|
||||
fetchBots: () => Promise<void>;
|
||||
fetchStoreBots: () => Promise<void>;
|
||||
createBot: (name: string, description: string) => Promise<Bot & { token: string }>;
|
||||
updateBot: (id: string, data: { name?: string; description?: string; avatar?: string }) => Promise<Bot>;
|
||||
fetchBotTypes: () => Promise<void>;
|
||||
createBot: (name: string, description: string, botType?: string, config?: Record<string, unknown>) => Promise<Bot & { token: string }>;
|
||||
updateBot: (id: string, data: { name?: string; description?: string; avatar?: string; bot_type?: string; config?: Record<string, unknown> }) => Promise<Bot>;
|
||||
deleteBot: (id: string) => Promise<void>;
|
||||
addToServer: (botId: string, serverId: string) => Promise<void>;
|
||||
removeFromServer: (botId: string, serverId: string) => Promise<void>;
|
||||
@@ -52,6 +56,7 @@ interface BotState {
|
||||
export const useBotStore = create<BotState>((set) => ({
|
||||
bots: [],
|
||||
storeBots: [],
|
||||
botTypes: [],
|
||||
loading: false,
|
||||
error: null,
|
||||
|
||||
@@ -81,10 +86,24 @@ export const useBotStore = create<BotState>((set) => ({
|
||||
}
|
||||
},
|
||||
|
||||
createBot: async (name, description) => {
|
||||
fetchBotTypes: async () => {
|
||||
try {
|
||||
const types = await api.get<string[]>('/bots/types');
|
||||
set({ botTypes: types });
|
||||
} catch {
|
||||
// silent
|
||||
}
|
||||
},
|
||||
|
||||
createBot: async (name, description, botType, config) => {
|
||||
set({ loading: true, error: null });
|
||||
try {
|
||||
const result = await api.post<Bot & { token: string }>('/bots', { name, description });
|
||||
const result = await api.post<Bot & { token: string }>('/bots', {
|
||||
name,
|
||||
description,
|
||||
bot_type: botType || '',
|
||||
config: config || {},
|
||||
});
|
||||
set((state) => ({
|
||||
bots: [...state.bots, result],
|
||||
loading: false,
|
||||
|
||||
Reference in New Issue
Block a user