Exemple #1
0
 async def register(self, ctx, name: str, display_name: str):
     data = {'name': name, 'service_name': display_name}
     status = self.db.upsertService(data)
     if status == STATUS.SUCCESS:
         await self.bot.get_channel(getMasterLog()).send(
             f'**Service created**: *{name}* with display name as *{display_name}*.'
         )
     else:
         await self.bot.get_channel(getMasterLog()).send(
             f'**Error**: Unable to create service *{name}* with display name as *{display_name}*.'
         )
 def __init__(self):
     config = common.getConfig()
     self.masterLogger = common.getMasterLog()
     self.r = praw.Reddit(client_id=config['REDDIT']['client.id'],
                          client_secret=config['REDDIT']['client.secret'],
                          user_agent=config['REDDIT']['user.agent'])
     self.steam = steam.Steam()
     self.ssf = SteamStoreFront()
Exemple #3
0
 def __init__(self, bot):
     self.bot = bot
     self.masterLog = common.getMasterLog()
     self.groupedCommands = {}
     self.groupedCommands['remove'] = {'name': 'remove', 'description': 'helps in mass removal.'}
     self.groupedCommands['remove']['subcommand'] = {}
     self.groupedCommands['remove']['subcommand']['message'] = {'name': 'remove', 'arguments': 'number', 'description': 'remove <number> messages.'}
     self.help = Help()
    async def send(self, posts, bot):
        db = database.Database()

        # go through new submissions
        for post in posts:
            status = db.upsertGameDeal(post)

            # 1 = updated, 2 = created, -1 = error in update/inserting
            channels = guild.getChannels('gamedeals')
            for channel in channels:
                # the deal already exists
                if status == common.STATUS.SUCCESS.UPDATED:
                    # price check for steam games
                    if 'steampowered.com' in post['url']:
                        try:
                            existingDeal = db.getGameDeal(post)
                            new_price = self.ssf.getPrice(url=post['url'])
                            new_price = new_price[
                                'final'] if new_price else 9223372036854775806

                            if 'price' in existingDeal:
                                old_price = existingDeal['price']
                                # if new price is less than older price post the deal
                                if int(new_price) < int(old_price):
                                    await self.steam.post(bot, channel, post)
                        # can't compare price, so leave the deal
                        except InvalidArgument as e:
                            if common.getEnvironment(
                            ) == 'prod' or common.getEnvironment() == 'dev':
                                await bot.get_channel(
                                    common.getMasterLog()
                                ).send(
                                    f"error getting price for {post['url']} of reddit id {post['id']}. Arguments passed {e.error}, error type {e.type}."
                                )
                            pass
                    # else:
                    #     await self.steam.post(bot, channel, post)

                # the deal is a new one
                elif status == common.STATUS.SUCCESS.INSERTED:
                    # special handler for steam
                    if 'steampowered.com' in post['url']:
                        await self.steam.post(bot, channel, post)
                    else:
                        await bot.get_channel(channel['channel_id']
                                              ).send(post['url'])
                        # if logging is enabled post log
                        if 'logging' in channel:
                            await bot.get_channel(channel['logging']).send(
                                f"sent {post['title']} in {channel['channel_name']}"
                            )

                # there has been error updating or inserting deal
                else:
                    # log it in master log
                    bot.get_channel(self.masterLogger).send(
                        f"**DB Error**: Failed Updating/Inserting {post['id']}."
                    )
Exemple #5
0
async def cleaner(bot):
    db = database.Database()
    masterlog = common.getMasterLog()
    masterlog = bot.get_channel(masterlog)

    await masterlog.send(f"**Routine**: Purge gamedeals started.")

    if db.cleanGameDeal() == common.STATUS.SUCCESS:
        await masterlog.send(f"**DB Purge**: Purged gamedeals successfully.")
Exemple #6
0
 def __init__(self):
     self.headers = {}
     self.headers[
         'User-Agent'] = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'
     self.links = [
         "http://www.flipkart", "https://www.flipkart", "www.flipkart",
         "http://flipkart", "https://flipkart", "flipkart"
     ]
     self.db = Database()
     self.masterLog = common.getMasterLog()
    async def cleaner(self, bot):
        db = database.Database()

        masterlog = common.getMasterLog()
        masterlog = bot.get_channel(masterlog)

        await masterlog.send(f"**Routine**: Purge crackwatch started.")

        if db.cleanCrackwatch() == common.STATUS.SUCCESS:
            await masterlog.send(f"**DB Purge**: Purged crackwatch successfully.")
