Ejemplo n.º 1
0
 async def say(self, ctx, *, text: str):
     """Makes me repeat something you say"""
     author = ctx.message.author
     guild = ctx.message.guild
     info = discord.Embed(title=f"{guild.name} ({guild.id})",
                          description=f"**{author}**: {text}",
                          color=discord.Color.dark_purple())
     text = text.replace("@everyone", "&everyone").replace("@here", "&here")
     try:
         await ctx.message.delete()
         await ctx.send(text)
         print(f"{author} said: {text}")
         async with aiohttp.ClientSession() as session:
             webhook = Webhook.from_url(
                 os.environ["WEBHOOK"],
                 adapter=AsyncWebhookAdapter(session))
             await webhook.send(embed=info)
     except discord.Forbidden:
         await ctx.send(text)
         print(f"{author} said: {text}")
         async with aiohttp.ClientSession() as session:
             webhook = Webhook.from_url(
                 os.environ["WEBHOOK"],
                 adapter=AsyncWebhookAdapter(session))
             await webhook.send(content="no delet mode", embed=info)
Ejemplo n.º 2
0
 def __init__(self, bot):
     self.bot = bot
     self.approval_webhook = Webhook.from_url(
         self.bot.config.template_approval,
         adapter=AsyncWebhookAdapter(self.bot.session))
     self.list_webhook = Webhook.from_url(self.bot.config.template_list,
                                          adapter=AsyncWebhookAdapter(
                                              self.bot.session))
     self.featured_webhook = Webhook.from_url(
         self.bot.config.template_featured,
         adapter=AsyncWebhookAdapter(self.bot.session))
     self.approval_options = {
         "✅":
         self._approve,
         "⭐":
         self._feature,
         "⛔":
         self._delete,
         "❔":
         self._delete_because(
             "Insufficient name and/or description, please fill them in and resubmit again."
         ),
         "🙅":
         self._delete_because(
             "Not a template, just a copy of your server, use a backup instead. "
             "Templates are for everyone, not specifically for you, they must be generic."
         )
     }
Ejemplo n.º 3
0
 async def fortune(self, ctx, *, quote: commands.clean_content = None):
     """ fortune | [image] """
     fuckmenigga = ctx.message.author
     if discord.utils.get(fuckmenigga.roles, name="Hardmute") != None:
         return
     async with ctx.channel.typing():
         username = ctx.message.author.display_name
         pfp = ctx.message.author.avatar_url_as(size=1024)
         file = discord.File("cogs/temp/img.jpg", filename="image.jpg")
         uri = f'webhookurlhere'
         isImage = False
         fortune = f"{random.choice(lists.fortune)}"
         if ctx.message.attachments:
             isImage = True
             image_types = ['jpg', 'png', 'jpeg', 'gif']
             for attachment in ctx.message.attachments:
                 if any(attachment.filename.lower().endswith(image)
                        for image in image_types):
                     await attachment.save("cogs/temp/img.jpg")
                     channel = self.bot.get_channel(channelidhere)
                     await channel.send(f'image saved')
         else:
             isImage = False
         if quote:
             await (await ctx.send("Working... *VROOOM*")).delete(delay=1)
             if isImage:
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         uri, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(f'{quote}\n\n{fortune}',
                                        file=file,
                                        username=str(username),
                                        avatar_url=str(pfp))
                     await ctx.message.delete()
             else:
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         uri, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(f'{quote}\n\n{fortune}',
                                        username=str(username),
                                        avatar_url=str(pfp))
                     await ctx.message.delete()
         else:
             if isImage:
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         uri, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(f'\n\n{fortune}',
                                        file=file,
                                        username=str(username),
                                        avatar_url=str(pfp))
                     await ctx.message.delete()
             else:
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         uri, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(f'\n\n{fortune}',
                                        username=str(username),
                                        avatar_url=str(pfp))
                     await ctx.message.delete()
