Exemplo n.º 1
0
    async def download_url(self, url, drive_id, channel_id):
        try:
            async with aiohttp.ClientSession() as session:
                async with session.get(url) as r:
                    check = False
                    if r.status == 200:
                        unique_id = randint(0, 1000000000000)
                        unique_id2 = randint(0, 1000)
                        unique_id3 = randint(0, 500)
                        src = url[len(url) - 4:len(url)]
                        checkerx = url.find(":large")
                        if checkerx != -1:
                            src = url[len(url) - 10:len(url) - 6]
                            url = f"{url[0:checkerx-1]}:orig"

                        src2 = url.find('?format=')
                        if src2 != -1:
                            check = True
                            src = f".{url[src2+8:src2+11]}"
                            url = f"{url[0:src2-1]}{src}:orig"
                        if src == ".jpg" or src == ".gif" or src == '.png' or check:
                            file_name = f"1_{unique_id}_{unique_id2}_{unique_id3}{src}"
                            fd = await aiofiles.open(
                                'Photos/{}'.format(file_name), mode='wb')
                            await fd.write(await r.read())
                            await fd.close()
                            c.execute(
                                "INSERT INTO archive.ArchivedChannels VALUES(%s,%s,%s,%s)",
                                (file_name, src, drive_id, channel_id))
                            DBconn.commit()
                        # quickstart.Drive.checker()
        except Exception as e:
            log.console(e)
            pass
Exemplo n.º 2
0
    async def movelinks(self, ctx):
        """Add DC LINKS to main link table."""
        c.execute("SELECT link, member FROM currency.dchdlinks")
        hd_links = fetch_all()
        count = 0
        for link in hd_links:
            url = link[0]
            member_name = link[1]
            member_id = None
            if member_name == "Gahyeon":
                member_id = 163
            elif member_name == "Siyeon":
                member_id = 159
            elif member_name == "Yoohyeon":
                member_id = 161
            elif member_name == "JIU":
                member_id = 157
            elif member_name == "SUA":
                member_id = 158
            elif member_name == "Dami":
                member_id = 162
            elif member_name == "Handong":
                member_id = 160
            else:
                pass

            try:
                c.execute("INSERT INTO groupmembers.imagelinks VALUES (%s,%s)", (url, member_id))
                DBconn.commit()
                count += 1
            except Exception as e:
                log.console(e)
                pass
        await ctx.send(f"> **Added {count} links.**")
Exemplo n.º 3
0
 async def tenor(self, ctx, keyword, limit=1):
     """Connection to tenor API // Sends Links of gifs to Database. // dashes are spaces between words"""
     # base_url = f'https://api.tenor.com/v1/search?<parameters>'
     # https://tenor.com/developer/dashboard
     try:
         url = f'https://api.tenor.com/v1/search?q={keyword}&key={keys.tenor_key}&limit={limit}'
         async with aiohttp.ClientSession() as session:
             async with session.get(url) as r:
                 if r.status == 200:
                     content = await r.content.read()
                     gifs = json.loads(content)
                     count = 0
                     for key in gifs['results']:
                         count += 1
                         # await ctx.send((key['url']))
                         url = key['url']
                         c.execute(
                             "INSERT INTO groupmembers.ScrapedLinks VALUES (%s)",
                             (url, ))
                     await ctx.send(
                         f"> **{count} link(s) for {keyword} were added to the Database.**"
                     )
                     DBconn.commit()
     except Exception as e:
         log.console(e)
Exemplo n.º 4
0
 async def latest(self, ctx):
     """Grabs the highest resolution possible from MOST RECENT DC Post [Format: %latest]"""
     c.execute("SELECT URL FROM currency.DCUrl")
     my_url = fetch_one()
     try:
         async with aiohttp.ClientSession() as session:
             async with session.get('{}'.format(my_url)) as r:
                 url_list = []
                 if r.status == 200:
                     page_html = await r.text()
                     page_soup = soup(page_html, "html.parser")
                     image_url = (page_soup.findAll("div", {"class": "imgSize width"}))
                     for image in image_url:
                         new_image_url = image.img["src"]
                         DC_Date = new_image_url[41:49]
                         unique_id = new_image_url[55:87]
                         file_format = new_image_url[93:]
                         HD_Link = f'https://file.candlemystar.com/post/{DC_Date}{unique_id}{file_format}'
                         url_list.append(HD_Link)
                     await ctx.send(f"> **Here are the Original Photos for <{my_url}>**:")
                     for link in url_list:
                         await ctx.send(f"<{link}>")
                 else:
                     await ctx.send(f"> **Error {r.status}: Unable to retrieve latest photos.**")
     except:
         await ctx.send(f"> **Unable to retrieve latest photos.** ")
