diff --git a/.DS_Store b/.DS_Store index 595bf3b..fe7153c 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/discord_glhf/handlers/event_handler.py b/discord_glhf/handlers/event_handler.py index 2cb9f88..8bf5a16 100644 --- a/discord_glhf/handlers/event_handler.py +++ b/discord_glhf/handlers/event_handler.py @@ -636,7 +636,7 @@ class EventHandler: }, ) - async def send_prompt_to_channel(self, prompt: str, channel_id: int) -> None: + async def send_prompt_to_channel(self, prompt: str, channel_id: int, username: str = "Web User") -> None: """Send a prompt to the LLM and post response in Discord channel.""" try: # Get the channel @@ -661,8 +661,8 @@ class EventHandler: "id": str(self.bot.user.id), }, "user_info": { - "name": "web_user", - "display_name": "Web User", + "name": username.lower().replace(" ", "_"), + "display_name": username, "id": "0", }, "timeout_env": "GLHF_TIMEOUT" @@ -675,8 +675,8 @@ class EventHandler: id=str(uuid.uuid4()), author=SimpleNamespace( id=0, - name="web_user", - display_name="Web User", + name=username.lower().replace(" ", "_"), + display_name=username, bot=False, discriminator="0000" ), diff --git a/discord_glhf/web/app.py b/discord_glhf/web/app.py index 927bc97..79e1caf 100644 --- a/discord_glhf/web/app.py +++ b/discord_glhf/web/app.py @@ -39,6 +39,10 @@ async def send_prompt(): if not data or 'prompt' not in data: return jsonify({'error': 'Missing prompt'}), 400 + username = data.get('username', 'Web User') + if not username.strip(): + username = 'Web User' + try: channel_id = int(str(data.get('channel_id', '1198637345701285999'))) except (ValueError, TypeError): @@ -48,8 +52,8 @@ async def send_prompt(): return jsonify({'error': 'Channel ID is required'}), 400 try: - # Attempt to send prompt to channel - await event_handler.send_prompt_to_channel(data['prompt'], channel_id) + # Attempt to send prompt to channel with username + await event_handler.send_prompt_to_channel(data['prompt'], channel_id, username=username) return jsonify({ 'status': 'processing', 'message': f'Prompt sent to channel {channel_id}' diff --git a/discord_glhf/web/templates/index.html b/discord_glhf/web/templates/index.html index a4aa4c6..6dcc72b 100644 --- a/discord_glhf/web/templates/index.html +++ b/discord_glhf/web/templates/index.html @@ -25,6 +25,20 @@ placeholder="Enter your prompt here..." > + +
+ + +