Пример #1
0
def post_message(d):
    try:
        if float(d['price']) < 10.0:
            return
        app_id_name = next(
            (item for item in app_id_lookup if item['a'] == d['app_id']), None)
        app_id = int(d['app_id'])
        name = str(d["market_hash_name"])
        market = urllib.request.pathname2url(d['market_hash_name'])
        msg = "Name: {}\nListing Price: {}".format(d["market_hash_name"],
                                                   d['price'])
        if str(d['app_id']) == "730":
            wd = int(d['withdrawable_at'] - time.time())
            if wd <= 0:
                msg += "\nTradeable: Instantly\n"
            else:
                msg += "\nTradeable: {}\n".format(secondsToText(wd))
        if app_id == 730:  #CS
            arr = ["000"]
            if any(knife in name.lower() for knife in knife_channel):
                wh_url = "000"
            elif any(glove in name.lower() for glove in glove_channel):
                wh_url = "000"
            else:
                wh_url = "000"
        elif app_id == 570:  #dota
            wh_url = "000"
        elif app_id == 440:  #tf2
            wh_url = "000"
        else:
            wh_url = "000"
        webhook = DiscordWebhook(url=wh_url)
        log = DiscordEmbed()
        log.title = "Game: {}".format(app_id_name['n'])
        log.color = 0xe74c3c
        thumb = str(d['image'])
        log.set_thumbnail(url=thumb)
        log.description = msg
        log.add_field(
            name='Item Link:',
            value='[[URL](https://bitskins.com/view_item?app_id={}&item_id={})]'
            .format(d['app_id'], d['item_id']),
            inline=True)
        log.add_field(
            name='Sales Page:',
            value=
            '[[URL](https://bitskins.com/?app_id={}&market_hash_name={}&sort_by=price&order=asc)]'
            .format(d['app_id'], market),
            inline=True)
        webhook.add_embed(log)
        webhook.execute()
    except Exception as e:
        print("Error: {}\n TB: {}".format(e, traceback.format_exc()))
def post_message(d, fv, avg, c, stickers, seed=None, insp=None, phase=None):
    try:
        app_id_name = next(
            (item for item in app_id_lookup if item['a'] == d['app_id']), None)
        name = str(d['market_hash_name'])
        app_id = int(d['app_id'])
        price = float(d['price'])
        if app_id == 570:  #dota
            wh_url = "000"
        elif app_id == 433850:  #z1
            wh_url = "000"
        elif app_id == 252490:
            wh_url = "000"
        elif app_id == 730:
            if c == 0x0000ff:  #floats
                wh_url = "000"
            if c == 0x00ff00:  #avg
                if any(knife in name.lower() for knife in knife_channel):
                    wh_url = "000"
                elif "sticker" in name.lower():
                    wh_url = "000"
                elif price <= 1:
                    wh_url = "000"
                elif 1 <= price <= 5:
                    wh_url = "000"
                elif 5 <= price <= 10:
                    wh_url = "000"
                elif 10 <= price <= 50:
                    wh_url = "000"
                elif price > 50:
                    wh_url = "000"
            if c == 0xeeffff:  #price
                if any(knife in name.lower() for knife in knife_channel):
                    wh_url = "000"
                elif "sticker" in name.lower():
                    wh_url = "000"
                elif price <= 1:
                    wh_url = "000"
                elif 1 <= price <= 5:
                    wh_url = "000"
                elif 5 <= price <= 10:
                    wh_url = "000"
                elif 10 <= price <= 50:
                    wh_url = "000"
                elif price > 50:
                    wh_url = "000"
            if c == 0xff0000:  #stickers
                wh_url = "000"
            if c == 0x85ffff:  #ch
                wh_url = "000"
        else:
            wh_url = "000"
        market = urllib.request.pathname2url(d['market_hash_name'])
        msg = "\nItem: {}\n".format(d['market_hash_name'])
        if app_id == 730:
            if seed and "case hardened" in str(d['market_hash_name']).lower():
                msg += "Pattern Seed: {}\n".format(seed)
            if phase is not None:
                msg += "Phase: {}\n".format(
                    str(phase).replace("phase", "Phase "))
            if fv is not None:
                if fv == "-1.0000000000":
                    pass
                elif fv != "None":
                    if fv == 5:
                        msg += "Float: n/a\n".format(float(fv))
                    else:
                        msg += "Float: {:.10f}\n".format(float(fv))
            if stickers is not None:
                msg += "\nStickers:\n"
                stick_len = 1
                for sticker in stickers:
                    msg += "{}) [{}] {}\n".format(
                        stick_len, "{:.0%}".format(float(sticker['w']))
                        if sticker['w'] != "None" else "0%", sticker['n'])
                    stick_len += 1
                msg += "\n"
            wd = int(d['withdrawable_at'] - time.time())
            if wd <= 0:
                msg += "Tradeable: Instantly\n"
            else:
                msg += "Tradeable: {}\n".format(secondsToText(wd))
        msg += "\n"
        avg_sale_price = "${:.3f}".format(avg[0])

        # if avg[3][1]:
        # delta_prof = float(avg[3][1]) - price
        # perc_prof = delta / price * 100
        # else:
        delta = float(avg[0]) - price
        perc = delta / price * 100

        if c == 0x00ff00:
            if price < 0.07:
                # print("{} - ${}".format(d['market_hash_name'], price))
                return
            if perc < 4.86:
                # print("{} - {}%".format(d['market_hash_name'], perc))
                return
        msg += "Price: ${}\n".format(price)
        msg += "AVG Price: {}\nAverage From: {}\n \n".format(
            avg_sale_price, avg[1])
        msg += "Delta: ${:.3f}\nDelta: {:.3f}% \n".format(delta, perc)
        msg += "\nPrevious Sale AVG: ${:.3f}\nCurrent Listing AVG: ${:.3f}\n".format(
            build_avg(avg[2]), build_avg(avg[3]))
        webhook = DiscordWebhook(url=wh_url)
        log = DiscordEmbed()
        log.title = "Game: {}".format(app_id_name['n'])
        log.color = c
        thumb = str(d['image'])
        log.set_thumbnail(url=thumb)
        log.description = msg
        prev_sales = list(dict.fromkeys(avg[2]))
        log.add_field(name='{} Previous {}:'.format(
            len(prev_sales), "Sale" if len(prev_sales) == 1 else "Sales"),
                      value='{}'.format(', '.join(str(v) for v in prev_sales)),
                      inline=False)
        log.add_field(name='{}/5 Current Listings:'.format(len(avg[3])),
                      value='{}'.format(', '.join(str(v) for v in avg[3])),
                      inline=False)
        log.add_field(
            name='Item Link:',
            value='[[URL](https://bitskins.com/view_item?app_id={}&item_id={})]'
            .format(d['app_id'], d['item_id']),
            inline=True)
        log.add_field(
            name='Sales Page:',
            value=
            '[[URL](https://bitskins.com/?app_id={}&market_hash_name={}&sort_by=price&order=asc)]'
            .format(d['app_id'], market),
            inline=True)
        log.add_field(
            name='Pricecheck Page:',
            value='[[URL](https://bitskins.com/price/?market_hash_name={})]'.
            format(market),
            inline=True)
        if insp is not None:
            log.add_field(
                name='Screenshot:',
                value='[[URL](https://csgo.gallery/{})]'.format(insp),
                inline=True)
        log.set_footer(text="Price Modified: ${} -> ${}".format(
            d['old_price'], d['price']))
        webhook.add_embed(log)
        webhook.execute()
        print(d)
    except Exception as e:
        print("Error: {}\n TB: {}".format(e, traceback.format_exc()))
