Example #1
0
    def post_message(self,
                     message,
                     avatar=None,
                     author=None,
                     image=None,
                     url=None):
        '''Отправляет сообщение в Discord'''
        # print("message: %s, avatar: %s, author: %s, image: %s, url: %s"%(message,avatar,author,image,url))

        webhook = DiscordWebhook(self.cf.discord_webhook)
        embed = DiscordEmbed()
        embed.title = message
        embed.set_image(url=image)
        embed.set_url(url)
        embed.color = 242424
        embed.set_author(name=author, url=None, icon_url=avatar)
        embed.set_footer(text='Отправлено:')
        embed.set_timestamp()
        webhook.add_embed(embed)

        webhook.execute()
Example #2
0
 def test_discordwebhook_constructor(self):
     webhook = DiscordWebhook("testurl")
     self.assertEqual(webhook.url, "testurl")
Example #3
0
 def test_set_content(self):
     test_content = "Test data"
     webhook = DiscordWebhook("testurl")
     webhook.set_content(test_content)
     self.assertEqual(webhook.content, test_content)