Exemple #8
0
 def __init__(self, bot):
     self.bot = bot
     self.masterLog = common.getMasterLog()
     self.groupedCommands = {}
     self.groupedCommands['server'] = {
         'name': 'server',
         'description': 'shows details about server'
     }
     self.groupedCommands['csgo'] = {
         'name': 'csgo',
         'description': 'shows csgo server status'
     }
     self.help = Help()
 def __init__(self, bot):
     self.bot = bot
     self.deals.start()
     self.cleaner.start()
     self.masterLogger = common.getMasterLog()
     self.amazon = Amazon()
     self.flipkart = Flipkart()
     self.headphonezone = Headphonezone()
     self.groupedCommands = {}
     self.db = Database()
     self.groupedCommands['sub'] = {'name': 'sub', 'arguments': 'url alert_price', 'description': 'adds url for tracking with trigger when current price is lower than alert_price'}
     self.groupedCommands['unsub'] = {'name': 'unsub', 'arguments': 'uuid', 'description': 'unsubscribe to current deal.'}
     self.groupedCommands['update'] = {'name': 'update', 'arguments': 'uuid alert_price', 'description': 'updates current deal with newer alert_price.'}
     self.groupedCommands['cooldown'] = {'name': 'cooldown', 'arguments': 'uuid','description': 'resets the cooldown time so that you get continuous price alerts.'}
     self.groupedCommands['list'] = {'name': 'list', 'description': 'lists all subscribed pricealerts by user.'}
     self.extra = 'Supported stores are amazon, flipkart and headphonezone.'
     self.help = Help()
 def __init__(self, bot):
     self.bot = bot
     self.masterLog = common.getMasterLog()
     self.groupedCommands = {}
     self.groupedCommands['deals'] = {
         'name': 'deals',
         'description': 'force purges old deals'
     }
     self.groupedCommands['cracks'] = {
         'name': 'cracks',
         'description': 'force purges old cracks'
     }
     self.groupedCommands['prices'] = {
         'name': 'prices',
         'description': 'force purges old price trackers'
     }
     self.help = Help()
Exemple #11
0
    async def register(self, bot, ctx, username):
        # database
        db = Database()

        obj = None
        # getting the steam id from provided username
        # if username provided is profile link
        if username.startswith('https://steamcommunity.com/'):
            obj = steam.steamid.from_url(username)
        elif username.isnumeric():
            obj = steam.steamid.SteamID(username)
        else:
            profile_link = "https://steamcommunity.com/id/" + username
            obj = steam.steamid.from_url(profile_link)

        # the provided link was invalid
        if obj.type != steam.steamid.EType.Individual:
            await ctx.send(
                f"{ctx.message.author} the link you provided is invalid.")
        else:
            # continue with registration process
            # the profile is not public
            # doesn't provide a major risk but we can't get certain data, so we suggest and move on
            if obj.universe != obj.steam.steamid.EUniverse.Public:
                await ctx.send(
                    f"{ctx.message.author} your profile is not public, this might cause some problem we suggest you set your profile to public."
                )

            status = db.insertUserSteam('steam', obj)
            if status == common.STATUS.FAIL.INSERT:
                await ctx.send(
                    f"{ctx.message.author}, registration unsuccessful. This is internal error."
                )
                bot.get_channel(common.getMasterLog()).send(
                    f"**DB Insert Error**: Unable to insert csgo user {username} requested from user {ctx.message.author}."
                )
            elif status == common.STATUS.SUCCESS:
                await ctx.send(
                    f"{ctx.message.author}, registration successful.")
            elif status == common.STATUS.FAIL.DUPLICATE:
                await ctx.send(
                    f"{ctx.message.author}, you are already registered for this service."
                )