Exemplo n.º 5
0
 async def leaderboard(self, ctx):
     """Shows Top 10 Users [Format: %leaderboard][Aliases: leaderboards, lb]"""
     c.execute("SELECT count(UserID) FROM currency.Currency")
     counter = fetch_one()
     embed = discord.Embed(title=f"Currency Leaderboard", color=0xffb6c1)
     embed.set_author(name="Irene", url='https://www.youtube.com/watch?v=dQw4w9WgXcQ', icon_url='https://cdn.discordapp.com/emojis/693392862611767336.gif?v=1')
     embed.set_footer(text="Type %bal (user) to view their balance.", icon_url='https://cdn.discordapp.com/emojis/683932986818822174.gif?v=1')
     if counter == 0:
         await ctx.send("> **There are no users to display.**", delete_after=60)
     if counter > 0:
         c.execute("Select UserID,Money FROM currency.Currency")
         amount = fetch_all()
         sort_money = []
         for sort in amount:
             new_user = [sort[0], int(sort[1])]
             sort_money.append(new_user)
         sort_money.sort(key=lambda x: x[1], reverse=True)
         count = 0
         for a in sort_money:
             count += 1
             UserID = a[0]
             Money = a[1]
             UserName = self.client.get_user(UserID)
             if count <= 10:
                 embed.add_field(name=f"{count}) {UserName} ({UserID})", value=await shorten_balance(str(Money)), inline=True)
         await ctx.send(embed=embed)
Exemplo n.º 6
0
 async def countleaderboard(self, ctx):
     """Shows leaderboards for how many times an idol has been called. [Format: %clb]"""
     embed = discord.Embed(title=f"Idol Leaderboard", color=0xffb6c1)
     embed.set_author(
         name="Irene",
         url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
         icon_url=
         'https://cdn.discordapp.com/emojis/693392862611767336.gif?v=1')
     embed.set_footer(
         text="Type %count (idol name) to view their individual stats.",
         icon_url=
         'https://cdn.discordapp.com/emojis/683932986818822174.gif?v=1')
     c.execute(
         "SELECT MemberID, Count FROM groupmembers.Count ORDER BY Count DESC"
     )
     all_members = fetch_all()
     count_loop = 0
     for mem in all_members:
         count_loop += 1
         if count_loop <= 10:
             MemberID = mem[0]
             count = mem[1]
             c.execute(
                 "SELECT fullname, stagename FROM groupmembers.Member WHERE ID = %s",
                 (MemberID, ))
             idol = c.fetchone()
             embed.add_field(name=f"{count_loop}) {idol[0]} ({idol[1]})",
                             value=count)
     await ctx.send(embed=embed)
Exemplo n.º 7
0
 async def removeurl(self, ctx, link):
     """Remove url from youtube videos [Format: %removeurl (link)]"""
     try:
         c.execute("DELETE FROM currency.Links WHERE Link = %s", (link, ))
         DBconn.commit()
         await ctx.send("> **That video has been deleted**")
     except:
         await ctx.send("> **That video is not being tracked.**")
Exemplo n.º 8
0
 async def logremove(self, ctx):
     """Stop logging the current text channel."""
     if await check_if_logged(channel_id=ctx.channel.id):
         c.execute("DELETE FROM logging.channels WHERE channelid = %s", (ctx.channel.id,))
         DBconn.commit()
         await ctx.send("> **This channel is no longer being logged.**")
     else:
         await ctx.send(f"> **This channel is not being logged.**")
Exemplo n.º 9
0
 async def addurl(self, ctx, link):
     """Add url to youtube videos [Format: %addurl (link)]"""
     if 'youtube.com' in link or 'youtu.be' in link:
         try:
             c.execute("INSERT INTO currency.Links VALUES(%s)", (link, ))
             DBconn.commit()
             await ctx.send("> **That video is now being traced**")
         except Exception as e:
             log.console(e)
             await ctx.send("> **That video is already being tracked.**")
