Beispiel #1
0
    async def on_vk_msg(self):
        await self.Bot.wait_until_ready()

        msg = Thread(target=on_message)
        msg.start()

        while not self.Bot.is_closed():
            for post in posts:
                print(posts)
                data = handle(post.text)
                if not data is None:
                    await self.send_vk("successfully", post)

                    msg = []
                    emojis = [
                        "<:sex1:777608679808958484>",
                        "<:sex2:777608962606366752>",
                        "<:sex3:777608978091081808>",
                        "<:sex4:777608990309220372>"
                    ]
                    embed = discord.Embed(color=discord.Colour.dark_purple(),
                                          title=data["author"],
                                          description=data['text'])
                    print(data['thumbnail'])
                    embed.set_thumbnail(url=data['thumbnail'])
                    if len(data['images']) == 1:
                        embed.set_image(url=data['images'][0])
                    else:
                        for i in data['images']:
                            msg.append(i)
                    for i in data['videos']:
                        msg.append(i)
                    channel = get(self.Bot.get_all_channels(),
                                  id=789978335052431391)
                    message = await channel.send(embed=embed)
                    for i in range(len(emojis)):
                        await message.add_reaction(emojis[i])
                    for i in msg:
                        await channel.send(i)
                    posts.remove(post)
                else:
                    await self.send_vk(
                        "Error: This post type is not supported", post)
                    posts.remove(post)

            await asyncio.sleep(1)