fix parse and reply
This commit is contained in:
		
							
								
								
									
										10
									
								
								bot.py
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								bot.py
									
									
									
									
									
								
							| @@ -75,16 +75,18 @@ class BotClient(discord.Client): | ||||
|         match message.content.split(" "): | ||||
|             case ["%calc", *args]: | ||||
|                 reply = await self._calculate(args) | ||||
|                 await message.reply(content=reply) | ||||
|                 if reply: | ||||
|                     await message.reply(content=reply.strip()) | ||||
|             case _: | ||||
|                 _log.info(f"Unrecognised command {command}") | ||||
|  | ||||
|     async def _calculate(self, args: list[str]) -> str: | ||||
|         proc = sp.run(["node", "calc_main.js", "--"] + args) | ||||
|         proc = sp.run( | ||||
|             ["node", "calc_main.js", "--"] + args, stdout=sp.PIPE, stderr=sp.PIPE | ||||
|         ) | ||||
|         if proc.returncode != 0: | ||||
|             _log.error(f"running calculator: {proc.stderr}") | ||||
|         msg = proc.stdout or "" | ||||
|         return msg.strip() | ||||
|         return proc.stdout | ||||
|  | ||||
|     def is_replay(self, message: discord.Message) -> bool: | ||||
|         if re.match("https://replay.pokemonshowdown.com/dl-.*", message.content): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user