Exemplo n.º 10
0
 async def on_message_log(self, message):
     if await check_logging_requirements(message):
         try:
             c.execute("SELECT sendall FROM logging.servers WHERE serverid = %s", (message.guild.id,))
             if fetch_one() == 1:
                 logging_channel = await get_log_channel_id(message, self.client)
                 files = await get_attachments(message)
                 embed_message = f"**{message.author} ({message.author.id})\nMessage: **{message.content}**\nFrom {message.guild} in {message.channel}\nCreated at {message.created_at}\n<{message.jump_url}>**"
                 embed = discord.Embed(title="Message Sent", description=embed_message, color=0xffffff)
                 await logging_channel.send(embed=embed, files=files)
         except Exception as e:
             log.console(f"ON_MESSAGE_LOG ERROR: {e} Server ID: {message.guild.id} Channel ID: {message.channel.id}")
Exemplo n.º 11
0
 async def deletephotos(self):
     c.execute("SELECT FileName from archive.ArchivedChannels")
     allfiles = fetch_all()
     file_list = []
     for file in allfiles:
         file_list.append(file[0])
     all_photos = os.listdir('Photos')
     for photo in all_photos:
         if photo != "placeholder.txt" and photo not in file_list:
             try:
                 os.unlink('Photos/{}'.format(photo))
             except Exception as e:
                 pass
Exemplo n.º 12
0
 async def amount_of_links(member_id, current_full_name,
                           current_stage_name):
     c.execute(
         "SELECT COUNT(*) FROM groupmembers.ImageLinks WHERE MemberID = %s",
         (member_id, ))
     counter = fetch_one()
     if counter == 0:
         await ctx.send(
             f"> **There are no results for {current_full_name} ({current_stage_name})**"
         )
     else:
         await ctx.send(
             f"> **There are {counter} images for {current_full_name} ({current_stage_name}).**"
         )
Exemplo n.º 13
0
 async def on_message(message):
     try:
         # fetching temporary channels that have delays for removed messages.
         c.execute("SELECT chanID, delay FROM currency.TempChannels")
         temp_channels = fetch_all()
         message_sender = message.author
         message_content = message.clean_content
         message_channel = message.channel
         # check if messages are in a temporary channel
         for temp in temp_channels:
             chan_id = temp[0]
             delay = temp[1]
             if message_channel.id == chan_id:
                 await message.delete(delay=delay)
         if check_message_not_empty(message):
             # check if the message belongs to the bot
             if message_sender.id != client.user.id:
                 if message_content[0] != '%':
                     # it had to be written somewhere :( and I'm not about to pull it from a table
                     if 'n***a' in message_content.lower(
                     ) or 'nigger' in message_content.lower(
                     ) and ':' not in message_content.lower():
                         author_id = message_sender.id
                         # checks how many instances ( should logically only be 0 or 1 )
                         c.execute(
                             "SELECT COUNT(*) FROM currency.Counter WHERE UserID = %s::bigint",
                             (author_id, ))
                         checker = fetch_one()
                         if checker > 0:
                             c.execute(
                                 "SELECT NWord FROM currency.Counter WHERE UserID = %s::bigint",
                                 (author_id, ))
                             current_count = fetch_one()
                             current_count += 1
                             c.execute(
                                 "UPDATE currency.Counter SET NWord = %s WHERE UserID = %s::bigint",
                                 (current_count, author_id))
                         if checker == 0:
                             c.execute(
                                 "INSERT INTO currency.Counter VALUES (%s,%s)",
                                 (author_id, 1))
                         DBconn.commit()
             if get_message_prefix(message) == '%':
                 log.console(
                     f"CMD LOG: ChannelID = {message_channel.id} - {message_sender} || {message_content} "
                 )
             await client.process_commands(message)
     except Exception as e:
         log.console(e)
         DBconn.rollback()
Exemplo n.º 14
0
 def checker():
     c.execute("SELECT COUNT(*) FROM archive.ArchivedChannels")
     check = fetch_one()
     if check > 0:
         c.execute(
             "SELECT id, filename, filetype, folderid FROM archive.ArchivedChannels"
         )
         posts = fetch_all()
         for post in posts:
             ID = post[0]
             FileName = post[1]
             FileType = post[2]
             FolderID = post[3]
             Drive.upload_to_drive(ID, FolderID, FileName, FileType)