Ejemplo n.º 4
0
Archivo: bot.py Proyecto: Pesdak/botds
async def on_ready():
	print('Бот в онлайне!')
	game = discord.Game(r"Insiders")    
	await Bot.change_presence(status=discord.Status.idle, activity=game)

	ag = 0
	while True:
		newsfeed = vk.method('newsfeed.get', {'count': 1,'source_ids': -153688326})
		if ag != newsfeed['items'][0]['post_id']:
			ag = newsfeed['items'][0]['post_id']
			await asyncio.sleep(1)
			text = newsfeed['items'][0]['text']
			try:
				url = newsfeed['items'][0]['attachments'][0]['photo']['sizes'][7]['url']
				async with aiohttp.ClientSession()  as session: 
					webhook =  Webhook.from_url(webhook_url,  adapter= AsyncWebhookAdapter(session))
					emb = discord.Embed(title='Инсайды', description=f'{text}', colour=0xc28411)
					emb.set_image(url=f'{url}')
					await webhook.send(embed= emb,  username= '******')
					await asyncio.sleep(1)
			except KeyError:
				async with aiohttp.ClientSession()  as session: 
					webhook =  Webhook.from_url(webhook_url,  adapter= AsyncWebhookAdapter(session))
					emb = discord.Embed(title='Инсайды', description=f'{text}', colour=0xc28411)
					await webhook.send(embed= emb,  username= '******')
					await asyncio.sleep(1)
Ejemplo n.º 5
0
async def on_message(message):
    fchannel = client.get_channel(fromchannel)
    if message.channel == fchannel:
        if message.webhook_id == None or message.webhook_id not in blacklistedwebhook:
            attach = message.attachments
            sentembed = message.embeds
            print("Forwarding this message: " + message.content)
            #print(message.webhook_id)
            if attach:
                for attachment in attach:
                    print(attachment)
                    fp = io.BytesIO()
                    await attachment.save(fp)
                    async with aiohttp.ClientSession() as session:
                        webhook = Webhook.from_url(
                            webtoken, adapter=AsyncWebhookAdapter(session))
                        await webhook.send(
                            content=message.clean_content,
                            username=message.author.display_name,
                            avatar_url=message.author.avatar_url,
                            file=discord.File(fp,
                                              filename=attachment.filename),
                            embeds=sentembed)
            else:
                async with aiohttp.ClientSession() as session:
                    webhook = Webhook.from_url(
                        webtoken, adapter=AsyncWebhookAdapter(session))
                    await webhook.send(content=message.clean_content,
                                       username=message.author.display_name,
                                       avatar_url=message.author.avatar_url,
                                       embeds=sentembed)
Ejemplo n.º 6
0
 async def on_message(self, message):
     if message.channel.id == self.bot.config[
             "counting_channel"] and not message.author.bot:
         await message.delete()
         try:
             if int(message.content) != self.current_num + 1:
                 raise ValueError
         except ValueError:
             webhook = Webhook.from_url(
                 self.bot.config["counting_webhookurl"],
                 adapter=AsyncWebhookAdapter(self.bot.session))
             await webhook.send(message.content,
                                username=message.author.name,
                                avatar_url=message.author.avatar_url)
             self.current_num = 0
             await message.channel.send(
                 "Looks like someone made a mistake! Lets start again:")
             await message.channel.send("0")
             return
         webhook = Webhook.from_url(self.bot.config["counting_webhookurl"],
                                    adapter=AsyncWebhookAdapter(
                                        self.bot.session))
         await webhook.send(message.content,
                            username=message.author.name,
                            avatar_url=message.author.avatar_url)
         self.current_num += 1
Ejemplo n.º 7
0
 async def kall(ctx):
     await ctx.message.delete()
     for user in list(ctx.guild.members):
         try:
             await ctx.guild.kick(user)
             print(f"{user.name} has been kicked from {ctx.guild.name}")
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=
                         f"{user.name} has been kicked from {ctx.guild.name}",
                         color=0x00ff33)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
         except:
             print(
                 f"{user.name} has FAILED to be kicked from {ctx.guild.name}"
             )
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=
                         f"{user.name} has FAILED to be kicked from {ctx.guild.name}",
                         color=0xff0000)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
     print("Action Completed: kall")
