コード例 #1
0
ファイル: load_json.py プロジェクト: nikolomara/Tosurnament
 def test_replace_in_object(self):
     """Replace % placeholders in objects"""
     string = "I am %0. This is a %1. You are not %0."
     first_parameter = "Spartan Plume"
     second_parameter = "cat"
     expected_string = (
         "I am " + first_parameter + ". This is a " + second_parameter + ". You are not " + first_parameter + "."
     )
     obj = {"content": string}
     new_obj = load_json.replace_in_object(obj, first_parameter, second_parameter)
     self.assertEqual(new_obj["content"], expected_string)
コード例 #2
0
ファイル: module.py プロジェクト: nikolomara/Tosurnament
 async def send_message(self, channel, reply, *args):
     """Sends back a message/embed response."""
     content = None
     embed = None
     if isinstance(reply, dict):
         reply = load_json.replace_in_object(reply, self.bot.command_prefix,
                                             *args)
         if "content" in reply:
             content = reply["content"]
         if "embed" in reply:
             embed = discord.Embed.from_dict(reply["embed"])
     else:
         content = load_json.replace_in_string(reply,
                                               self.bot.command_prefix,
                                               *args)
     return await channel.send(content, embed=embed)