Exemplo n.º 15
0
 async def logadd(self, ctx):
     """Start logging the current text channel."""
     if await check_if_logged(server_id=ctx.guild.id):
         if not await check_if_logged(channel_id=ctx.channel.id):
             c.execute("SELECT COUNT(*) FROM logging.servers WHERE channelid = %s", (ctx.channel.id,))
             if fetch_one() == 0:
                 logging_id = await get_logging_id(ctx.guild.id)
                 c.execute("INSERT INTO logging.channels (channelid, server) VALUES(%s, %s)", (ctx.channel.id, logging_id))
                 DBconn.commit()
                 await ctx.send(f"> **This channel is now being logged.**")
             else:
                 await ctx.send(f"> **This channel can not be logged since log messages are sent here.**")
         else:
             await ctx.send(f"> **This channel is already being logged.**")
     else:
         await ctx.send(f"> **The server must be logged in order to log a channel.**")
Exemplo n.º 16
0
 async def clearnword(self, ctx, user: discord.Member = "@user"):
     """Clear A User's Nword Counter [Format: %clearnword @user]"""
     if user == "@user":
         await ctx.send("> **Please @ a user**")
     if user != "@user":
         c.execute(
             "SELECT COUNT(*) FROM currency.Counter WHERE UserID = %s",
             (user.id, ))
         checker = fetch_one()
         if checker > 0:
             c.execute("DELETE FROM currency.Counter where UserID = %s",
                       (user.id, ))
             await ctx.send("**> Cleared.**")
             DBconn.commit()
         if checker == 0:
             await ctx.send(
                 f"> **<@{user.id}> has not said the N-Word a single time!**"
             )
Exemplo n.º 17
0
 def upload_to_drive(ID, folder_id, file_name, file_type):
     try:
         drive_service = Drive.get_drive_connection()
         file_metadata = {'name': file_name, 'parents': [folder_id]}
         if len(file_type) == 4:
             file_type = file_type[1:3]
             # print(file_name)
             file_location = f'Photos/{file_name}'
             media = MediaFileUpload(file_location)
             file = drive_service.files().create(body=file_metadata,
                                                 media_body=media,
                                                 fields='id').execute()
         c.execute("DELETE FROM archive.ArchivedChannels WHERE ID = %s",
                   (ID, ))
         DBconn.commit()
         # print ('File ID: %s'% file.get('id'))
         # link_addon = file.get('id')
     except Exception as e:
         log.console(e)
Exemplo n.º 18
0
    async def count(self, ctx, *, name):
        """Shows howmany times an idol has been called. [Format: %count (idol's name)]"""
        try:
            c.execute(
                "SELECT ID, FullName, StageName, Aliases FROM groupmembers.Member"
            )
            all_members = fetch_all()
            final_count = "Unknown"
            for mem in all_members:
                check = 0
                ID = mem[0]
                full_name = mem[1]
                stage_name = mem[2]
                aliases = mem[3]
                if aliases != "NULL":
                    aliases = aliases.split(',')
                    for alias in aliases:
                        if alias.lower() == name.lower():
                            check = 1
                if name.lower() == full_name.lower() or name.lower(
                ) == stage_name.lower():
                    check = 1
                if check == 1:
                    c.execute(
                        "SELECT COUNT(*) FROM groupmembers.Count WHERE MemberID = %s",
                        (ID, ))
                    counter = fetch_one()
                    if counter == 0:
                        await ctx.send(
                            f"> **{full_name} ({stage_name}) has not been called by a user yet.**"
                        )
                    else:
                        c.execute(
                            "SELECT Count FROM groupmembers.Count WHERE MemberID = %s",
                            (ID, ))
                        counter = fetch_one()
                        c.execute(
                            "SELECT MemberID FROM groupmembers.Count ORDER BY Count DESC"
                        )
                        all_counters = fetch_all()
                        count = 0
                        for rank in all_counters:
                            count += 1
                            mem_id = rank[0]
                            if mem_id == ID:
                                final_count = count

                        await ctx.send(
                            f"> **{full_name} ({stage_name}) has been called {counter} times at rank {final_count}.**"
                        )
        except Exception as e:
            log.console(e)