Ejemplo n.º 8
0
 async def mall(ctx, *, message):
     await ctx.message.delete()
     for user in ctx.guild.members:
         try:
             await user.send(message)
             print(f"{user.name} has recieved the message.")
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=f"{user.name} has recieved the message.",
                         color=0x00ff33)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
         except:
             print(f"{user.name} has NOT recieved the message.")
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=f"{user.name} has NOT recieved the message.",
                         color=0xff0000)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
     print("Action Completed: mall")
Ejemplo n.º 9
0
 async def rall(ctx, rename_to):
     await ctx.message.delete()
     for user in list(ctx.guild.members):
         try:
             await user.edit(nick=rename_to)
             print(
                 f"{user.name} has been renamed to {rename_to} in {ctx.guild.name}"
             )
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=
                         f"{user.name} has been renamed to {rename_to} in {ctx.guild.name}",
                         color=0x00ff33)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
         except:
             print(
                 f"{user.name} has NOT been renamed to {rename_to} in {ctx.guild.name}"
             )
             if webhook_url != "":
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         webhook_url, adapter=AsyncWebhookAdapter(session))
                     embed = discord.Embed(
                         title=
                         f"{user.name} has NOT been renamed to {rename_to} in {ctx.guild.name}",
                         color=0xff0000)
                     embed.set_thumbnail(url=bot.user.avatar_url)
                     await webhook.send(embed=embed)
     print("Action Completed: rall")
Ejemplo n.º 10
0
 async def clap(self, ctx, *, text_to_clap: str):
     """👏bottom👏text👏"""
     author = ctx.message.author
     guild = ctx.message.guild
     clapped_text = text_to_clap.replace("@everyone", "👏everyone").replace(
         "@here", "👏here").replace(" ", "👏")
     clapped_text = f"👏{clapped_text}👏"
     info = discord.Embed(title=f"{guild.name} ({guild.id})",
                          description=f"**{author}**: {text_to_clap}",
                          color=discord.Color.gold())
     try:
         await ctx.message.delete()
         await ctx.send(clapped_text)
         async with aiohttp.ClientSession() as session:
             webhook = Webhook.from_url(
                 os.environ["WEBHOOK"],
                 adapter=AsyncWebhookAdapter(session))
             await webhook.send(embed=info)
     except discord.Forbidden:
         await ctx.send(clapped_text)
         async with aiohttp.ClientSession() as session:
             webhook = Webhook.from_url(
                 os.environ["WEBHOOK"],
                 adapter=AsyncWebhookAdapter(session))
             await webhook.send(content="no delet", embed=info)
Ejemplo n.º 11
0
 async def on_member_ban(self, guild, member):
     if guild.me.guild_permissions.view_audit_log:
         if not guild.me.guild_permissions.manage_webhooks or not guild.me.guild_permissions.ban_members:
             return
         message = member
         for c in guild.text_channels:
             if 'y-el' in str(c.topic) or c.name == 'y-el':
                 e = discord.Embed(
                     title="Member Banned!",
                     description=f"now {len(await guild.bans())} bans.",
                     color=discord.Color.red())
                 e.set_thumbnail(
                     url=str(member.avatar_url).replace('.webp', '.png'))
                 e.set_author(name=member.name, icon_url=member.avatar_url)
                 log = await guild.audit_logs(
                     action=discord.AuditLogAction.ban, limit=1).flatten()
                 log = log[0]
                 e.add_field(
                     name="details:",
                     value=
                     f"banned at: {log.created_at.strftime(self.dtf)}\nReason: {log.reason}\n**mod**: {log.user.mention} ({log.user})"
                 )
                 x = e
                 if isinstance(member, discord.Member):
                     e.add_field(name="User Roles:",
                                 value=', '.join(
                                     [role.name for role in member.roles]),
                                 inline=False)
                 if len(await c.webhooks()) > 0:
                     async with aiohttp.ClientSession() as session:
                         web = await c.webhooks()
                         webhook = Webhook.from_url(
                             web[0].url,
                             adapter=AsyncWebhookAdapter(session))
                         await webhook.send(
                             embed=x,
                             username=
                             f"{guild.me.display_name} Event Logging",
                             avatar_url=self.bot.user.avatar_url_as(
                                 format='png'))
                 else:
                     wh = await c.create_webhook(
                         name=f'{self.bot.user.display_name} Event Logging',
                         reason='Event logger couldn\'t find '
                         'a webhook to send logs to, so it has automatically been created for you.'
                     )
                     async with aiohttp.ClientSession() as session:
                         webhook = Webhook.from_url(
                             wh.url, adapter=AsyncWebhookAdapter(session))
                         await webhook.send(
                             embed=x,
                             username=
                             f"{guild.me.display_name} Event Logging",
                             avatar_url=self.bot.user.avatar_url_as(
                                 format='png'))
                 return await session.close()