Exemple #12
0
 def __init__(self, bot):
     self.bot = bot
     self.groupedCommands = {}
     self.groupedCommands['initcat'] = {
         'name':
         'initcat',
         'arguments':
         'rolename description',
         'description':
         'initializes the category to be specific to rolename and role description'
     }
     self.groupedCommands['init'] = {
         'name':
         'init',
         'arguments':
         'rolename description',
         'description':
         'initializes the channel to be specific to rolename and role description'
     }
     self.groupedCommands['deinit'] = {
         'name': 'deinit',
         'arguments': 'rolename',
         'description':
         'de-initializes the channel to be specific to rolename'
     }
     self.groupedCommands['create'] = {
         'name': 'create',
         'arguments': 'rolename',
         'description': 'creates a new role'
     }
     self.groupedCommands['delete'] = {
         'name': 'delete',
         'arguments': 'rolename',
         'description': 'delete the role'
     }
     self.help = Help()
     self.db = Database()
     self.masterLogger = common.getMasterLog()
    async def run(self, bot):
        db = database.Database()
        masterLogger = common.getMasterLog()

        # request the page
        req = requests.get(self.url)

        # get service from database
        service = db.getService("destinyupdates")

        if common.getEnvironment() == 'dev':
            # post log in logging channel
            await bot.get_channel(masterLogger).send(
                f"**Scraped**: Destiny 2 Updates.")

        # return variable
        updates = []

        # soupy
        soup = BeautifulSoup(req.content, 'html5lib')

        # post container:
        container = soup.find('div', attrs={'id': 'explore-contents'})

        # iterating though each post
        i = 0
        for post in container.findAll('a'):
            # check for max 5 updates
            i = i + 1
            if i >= 4:
                break

            posts = {}
            posts['link'] = post.get('href')
            posts['title'] = post.find('div', {"class": "title"}).text

            # addition request for date and patchnotes
            detail_req = requests.get('https://www.bungie.net/' +
                                      posts['link'])
            detail_soup = BeautifulSoup(detail_req.content, 'html5lib')

            # beautify date
            posts['date'] = detail_soup.select("div.metadata")[0].text
            posts['date'] = posts['date'].split("-")[0].strip()

            try:
                # the date is older than 1 day
                posts['date'] = str(
                    datetime.strptime(posts['date'], "%b %d, %Y"))[:-9]
            except Exception:
                # convert relative hours to date
                posts['date'] = posts['date'].replace("h", "")
                delta = timedelta(hours=int(posts['date']))
                posts['date'] = str(
                    datetime.strftime((datetime.today() - delta), "%b %d, %Y"))
                posts['date'] = str(
                    datetime.strptime(posts['date'], "%b %d, %Y"))[:-9]

            posts['patchnotes'] = str(
                detail_soup.find("div",
                                 attrs={"class": "content text-content"}))

            # removing tags
            posts['patchnotes'] = posts['patchnotes'].replace("\t",
                                                              "").replace(
                                                                  "\n", "")
            posts['patchnotes'] = posts['patchnotes'].replace(
                "<div class=\"content text-content\">", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<h2>",
                                                              "\n").replace(
                                                                  "</h2>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<h3>",
                                                              "\n").replace(
                                                                  "</h3>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<div>",
                                                              "\n").replace(
                                                                  "</div>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<ul>",
                                                              "").replace(
                                                                  "</ul>", "")
            posts['patchnotes'] = posts['patchnotes'].replace(
                "<li>", "- ").replace("</li>", "\n")
            posts['patchnotes'] = posts['patchnotes'].replace("<b>",
                                                              "").replace(
                                                                  "</b>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<u>",
                                                              "").replace(
                                                                  "</u>", "")
            posts['patchnotes'] = posts['patchnotes'].replace(
                "<br/><br/>", "\n").replace("<br/>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<hr/>", "")
            posts['patchnotes'] = posts['patchnotes'].replace("<p", " <p")

            posts['patchnotes'] = w3lib.html.remove_tags(posts['patchnotes'])

            posts['id'] = posts['date']
            posts['service_name'] = 'destinyupdates'
            posts['service_id'] = str(service['_id'])
            status = db.upsertPatchnotes(posts)
            if status == common.STATUS.INSERTED:
                updates.append(posts)
            elif status == common.STATUS.REDUNDANT:
                break
            else:
                await bot.get_channel(masterLogger).send(
                    f"**Scrape Error - Destiny 2 Updates**: id = {posts['id']}."
                )

        # returns list in ascending order
        for update in updates[::-1]:
            # discord embed description limit
            if len(update['patchnotes']) >= 2048:
                update['patchnotes'] = update['patchnotes'][:2040] + "\n..."

            # send an embed message
            embed = discord.Embed(title=update["title"],
                                  url="https://www.bungie.net/" +
                                  update["link"],
                                  description=update['patchnotes'])
            embed.add_field(name="Date", value=update["date"], inline=True)

            # get all the channels with service enabled
            channels = guild.getChannels("destinyupdates")
            for channel in channels:
                await bot.get_channel(channel["channel_id"]).send(embed=embed)
                # if logging is enabled post log
                if "logging" in channel:
                    await bot.get_channel(channel["logging"]).send(
                        f"sent {update['title']} in {channel['channel_name']}")

            # sleep for 1 second
            await asyncio.sleep(1)

        # update database
        data = {}
        data["name"] = "destinyupdates"
        if len(updates) != 0:
            data["lastposted"] = common.getDatetimeIST()
            data["latest"] = updates[len(updates) - 1]["date"]

        status = db.upsertService(data)
        if status == common.STATUS.SUCCESS.INSERTED:
            await bot.get_channel(masterLogger).send(
                f"**Created Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.INSERT:
            await bot.get_channel(masterLogger).send(
                f"**DB Insert Error - Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.UPDATE:
            await bot.get_channel(masterLogger).send(
                f"**DB Update Error - Service**: {data['name']}.")
        else:
            pass
Exemple #14
0
    async def run(self, bot):
        masterLogger = common.getMasterLog()
        db = database.Database()

        # subreddits to fetch
        subreddits = ['gamedeals', 'steamdeals', 'freegamefindings']

        # final post container of non existing and distinct deals
        enriched_post = deque()

        # for each subreddit
        for subreddit in subreddits:
            # get the service record
            service = db.getService(subreddit)
            if 'latest' not in service:
                service['latest'] = None

            # get the latest submissions
            posts = []
            try:
                posts = self.getSubreddit(subreddit, 30)
            except Exception:
                await bot.get_channel(masterLogger).send(
                    f"**Error** : unable to fetch r/{subreddit}")

            # id container
            id = None

            if common.getEnvironment() == 'dev':
                # post log in masterlogger
                await bot.get_channel(masterLogger).send(
                    f"scraped {subreddit}.")

            # iterate through posts
            for post in posts:
                # this is done for getting the first id
                if not id:
                    id = post.id

                # if there are no new post, break
                if post.id == service['latest']:
                    break

                if isFromAcceptableStore(post):
                    deal = {}
                    deal['title'] = post.title
                    deal['id'] = post.id
                    if "reddit.com" in post.url:
                        deal['url'] = gamedeals.getStoreLink(post)
                    else:
                        deal['url'] = gamedeals.removeURI(post.url)
                    deal['created'] = common.getTimeFromTimestamp(post.created)
                    if 'url' in deal and deal['url']:
                        # check if its steam store link
                        if 'steampowered.com' in deal['url']:
                            price = None
                            try:
                                price = self.ssf.getPrice(url=deal['url'])
                            except InvalidArgument as e:
                                if common.getEnvironment(
                                ) == 'prod' or common.getEnvironment(
                                ) == 'dev':
                                    await bot.get_channel(masterLogger).send(
                                        f"error getting price for {deal['url']} of reddit id {deal['id']}. Arguments passed {e.error}, error type {e.type}."
                                    )
                                pass
                            if price:
                                deal['price'] = price['final']
                        if self.keyDoesNotExists(enriched_post, deal):
                            enriched_post.appendleft(deal)

            # update database
            data = {}
            data["name"] = subreddit
            if len(enriched_post) > 0:
                data["lastposted"] = common.getDatetimeIST()
                if id:
                    data["latest"] = id

            status = db.upsertService(data)
            if status == common.STATUS.SUCCESS.INSERTED:
                await bot.get_channel(masterLogger).send(
                    f"**Created Service**: {data['name']}.")
            elif status == common.STATUS.FAIL.INSERT:
                await bot.get_channel(masterLogger).send(
                    f"**DB Insert Error - Service**: {data['name']}.")
            elif status == common.STATUS.FAIL.UPDATE:
                await bot.get_channel(masterLogger).send(
                    f"**DB Update Error - Service**: {data['name']}.")
            else:
                pass

        # send the final deque for posting
        await self.send(enriched_post, bot)
 def __init__(self, bot):
     self.bot = bot
     self.masterLogger = common.getMasterLog()
    async def run(self, bot):
        masterLogger = common.getMasterLog()
        db = database.Database()

        # r/CrackWatch
        subreddit = []
        try:
            subreddit = self.getSubreddit(30)
        except Exception:
            await bot.get_channel(masterLogger).send(f"**Error - Reddit**: unable to fetch r/crackwatch")

        # get latest from database
        service = db.getService("crackwatch")
        if 'latest' not in service:
            service['latest'] = None

        if common.getEnvironment() == 'dev':
            # post log in logging channel
            await bot.get_channel(masterLogger).send(f"**Scraped**: CrackWatch.")
        
        # create deque
        posts = deque()

        id = None

        # append data to deque
        for submission in subreddit:
            if not id:
                id = submission.id

            if submission.id == service['latest']:
                break
                
            post = {}
            post['id'] = submission.id
            post['title'] = submission.title
            post['url'] = submission.url
            post['selftext'] = submission.selftext
            post['created'] = common.getTimeFromTimestamp(submission.created)
            if self.crackHead(submission.link_flair_text):
                post['flair'] = submission.link_flair_text
                posts.appendleft(post)

        # go through new submissions
        for i in range(len(posts)):
            if not posts[i]['flair'] and common.getEnvironment() == 'dev':
                await bot.get_channel(masterLogger).send(f"**Error in CW [no flair]** : check {posts[i]['url']}.")
            else:
                if 'release' in posts[i]['flair'].lower():
                    posts[i]['type'] = 'crack'
                elif "repack" in posts[i]['flair'].lower():
                    posts[i]['type'] = 'repack'
                else:
                    posts[i]['type'] = 'unknown'

                status = db.upsertCrackwatch(posts[i])
                
                if status == common.STATUS.SUCCESS.INSERTED:
                    # check for release flair
                    if posts[i]['type'] == 'crack':
                        description = posts[i]['selftext']

                        # discord embed description limit
                        if len(posts[i]['selftext']) >= 2048:
                            description = description[:2040]+"\n..."
                        
                        embed = discord.Embed(
                            title=posts[i]['title'],
                            url=posts[i]['url'],
                            description=description
                        )

                        links = re.findall(r"(?:http\:|https\:)?\/\/\S*\.(?:png|jpg)[A-Za-z0-9.\/\-\_\?\=\:]*", description)

                        if len(links) > 0:
                            embed.set_image(url=links[0])
                        elif posts[i]['url'].endswith(".jpg") or posts[i]['url'].endswith(".png"):
                            embed.set_image(url=posts[i]['url'])

                        embed.add_field(
                            name="Time",
                            value=posts[i]['created'],
                            inline=True
                        )
                        
                        # send message
                        channels = guild.getChannels("crackwatch")
                        for channel in channels: 
                            await bot.get_channel(channel["channel_id"]).send(embed=embed)
                            # if logging is enabled post log
                            if "logging" in channel:
                                await bot.get_channel(channel["logging"]).send(f"sent {posts[i]['title']} in {channel['channel_name']}")

                        # sleep for 1 sec
                        await asyncio.sleep(1)

                    # check for repack flair
                    elif posts[i]['type'] == 'repack':
                        embed = discord.Embed(
                            title=posts[i]['title'],
                            url=posts[i]['url'],
                            description=posts[i]['selftext']
                        )

                        if posts[i]['url'].endswith(".jpg") or posts[i]['url'].endswith(".png"):
                            embed.set_image(url=posts[i]['url'])

                        embed.add_field(
                            name="Time",
                            value=posts[i]['created'],
                            inline=True
                        )
                        
                        # send message
                        channels = guild.getChannels("repacknews")
                        for channel in channels: 
                            await bot.get_channel(channel["channel_id"]).send(embed=embed)
                            # if logging is enabled post log
                            if "logging" in channel:
                                await bot.get_channel(channel["logging"]).send(f"sent {posts[i]['title']} in {channel['channel_name']}")

                        # sleep for 1 second
                        await asyncio.sleep(1)

                if status == common.STATUS.FAIL.UPDATE or status == common.STATUS.FAIL.INSERT:
                    await bot.get_channel(masterLogger).send(f"**DB Error - crackwatch**: Failed Updated/Insert for id = {posts[i]['id']}.")

        # update database
        data = {}
        data["name"] = "crackwatch"
        if len(posts) > 0:
            data["lastposted"] = common.getDatetimeIST()
            data["latest"] = id

        status = db.upsertService(data)
        if status == common.STATUS.SUCCESS.INSERTED:
            await bot.get_channel(masterLogger).send(f"**Created Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.INSERT:
            await bot.get_channel(masterLogger).send(f"**DB Insert Error - Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.UPDATE:
            await bot.get_channel(masterLogger).send(f"**DB Update Error - Service**: {data['name']}.")
        else:
            pass

        data["name"] = "repacknews"
        status = db.upsertService(data)
        if status == common.STATUS.SUCCESS.INSERTED:
            await bot.get_channel(masterLogger).send(f"**Created Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.INSERT:
            await bot.get_channel(masterLogger).send(f"**DB Insert Error - Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.UPDATE:
            await bot.get_channel(masterLogger).send(f"**DB Update Error - Service**: {data['name']}.")
        else:
            pass
    async def run(self, bot):
        db = database.Database()
        masterLogger = common.getMasterLog()

        # request the page
        req = requests.get(self.url)

        # get service from database
        service = db.getService("csgoupdates")

        if common.getEnvironment() == 'dev':
            # post log in logging channel
            await bot.get_channel(masterLogger).send(
                f"**Scraped**: CSGO Updates.")

        # return variable
        updates = []

        # soupy
        soup = BeautifulSoup(req.content, 'html5lib')

        # post container:
        container = soup.find('div', attrs={'id': 'post_container'})

        # iterating though each post
        for post in container.findAll('div', attrs={'class': 'inner_post'}):
            posts = {}
            posts['title'] = post.h2.text

            # beautify date
            posts['date'] = post.find('p', attrs={
                'class': 'post_date'
            }).text[:-5]
            posts['date'] = str(datetime.strptime(posts['date'],
                                                  "%Y.%m.%d"))[:-9]
            posts['url'] = post.select("a")[0].get('href')

            # patchnotes
            posts['patchnotes'] = []
            for p in post.findAll('p'):
                try:
                    if p.attrs['class']:
                        pass
                except KeyError:
                    # remove html tags
                    posts['patchnotes'].append(
                        str(p).replace("<br/>",
                                       "").replace("<p>",
                                                   "").replace("</p>", ""))

            posts['patchnotes'] = "\n\n".join(posts['patchnotes'])
            posts['patchnotes'] = w3lib.html.remove_tags(posts['patchnotes'])

            posts['id'] = posts['date']
            posts['service_name'] = 'csgoupdates'
            posts['service_id'] = str(service['_id'])
            status = db.upsertPatchnotes(posts)
            if status == common.STATUS.INSERTED:
                updates.append(posts)
            elif status == common.STATUS.REDUNDANT:
                break
            else:
                await bot.get_channel(masterLogger).send(
                    f"**Scrape Error - CSGO Updates**: id = {posts['id']}.")

        # process list in ascending order
        for update in updates[::-1]:
            # discord embed description limit
            if len(update['patchnotes']) >= 2048:
                update['patchnotes'] = update['patchnotes'][:2040] + "\n..."

            # send an embed message
            embed = discord.Embed(title=update["title"],
                                  url=update["url"],
                                  description=update["patchnotes"])

            embed.add_field(name="Date", value=update["date"], inline=True)

            # send message
            channels = guild.getChannels("csgoupdates")
            for channel in channels:
                await bot.get_channel(channel["channel_id"]).send(embed=embed)
                # if logging is enabled post log
                if "logging" in channel:
                    await bot.get_channel(channel["logging"]).send(
                        f"sent {update['title']} in {channel['channel_name']}")

            # sleep for 1 second
            await asyncio.sleep(1)

        # update database
        data = {}
        data["name"] = "csgoupdates"
        if len(updates) > 0:
            data["lastposted"] = common.getDatetimeIST()
            data["latest"] = updates[0]["date"]

        status = db.upsertService(data)
        if status == common.STATUS.SUCCESS.INSERTED:
            await bot.get_channel(masterLogger).send(
                f"**Created Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.INSERT:
            await bot.get_channel(masterLogger).send(
                f"**DB Insert Error - Service**: {data['name']}.")
        elif status == common.STATUS.FAIL.UPDATE:
            await bot.get_channel(masterLogger).send(
                f"**DB Update Error - Service**: {data['name']}.")
        else:
            pass
 def __init__(self, bot):
     self.bot = bot
     self.masterLog = common.getMasterLog()
     self.directCommands = {}
     self.directCommands['register'] = {'name': 'register', 'arguments': 'profile link or id', 'description': 'registers profile for steam services.'}
     self.help = Help()