Пример #3
0
def post_message(d):
    try:
        name = str(d["market_hash_name"])
        if d['phase']:
            item_id = d['item_id']
            x = get_item_info(item_id)
            if x == "Sold": #this is a shitty way to deal with it, good luck dealing with bitskins f*****g garbage api
                print("Item {} not on sale.".format(name))
                return
            if x is None:
                print("Item {} has no data.".format(name))
                insp = item_float = None
            else:
                insp = x[0]
                fv = x[1]
            price = float(d['price'])
            phase = str(d['phase'])
            market = urllib.request.pathname2url(name)
            phase_data = get_phase_prices(phase, market)
            avg_phase_price = phase_data[0]
            app_id_name = "Counter-Strike: Global Offensive"
            app_id = int(d['app_id'])
            clean_phase = phase.lower().replace("phase", "phase ")
            msg = "\nItem: {}\n".format(d['market_hash_name'])
            msg+="Phase: {}\n".format(clean_phase.title())
            if fv is not None:
                if fv == "-1.0000000000":
                    pass
                elif fv != "None":
                    if fv == 5:
                        msg+="Float: n/a\n".format(float(fv))
                    else:
                        msg+="Float: {:.10f}\n".format(float(fv))
                msg+="\n"
            wd = int(d['withdrawable_at'] - time.time())
            if wd <= 0:
                msg+="Tradeable: Instantly\n"
            else:
                msg+="Tradeable: {}\n".format(secondsToText(wd))
            msg+="\n"
            delta = float(avg_phase_price) - price
            perc = delta/price*100
            msg+="Price: ${}\nLowest Listing: {}{}\n \n".format(price,avg_phase_price," (Lowest price)" if price == avg_phase_price else "")
            msg+="Delta: ${:.3f}\nDelta: {:.3f}% \n".format(delta, perc)
            webhook = DiscordWebhook(url=wh_url)
            log = DiscordEmbed()
            log.title = "Game: {}".format(app_id_name)
            log.color = 0xe74c3c
            thumb = str(d['image'])
            log.set_thumbnail(url=thumb)
            log.description = msg
            log.add_field(name='{}/5 Current Listings:'.format(len(phase_data)), value='{}'.format(', '.join(str(v) for v in phase_data)), inline=False)
            log.add_field(name='Item Link:', value='[[URL](https://bitskins.com/view_item?app_id={}&item_id={})]'.format(d['app_id'], d['item_id']), inline=True)
            log.add_field(name='Sales Page:', value='[[URL](https://bitskins.com/?app_id={}&market_hash_name={}&sort_by=price&order=asc)]'.format(d['app_id'], market), inline=True)
            log.add_field(name='Pricecheck Page:', value='[[URL](https://bitskins.com/price/?market_hash_name={})]'.format(market), inline=True)
            if insp is not None:
                log.add_field(name='Screenshot:', value='[[URL](https://csgo.gallery/{})]'.format(insp), inline=True)
            webhook.add_embed(log)
            webhook.execute()
    except Exception as e:
        print("Error: {}\n TB: {}".format(e, traceback.format_exc()))