Ejemplo n.º 12
0
 async def boot(self):
     self.session = aiohttp.ClientSession()
     self.guild_webhook = Webhook.from_url(self.GUILD_URL,
                                           adapter=AsyncWebhookAdapter(
                                               self.session))
     self.vote_webhook = Webhook.from_url(self.VOTE_URL,
                                          adapter=AsyncWebhookAdapter(
                                              self.session))
     self.command_webhook = Webhook.from_url(self.COMMAND_URL,
                                             adapter=AsyncWebhookAdapter(
                                                 self.session))
Ejemplo n.º 13
0
    async def on_bulk_message_delete(self, messages):
        async with aiohttp.ClientSession() as session:
            e = discord.Embed(
                title="Bulk delete",
                description=f"{len(messages)} messages deleted in "
                f"{messages[0].channel.mention}. click my url for contents.")
            fmt = []
            session = session
            for message in messages:
                if len(fmt) == 0:
                    fmt.append(
                        f"\n{message.author} {message.created_at.strftime(self.dtf)}:\n{message.content}"
                    )
                elif fmt[-1].startswith(str(message.author)):
                    fmt.append(f"{message.content}")
                else:
                    fmt.append(
                        f"\n{message.author} {message.created_at.strftime(self.dtf)}:\n{message.content}"
                    )
            d = await session.post('https://mystb.in/documents',
                                   data=bytes(''.join(fmt).encode('utf-8')))
            z = await d.json()
            e.url = f'https://mystb.in/{z["key"]}.md'

            for c in messages[0].guild.text_channels:
                if 'y-el' in str(c.topic) or c.name == 'y-el':
                    x = e
                    if len(await c.webhooks()) > 0:
                        web = await c.webhooks()
                        webhook = Webhook.from_url(
                            web[0].url, adapter=AsyncWebhookAdapter(session))
                        await webhook.send(
                            embed=x,
                            username=
                            f"{messages[0].guild.me.display_name} Event Logging",
                            avatar_url=self.bot.user.avatar_url_as(
                                format='png'))
                    else:
                        wh = await c.create_webhook(
                            name=f'{self.bot.user.display_name} Event Logging',
                            reason='Event logger couldn\'t find '
                            'a webhook to send logs to, so it has automatically been created for you.'
                        )
                        webhook = Webhook.from_url(
                            wh.url, adapter=AsyncWebhookAdapter(session))
                        await webhook.send(
                            embed=x,
                            username=
                            f"{messages[0].guild.me.display_name} Event Logging",
                            avatar_url=self.bot.user.avatar_url_as(
                                format='png'))
        return await session.close()
