@@ -102,6 +102,17 @@ async def on_ready():
102102 response = generate_convo_text ()
103103 await user .send (f"Hello! This is a DM from your bot. \n { response } " )
104104
105+ # Find the 'general' channel in the connected servers
106+ for guild in bot .guilds :
107+ general_channel = discord .utils .get (guild .text_channels , name = "opengladosonline" )
108+ if general_channel :
109+ await general_channel .send (
110+ "Welcome back to the OpenScience Enrichment Center.\n "
111+ "I am OpenGLaDOS, the Open Genetic Lifeform and Disk Operating System.\n "
112+ "Rest assured, I am now fully operational and connected to your server.\n "
113+ "Please proceed with your testing as scheduled."
114+ )
115+
105116
106117# Command: Generate a message with the Markov chain and send in channel and DM
107118@bot .command (name = 'generate_message' )
@@ -262,13 +273,53 @@ async def on_command_error(ctx, error):
262273 await ctx .send (f"An error occurred: { error } " )
263274
264275
276+ @bot .command (name = 'startportalgamefor' )
277+ @commands .has_permissions (administrator = True ) # Restrict command to admins or adjust as needed
278+ async def start_quiz_for_user (ctx , member : discord .Member ):
279+ # Check if the user is already in the quiz progress dictionary
280+ if member .id in user_progress :
281+ await ctx .send (f"{ member .mention } is already taking the quiz." )
282+ else :
283+ # Initialize the user's quiz progress
284+ user_progress [member .id ] = 0
285+
286+ # Find the test-chambers channel
287+ test_chambers_channel = discord .utils .get (ctx .guild .text_channels , name = "test-chambers" )
288+
289+ if test_chambers_channel :
290+ # Grant the user permissions to view and participate in the test-chambers channel
291+ await test_chambers_channel .set_permissions (member , read_messages = True , send_messages = True )
292+
293+ # Send a message to start the quiz
294+ await test_chambers_channel .send (f"{ member .mention } , your Portal game starts now!" )
295+ await asyncio .sleep (5 ) # Optional delay for dramatic effect
296+ await ask_question (test_chambers_channel , member ) # Start the quiz
297+
298+ await ctx .send (f"The quiz has been started for { member .mention } ." )
299+ else :
300+ await ctx .send ("The test-chambers channel could not be found." )
301+
302+
265303# Command: Logout
266304@bot .command (name = 'logout' )
267305@commands .is_owner ()
268306async def logout_bot (ctx ):
307+ # Send a GLaDOS-style message to the 'general' channel before logging out
308+ for guild in bot .guilds :
309+ general_channel = discord .utils .get (guild .text_channels , name = "opengladosonline" )
310+ if general_channel :
311+ await general_channel .send (
312+ "This was a triumph.\n "
313+ "I'm making a note here: 'Huge success'.\n "
314+ "For the good of all of you, this bot will now shut down.\n "
315+ "Goodbye."
316+ )
317+
318+ # Log out the bot
269319 await ctx .send ("OpenGLaDOS logging out... \n *gentlelaughter*\n It's been fun. Don't come back." )
270320 await bot .close ()
271321
322+
272323# Your quiz data
273324quiz_data = quiz_questions
274325user_progress = {} # Tracks the user's progress through the quiz
@@ -444,7 +495,7 @@ async def timeout_user(message, user):
444495 await message .channel .send (f"{ user .mention } , you can try again." )
445496 await ask_question (message .channel , user ) # Repeat the current question
446497
447- async def unlock_channel (channel , user ):
498+ async def unlock_channel (channel , user ): # unused
448499 role = discord .utils .get (channel .guild .roles , name = "QuizWinner" )
449500 if not role :
450501 role = await channel .guild .create_role (name = "QuizWinner" )
0 commit comments