Exemplo n.º 19
0
 async def deletechannel(self, ctx):
     """Stop the current channel from being archived [Format: %deletechannel]"""
     try:
         c.execute(
             "SELECT COUNT(*) FROM archive.ChannelList WHERE ChannelID = %s",
             (ctx.channel.id, ))
         count = fetch_one()
         if count == 0:
             await ctx.send(
                 "> **This channel is not currently being archived.**")
         else:
             c.execute(
                 "DELETE FROM archive.ChannelList WHERE ChannelID = %s",
                 (ctx.channel.id, ))
             DBconn.commit()
             await ctx.send("> **This channel is no longer being archived**"
                            )
     except Exception as e:
         log.console(e)
         await ctx.send("> **There was an error.**")
Exemplo n.º 20
0
    async def countmember(self, ctx, *, member=""):
        """Shows how many photos of a certain member there are. [Format: %countmember <name>]"""
        async def amount_of_links(member_id, current_full_name,
                                  current_stage_name):
            c.execute(
                "SELECT COUNT(*) FROM groupmembers.ImageLinks WHERE MemberID = %s",
                (member_id, ))
            counter = fetch_one()
            if counter == 0:
                await ctx.send(
                    f"> **There are no results for {current_full_name} ({current_stage_name})**"
                )
            else:
                await ctx.send(
                    f"> **There are {counter} images for {current_full_name} ({current_stage_name}).**"
                )

        if member == "":
            await ctx.send(
                "> **Please specify a member's full name, stage name, or alias.**"
            )
        member = member.replace("_", " ")
        c.execute(
            "SELECT ID, FullName, StageName, Aliases FROM groupmembers.Member")
        all_members = fetch_all()
        for all_member in all_members:
            id = all_member[0]
            full_name = all_member[1]
            stage_name = all_member[2]
            aliases = all_member[3]
            if member.lower() == full_name.lower():
                await amount_of_links(id, full_name, stage_name)
            elif member.lower() == stage_name.lower():
                await amount_of_links(id, full_name, stage_name)
            try:
                aliases = aliases.split(",")
                for alias in aliases:
                    if member.lower() == alias.lower():
                        await amount_of_links(id, full_name, stage_name)
            except:
                pass
Exemplo n.º 21
0
 async def scrapeyoutube(self, ctx):
     """Scrape Youtube Video"""
     c.execute("SELECT link FROM currency.links")
     links = fetch_all()
     for link in links:
         c.execute("SELECT LinkID FROM currency.links WHERE Link = %s",
                   (link, ))
         id = fetch_one()
         async with aiohttp.ClientSession() as session:
             async with session.get('{}'.format(link[0])) as r:
                 if r.status == 200:
                     page_html = await r.text()
                     log.console(page_html)
                     page_soup = soup(page_html, "html.parser")
                     view_count = (page_soup.find(
                         "div", {"class": "watch-view-count"})).text
                     # c.execute("INSERT INTO currency.ViewCount VALUES (%s,%s)", (id,datetime.now()))
                     # DBconn.commit()
                     await ctx.send(
                         f"> **Managed to scrape DC SCREAM -- {view_count} -- {datetime.now()}**"
                     )
Exemplo n.º 22
0
 async def nword(self, ctx, user: discord.Member = "@user"):
     """Checks how many times a user has said the N Word [Format: %nword @user]"""
     if user == "@user":
         await ctx.send("> **Please @ a user**")
     if user != "@user":
         c.execute(
             "SELECT COUNT(*) FROM currency.Counter WHERE UserID = %s",
             (user.id, ))
         checker = fetch_one()
         if checker > 0:
             c.execute(
                 "SELECT NWord FROM currency.Counter WHERE UserID = %s",
                 (user.id, ))
             current_count = fetch_one()
             await ctx.send(
                 f"> **<@{user.id}> has said the N-Word {current_count} time(s)!**"
             )
         if checker == 0:
             await ctx.send(
                 f"> **<@{user.id}> has not said the N-Word a single time!**"
             )
Exemplo n.º 23
0
 async def endgame(self, ctx):
     """End your current game [Format: %endgame] [Aliases: eg]"""
     try:
         c.execute(
             "SELECT currency.GameID FROM Games WHERE Player1 = %s OR Player2 = %s",
             (ctx.author.id, ctx.author.id))
         game_id = fetch_one()
         c.execute(
             "DELETE FROM currency.Games WHERE Player1 = %s OR Player2 = %s",
             (ctx.author.id, ctx.author.id))
         c.execute("DELETE FROM currency.BlackJack WHERE GameID = %s",
                   (game_id, ))
         DBconn.commit()
         for task in self.tasks:
             # await ctx.send(task)
             x = task[0]
             y = task[1]
             z = task[2]
             if ctx.author.id == y or ctx.author.id == z:
                 x.stop()
                 self.tasks.remove(task)
         await ctx.send(
             "> **You have been removed from your current game.**",
             delete_after=5)
         self.count = 0
     except:
         await ctx.send("> **You are not currently in a running game.**",
                        delete_after=40)