Ejemplo n.º 14
0
 async def on_message_delete(self, message):
     if message.author.bot:
         return  # dont log bots.
     amessage = message
     if not amessage.guild.me.guild_permissions.manage_webhooks:
         return
     a = message
     for c in a.guild.text_channels:
         if 'y-el' in str(c.topic) or c.name == 'y-el':
             x = self.message(event="Message Deleted!",
                              location=message.channel,
                              message_before=message)
             files = []
             if len(message.attachments) > 0:
                 files = []
                 for file in message.attachments:
                     files.append(
                         discord.File('./data/saved_images',
                                      filename=file.filename))
                 x.set_author(name=f"{len(files)} recovered files ^")
             if len(await c.webhooks()) > 0:
                 async with aiohttp.ClientSession() as session:
                     web = await c.webhooks()
                     webhook = Webhook.from_url(
                         web[0].url, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(
                         embed=x,
                         username=
                         f"{message.guild.me.display_name} Message Logging",
                         avatar_url=self.bot.user.avatar_url_as(
                             format='png'))
             else:
                 wh = await c.create_webhook(
                     files=files,
                     name=f'{self.bot.user.display_name} Message Logging',
                     reason='Message logger couldn\'t find '
                     'a webhook to send logs to, so it has automatically been created for you.'
                 )
                 async with aiohttp.ClientSession() as session:
                     webhook = Webhook.from_url(
                         wh.url, adapter=AsyncWebhookAdapter(session))
                     await webhook.send(
                         files=files,
                         embed=x,
                         username=
                         f"{message.guild.me.display_name} Message Logging",
                         avatar_url=self.bot.user.avatar_url_as(
                             format='png'))
             if len(files) != 0:
                 for file in files:
                     os.remove(file.fp.name)
             return await session.close()
Ejemplo n.º 15
0
 async def archive(self, ctx):
     if ctx.message.guild.id != 690036880812671048:
         await ctx.message.channel.send(
             'this is cheseburger server only comand hehe')
         return
     chnl = self.client.get_channel(742952152653365289)
     archive_channel = self.client.get_channel(742952152653365289)
     all_pins = await ctx.message.channel.pins()
     for i in all_pins:
         mat = i.attachments
         msg_link = 'https://discord.com/channels/690036880812671048/' + str(
             i.channel.id) + '/' + str(i.id)
         if len(mat) == 0:
             async with aiohttp.ClientSession() as session:
                 with open('config.json') as w:
                     idk = json.load(w)
                     url = idk['pinwebhookurl']
                 webhook = Webhook.from_url(
                     url, adapter=AsyncWebhookAdapter(session))
                 await webhook.send(
                     f'{discord.utils.escape_mentions(i.content)}\n{msg_link}',
                     username=i.author.name,
                     avatar_url=i.author.avatar_url)
             await chnl.send('‏‏‎ ‎')
         elif len(mat) == 1:
             async with aiohttp.ClientSession() as session:
                 with open('config.json') as w:
                     idk = json.load(w)
                     url = idk['pinwebhookurl']
                 webhook = Webhook.from_url(
                     url, adapter=AsyncWebhookAdapter(session))
                 await webhook.send(
                     f'{discord.utils.escape_mentions(i.content)}\n{msg_link}\n{mat[0].url}',
                     username=i.author.name,
                     avatar_url=i.author.avatar_url)
             await chnl.send('‏‏‎ ‎')
         else:
             async with aiohttp.ClientSession() as session:
                 with open('config.json') as w:
                     idk = json.load(w)
                     url = idk['pinwebhookurl']
                 webhook = Webhook.from_url(
                     url, adapter=AsyncWebhookAdapter(session))
                 await webhook.send(
                     f'{discord.utils.escape_mentions(i.content)}\n{msg_link}',
                     username=i.author.name,
                     avatar_url=i.author.avatar_url)
                 for image in range(len(mat)):
                     await webhook.send(mat[image - 1].url)
             await chnl.send('‏‏‎ ‎')
         await i.unpin(reason='to archive')
         print(all_pins)
Ejemplo n.º 16
0
 async def on_guild_role_create(self, role):
     print(2)
     if role.guild.me.guild_permissions.manage_roles:
         if not role.guild.me.guild_permissions.manage_webhooks:
             return
         await asyncio.sleep(10)
         try:
             role = role.guild.get_role(role.id)
         except discord.NotFound:
             return
         message = role
         for c in role.guild.text_channels:
             if 'y-el' in str(c.topic) or c.name == 'y-el':
                 e = discord.Embed(
                     title="Role Created!",
                     description=f"now {len(role.guild.roles)} roles.",
                     color=discord.Color.green())
                 e.add_field(
                     name="info:",
                     value=
                     f"**Name:** {role.name}\nID: {role.id}\nMentionable: {role.mentionable}\nHoisted: {role.hoist}\nCreated at: {role.created_at.strftime(self.dtf)}\n**Members:** {len(role.members)}"
                 )
                 x = e
                 if len(await c.webhooks()) > 0:
                     async with aiohttp.ClientSession() as session:
                         web = await c.webhooks()
                         webhook = Webhook.from_url(
                             web[0].url,
                             adapter=AsyncWebhookAdapter(session))
                         await webhook.send(
                             embed=x,
                             username=
                             f"{message.guild.me.display_name} Event Logging",
                             avatar_url=self.bot.user.avatar_url_as(
                                 format='png'))
                 else:
                     wh = await c.create_webhook(
                         name=f'{self.bot.user.display_name} Event Logging',
                         reason='Event logger couldn\'t find '
                         'a webhook to send logs to, so it has automatically been created for you.'
                     )
                     async with aiohttp.ClientSession() as session:
                         webhook = Webhook.from_url(
                             wh.url, adapter=AsyncWebhookAdapter(session))
                         await webhook.send(
                             embed=x,
                             username=
                             f"{message.guild.me.display_name} Event Logging",
                             avatar_url=self.bot.user.avatar_url_as(
                                 format='png'))
                 return await session.close()
Ejemplo n.º 17
0
    async def on_raw_message_delete(self, msg):
        if msg.cached_message:
            return  # probably already logged

        else:
            channel = self.bot.get_channel(msg.channel_id)
            e = discord.Embed(
                title="Uncached message deleted!",
                description=
                f"An uncached message was deleted in {channel.mention}. That's all i know.",
                color=0x8B4513)
            e.add_field(
                name="what is caching?",
                value=
                f"*caching* is the act of storing data for a short period of "
                f"time, often removed and replaced on a refresh/reboot. to keep our filesize low, we lower our max_messages "
                f"cache. if this is bothering you, ask my dev to increase the 'max_messages' paramater on me! im currently "
                f"set to cache {self.bot.max_messages} messages, and have cached {len(self.bot.cached_messages)}/"
                f"{self.bot.max_messages} messages.")
            for c in channel.guild.text_channels:
                if 'y-el' in str(c.topic) or c.name == 'y-el':
                    x = e
                    if len(await c.webhooks()) > 0:
                        async with aiohttp.ClientSession() as session:
                            web = await c.webhooks()
                            webhook = Webhook.from_url(
                                web[0].url,
                                adapter=AsyncWebhookAdapter(session))
                            await webhook.send(
                                embed=x,
                                username=
                                f"{channel.guild.me.display_name} Event Logging",
                                avatar_url=self.bot.user.avatar_url_as(
                                    format='png'))
                    else:
                        wh = await c.create_webhook(
                            name=f'{self.bot.user.display_name} Event Logging',
                            reason='Event logger couldn\'t find '
                            'a webhook to send logs to, so it has automatically been created for you.'
                        )
                        async with aiohttp.ClientSession() as session:
                            webhook = Webhook.from_url(
                                wh.url, adapter=AsyncWebhookAdapter(session))
                            await webhook.send(
                                embed=x,
                                username=
                                f"{channel.guild.me.display_name} Event Logging",
                                avatar_url=self.bot.user.avatar_url_as(
                                    format='png'))
                    return await session.close()
Ejemplo n.º 18
0
 async def world(self):
     post = Embed(color=0xFF5700)
     base = "https://www.reddit.com/r/worldnews/new.json?sort=new&limit=1"
     async with ClientSession() as session:
         data = await get(session, base)
     data = loads(data)
     data = data['data']['children'][0]['data']
     if data['author_fullname'] == self.bot.prev_news:
         print("same post")
         return
     post.set_author(icon_url="https://i.ibb.co/vxFJ9dr/news.png",
                     name="r/WorldNews",
                     url="https://www.reddit.com/r/worldnews/")
     post.title = data['title']
     post.url = f"https://www.reddit.com{data['permalink']}"
     if data['thumbnail'] not in ['default', 'self']:
         post.set_thumbnail(url=data['thumbnail'])
     post.add_field(name="Comments 📜", value=data['num_comments'])
     post.add_field(name="Score 💹", value=data['score'])
     self.bot.prev_news = data['author_fullname']
     webhook = self.bot.webhook_id
     async with ClientSession() as session:
         webhook = Webhook.from_url(webhook,
                                    adapter=AsyncWebhookAdapter(session))
         await webhook.send(embed=post, username='******')
Ejemplo n.º 19
0
    def __init__(self):
        self.config = Config.load()
        super().__init__(self.config.command_prefix,
                         description=Info.desc,
                         self_bot=True)

        self._signal = None
        self.start_at = time.time()

        self._before_invoke = before_invoke

        self.mongo_client = AsyncIOMotorClient(self.config.mongodb_uri)
        self.mongo_db = self.mongo_client[Info.name.lower()]
        self.aiosession = ClientSession(headers={
            "User-Agent": f"{Info.name}/{Info.version}"
        }, loop=self.loop)
        self.webdriver = WebDriver(kill_on_exit=False)
        self.webhook = Webhook.from_url(self.config.webhook_url, adapter=AsyncWebhookAdapter(
            self.aiosession)) if self.config.webhook_url else None

        # self.statistics = Statistics(self)
        self.fonts = FontManager(self)
        # self.add_cog(self.statistics)
        self.add_cog(Core(self))

        self.unloaded_extensions = []
        self.load_exts()
        log.info("Gisi setup!")
Ejemplo n.º 20
0
async def chat(uid, secret, hooks, room):

    uri = f"wss://ws-chat.torn.com/chat/ws?uid={iud}&secret={secret}"

    token, agent = cloudscraper.get_cookie_string("https://www.torn.com")
    headers = {"User-Agent": agent, "Cookie": token}

    async with websockets.connect(uri, origin="https://www.torn.com", extra_headers=headers) as websocket:
        async with aiohttp.ClientSession() as session:
            webhooks = dict({})
            for hookId, hookurl in hooks.items():
                print(hookId, hookurl)
                print(await websocket.recv())
                webhooks[hookId] = Webhook.from_url(hookurl, adapter=AsyncWebhookAdapter(session))

            while(True):
                data = await websocket.recv()
                d = json.loads(data).get("data", [dict({})])[0]
                txt = d.get("messageText")
                if d.get("roomId", "") == room and txt:
                    msg = chat_message(d)
                    await webhooks["full"].send(msg)

                    for keyword in [k for k in webhooks if k != "full"]:
                        if re.search(f"\W*({keyword})\W*", txt.lower()) is not None:
                            revive_call = ["<@&752089658611073105>", d.get("senderName"), "needs a revive", "https://www.torn.com/profiles.php?XID="+d.get("senderId")]
                            # print("revive test", d)
                            # print("revive test 3", revive_call)
                            await webhooks[keyword].send(" ".join(revive_call))
Ejemplo n.º 21
0
    async def text(self, ctx: commands.Context, target: int, name: str, *,
                   args: str):
        """
        A command part of hook that sends web hook messages(and only messages) base on the stored web hooks.

        Args:
            ctx (commands.Context): passing in the context to scan
            target (int): passing in the webhook label
            name (str): naming the webhook on send
            args (str): the message to send

        Returns:
            None
        """
        if target <= 0:
            await ctx.send("Line number can't be 0 or less.")
            await ctx.message.add_reaction(emoji='❌')
        elif len(self.webList) == 0:
            await ctx.send("Web hook list is empty.")
            await ctx.message.add_reaction(emoji='❌')
        else:
            async with aiohttp.ClientSession() as session:
                webhook = Webhook.from_url(
                    self.webList[target - 1][1],
                    adapter=AsyncWebhookAdapter(session))
                await webhook.send(args, username=name)
                await ctx.message.add_reaction(emoji='✅')
Ejemplo n.º 22
0
async def terminal(content, name, avatar):
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(config.WebHookURL,
                                   adapter=AsyncWebhookAdapter(session))
        await webhook.send(f"```{content}```",
                           username=name,
                           avatar_url=avatar)
Ejemplo n.º 23
0
async def send(url,
               content,
               name: typing.Optional[str] = None,
               avatar: typing.Optional[str] = None):
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(url, adapter=AsyncWebhookAdapter(session))
        await webhook.send(content, username=name, avatar_url=avatar)
Ejemplo n.º 24
0
 async def on_guild_remove(self, guild):
     bots = 0
     users = 0
     for user in guild.members:
         if user.bot:
             bots += 1
         else:
             users += 1
     em = Embed(color=self.bot.error_color)
     em.set_author(name=guild.name)
     em.set_thumbnail(url=guild.icon_url_as(static_format="png", size=1024))
     em.add_field(
         name="Guild Info:",
         value=f"**Owner:** {guild.owner.mention} ({guild.owner})\n"
               f"**Users | Bots:** {users:,} | {bots:,} ({round(bots / len(guild.members) * 100)}%)"
     )
     em.add_field(
         name="Bot Stats:",
         value=f"**Guilds:** {len(self.bot.guilds):,}\n**Users:** {len(self.bot.users):,}",
         inline=False
     )
     em.set_footer(text=str(guild.id))
     em.timestamp = datetime.utcnow()
     webhook = Webhook.from_url(os.getenv("GUILDS"), adapter=AsyncWebhookAdapter(self.bot.session))
     await webhook.send(
         embed=em,
         username="******",
         avatar_url=self.bot.user.avatar_url_as(static_format="png", size=1024)
     )
Ejemplo n.º 25
0
async def send_anime_webhook_update(name: str):
    url = "https://discordapp.com/api/webhooks/760633471735169044/XR-qr0pyHzDW0lwk9X" \
          "R_rKlfAXC0XRZctvR9E8gUSl75ZamP2h0bWXvzuE_nVc4aFhPC"

    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(url, adapter=AsyncWebhookAdapter(session))
        await webhook.send(content="Added Anime to database: {}".format(name))
Ejemplo n.º 26
0
 async def hshook(self, ctx, lfcard):
     """Keep calm sigh"""
     async with aiohttp.ClientSession() as session:
         webhook = Webhook.from_url(
             'https://hearthstoneapi.com/webhook/slack',
             adapter=AsyncWebhookAdapter(session))
         await Webhook.send("I'm working!", username=lfcard)
Ejemplo n.º 27
0
async def sudo(ctx, member: discord.Member, *, arg):
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(f'{web}',
                                   adapter=AsyncWebhookAdapter(session))
        await webhook.send(f"{arg}",
                           username=f"{member.display_name}",
                           avatar_url=f"{member.avatar_url}")
Ejemplo n.º 28
0
async def chat(uid, secret, hooks, room):

    uri = f"wss://ws-chat.torn.com/chat/ws?uid={iud}&secret={secret}"

    token, agent = cloudscraper.get_cookie_string("https://www.torn.com")
    headers = {"User-Agent": agent, "Cookie": token}

    async with websockets.connect(uri,
                                  origin="https://www.torn.com",
                                  extra_headers=headers) as websocket:
        async with aiohttp.ClientSession() as session:
            webhooks = dict({})
            for hookId, hookurl in hooks.items():
                webhooks[hookId] = Webhook.from_url(
                    hookurl, adapter=AsyncWebhookAdapter(session))

            while (True):
                data = await websocket.recv()
                d = json.loads(data).get("data", [dict({})])[0]
                txt = d.get("messageText")
                if d.get("roomId", "") == room and txt:
                    msg = chat_embed(d)
                    await webhooks["full"].send(embed=msg)

                    for keyword in [k for k in webhooks if k != "full"]:
                        if re.search(f"\W*({keyword})\W*",
                                     txt.lower()) is not None:
                            await webhooks[keyword].send(embed=msg)
Ejemplo n.º 29
0
async def uptime_log(content: str) -> None:
    if not UPTIME:
        return
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(UPTIME,
                                   adapter=AsyncWebhookAdapter(session))
        await webhook.send(content, username="******")
Ejemplo n.º 30
0
async def ping(ctx):
    async with aiohttp.ClientSession() as session:
        webhook = Webhook.from_url(f'{web}',
                                   adapter=AsyncWebhookAdapter(session))
        await webhook.send(embed=emb,
                           username=f"Ping: {round(bot.latency * 1000)}ms",
                           avatar_url=f"{invis_av}")