async def on_message(self, message): """Detects and carries out any commands then sends a cube image or text.""" txt = None await lock.acquire() if message.content.startswith(HANDS_OP): txt = hands( message.channel.id, message.content[len(HANDS_OP + " "):], self.database_connection, ) elif message.content.startswith(JUMBLE_OP): jumble(message.channel.id, self.database_connection) elif message.content.startswith(SOLVE_OP): solve(message.channel.id, self.database_connection) elif message.content.startswith(CUSTOM_OP): txt = custom( message.channel.id, message.content[len(CUSTOM_OP + " "):], self.database_connection, ) elif message.content.startswith(TEXT_OP): txt = text(message.channel.id, self.database_connection) elif message.content.startswith(HELP_OP): txt = HELP_TEXT else: lock.release() return if txt == None: await message.channel.send( file=discord.File(GRAFFITIED_IMAGE, "cube.png")) else: await message.channel.send(txt) lock.release()
def test_custom_right_rotate_90_clockwise_cube(self): reset_test_cube() self.assertIsNone( custom( TEST_CHANNEL_ID, "rrrrrrrrryygyygyygggwggwggwwwbwwbwwboooooooooybbybbybb", ) )
def test_custom_solved_cube(self): reset_test_cube() self.assertIsNone( custom( TEST_CHANNEL_ID, "rrrrrrrrryyyyyyyyygggggggggwwwwwwwwwooooooooobbbbbbbbb", ) )
def test_custom_bad_colours(self): reset_test_cube() self.assertIsNotNone( custom( TEST_CHANNEL_ID, "rrzrrrrrryyyyyyyyygggggggggwwwwwwwwwooooooooobbbbbbbbb", ) )
def test_custom_impossible_cube(self): reset_test_cube() self.assertIsNotNone(custom(TEST_CHANNEL_ID, "r" * 54))
def test_custom_bad_length(self): reset_test_cube() self.assertIsNotNone(custom(TEST_CHANNEL_ID, "rrrrrrrrrroooooooooogg"))
def test_custom_nothing(self): reset_test_cube() self.assertIsNotNone(custom(TEST_CHANNEL_ID, ""))