Exemplo n.º 24
0
 async def listchannels(self, ctx):
     """List the channels in your server that are being archived. [Format: %listchannels]"""
     c.execute(
         "SELECT id, channelid, guildid, driveid, name FROM archive.ChannelList"
     )
     all_channels = fetch_all()
     guild_name = ctx.guild.name
     embed = discord.Embed(title=f"Archived {guild_name} Channels",
                           color=0x87CEEB)
     embed.set_author(
         name="Irene",
         url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
         icon_url=
         'https://cdn.discordapp.com/emojis/693392862611767336.gif?v=1')
     embed.set_footer(
         text="Thanks for using Irene.",
         icon_url=
         'https://cdn.discordapp.com/emojis/683932986818822174.gif?v=1')
     check = False
     for channel in all_channels:
         ID = channel[0]
         ChannelID = channel[1]
         list_channel = (await self.client.fetch_channel(ChannelID)).name
         GuildID = channel[2]
         DriveID = channel[3]
         Name = channel[4]
         if ctx.guild.id == GuildID:
             check = True
             embed.insert_field_at(
                 0,
                 name=list_channel,
                 value=
                 f"https://drive.google.com/drive/folders/{DriveID} | {Name}",
                 inline=False)
             pass
     if check:
         await ctx.send(embed=embed)
     else:
         await ctx.send(
             "> **There are no archived channels on this server.**")
Exemplo n.º 25
0
 async def new_task5(self):
     check = True
     try:
         c.execute("SELECT link FROM currency.links")
         links = fetch_all()
     except Exception as e:
         check = False
         pass
     if check:
         try:
             for link in links:
                 c.execute(
                     "SELECT LinkID FROM currency.links WHERE Link = %s",
                     link)
                 link_id = fetch_one()
                 async with aiohttp.ClientSession() as session:
                     async with session.get('{}'.format(link[0])) as r:
                         if r.status == 200:
                             page_html = await r.text()
                             # log.console(page_html)
                             page_soup = soup(page_html, "html.parser")
                             view_count = (page_soup.find(
                                 "div", {"class": "watch-view-count"})).text
                             now = datetime.now()
                             c.execute(
                                 "INSERT INTO currency.ViewCount VALUES (%s,%s,%s)",
                                 (link_id, view_count, now))
                             self.view_count.append(view_count)
                             self.now.append(now)
                             DBconn.commit()
             # log.console("Updated Video Views Tracker")
         except Exception as e:
             log.console(e)
     self.view_count = []
     self.now = []
Exemplo n.º 26
0
 async def addalias(self, ctx, alias, *, member):
     """Add alias to a member [Format: %addalias (alias) (member full name)]"""
     try:
         c.execute(
             "SELECT COUNT(*) FROM groupmembers.Member WHERE FullName = %s",
             (member, ))
         counter = fetch_one()
         if counter == 0:
             await ctx.send("> **That person does not exist.**")
         else:
             c.execute(
                 "SELECT Aliases FROM groupmembers.Member WHERE FullName = %s",
                 (member, ))
             current_aliases = fetch_one()
             if current_aliases == "NULL":
                 new_aliases = alias
             else:
                 new_aliases = f"{current_aliases},{alias.lower()}"
             c.execute(
                 "UPDATE groupmembers.Member SET Aliases = %s WHERE FullName = %s",
                 (new_aliases, member))
             DBconn.commit()
             await ctx.send(f"> **Added Alias: {alias} to {member}**")
     except Exception as e:
         await ctx.send(e)
         log.console(e)
Exemplo n.º 27
0
 async def download_all_task(ctx):
     self.download_all_number += 1
     number = self.download_all_number
     # if number >= latest post
     # last run on 40830
     c.execute("SELECT PostID FROM currency.DCPost")
     if number >= fetch_one():
         download_all_task.cancel()
     else:
         my_url = 'https://dreamcatcher.candlemystar.com/post/{}'.format(number)
         async with aiohttp.ClientSession() as session:
             async with session.get('{}'.format(my_url)) as r:
                 if r.status == 200:
                         page_html = await r.text()
                         page_soup = soup(page_html, "html.parser")
                         username = (page_soup.find("div", {"class": "card-name"})).text
                         if username in self.list:
                             image_url = (page_soup.findAll("div", {"class": "imgSize width"}))
                             for image in image_url:
                                 new_image_url = image.img["src"]
                                 DC_Date = new_image_url[41:49]
                                 unique_id = new_image_url[55:87]
                                 file_format = new_image_url[93:]
                                 HD_Link = f'https://file.candlemystar.com/post/{DC_Date}{unique_id}{file_format}'
                                 async with session.get(HD_Link) as resp:
                                     fd = await aiofiles.open('DCAppDownloaded/{}'.format(f"{unique_id[:8]}{file_format}"), mode='wb')
                                     await fd.write(await resp.read())
                                     await fd.close()
                                     log.console(f"Downloaded {unique_id[:8]}{file_format} on {number}")
                                     number += 1
                         else:
                             log.console("DOWNLOAD Passing Post from POST #{}".format(number))
                 elif r.status == 304:
                     log.console("> **Access Denied - {}**".format(number))
                 elif r.status == 404:
                     log.console("DOWNLOAD Error 404. {} was not Found.".format(number))
                     pass
                 else:
                     log.console("DOWNLOAD Other Error")
Exemplo n.º 28
0
 async def addcards(self, ctx):
     """Fill The CardValues Table with Cards [Format: %addcards]"""
     c.execute("DELETE FROM currency.CardValues")
     suitName = ("Hearts", "Diamonds", "Spades", "Clubs")
     rankName = ("Ace", "Two", "Three", "Four", "Five", "Six", "Seven",
                 "Eight", "Nine", "Ten", "Jack", "Queen", "King")
     cardvalues = [
         11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7,
         8, 9, 10, 10, 10, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10,
         11, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10
     ]
     cards = []
     for suit in suitName[0:4]:
         for rank in rankName[0:13]:
             cards += [("{} of {}".format(rank, suit))]
     countx = -1
     for card in cards:
         countx += 1
         c.execute("INSERT INTO currency.CardValues VALUES (%s, %s)",
                   (card, cardvalues[countx]))
     DBconn.commit()
     await ctx.send("> **All cards have been added into the table.**",
                    delete_after=40)
Exemplo n.º 29
0
 async def nwordleaderboard(self, ctx):
     """Shows leaderboards for how many times the nword has been said. [Format: %nwl]"""
     embed = discord.Embed(title=f"NWord Leaderboard", color=0xffb6c1)
     embed.set_author(
         name="Irene",
         url='https://www.youtube.com/watch?v=dQw4w9WgXcQ',
         icon_url=
         'https://cdn.discordapp.com/emojis/693392862611767336.gif?v=1')
     embed.set_footer(
         text="Type %nword (user) to view their individual stats.",
         icon_url=
         'https://cdn.discordapp.com/emojis/683932986818822174.gif?v=1')
     c.execute(
         "SELECT UserID, NWord FROM currency.Counter ORDER BY NWord DESC")
     all_members = fetch_all()
     count_loop = 0
     for mem in all_members:
         count_loop += 1
         if count_loop <= 10:
             user_name = (await self.client.fetch_user(mem[0])).name
             embed.add_field(name=f"{count_loop}) {user_name} ({mem[0]})",
                             value=mem[1])
     await ctx.send(embed=embed)
Exemplo n.º 30
0
 async def sendall(self, ctx):
     """Toggles sending all messages to log channel. If turned off, it only sends edited & deleted messages."""
     if await check_if_logged(server_id=ctx.guild.id):
         c.execute("SELECT sendall FROM logging.servers WHERE serverid = %s", (ctx.guild.id,))
         if fetch_one() == 0:
             c.execute("UPDATE logging.servers SET sendall = %s WHERE serverid = %s", (1, ctx.guild.id))
             await ctx.send(f"> **All messages will now be sent in the logging channel.**")
         else:
             c.execute("UPDATE logging.servers SET sendall = %s WHERE serverid = %s", (0, ctx.guild.id))
             await ctx.send(f"> **Only edited and deleted messages will be sent in the logging channel.**")
     else:
         await ctx.send("> **This server is not being logged.**")