Пример #1
0
async def wallet_watcher():
    await client.wait_until_ready()
    start = int(rpc.getStatus()['blockCount']) - 100000
    while not client.is_closed:
        height = int(rpc.getStatus()['blockCount'])
        print("HEIGHT IS: " + str(height))
        for tx in get_deposits(start, session):
            session.add(tx)
            try:
                session.commit()
            except:
                session.rollback()
            balance = session.query(TipJar).filter(
                TipJar.paymentid == tx.paymentid).first()
            if not balance:  # don't do for withdrawal
                return

            good_embed = discord.Embed(title="Deposit Recieved!",
                                       colour=discord.Colour(0xD4AF37))
            good_embed.description = "Your deposit of {} {} has now been credited.".format(
                tx.amount / config['units'], config['symbol'])
            print("TRANSACTION PID IS: " + tx.paymentid)
            good_embed.add_field(name="New Balance",
                                 value="{0:,.2f}".format(balance.amount /
                                                         config['units']))
            user = await client.get_user_info(str(balance.userid))
            await client.send_message(user, embed=good_embed)
        if start < height:
            start += 1000
        if start >= height:
            start = height - 1
        await asyncio.sleep(0.5)  # just less than the block time
Пример #2
0
async def wallet_watcher():
    await client.wait_until_ready()
    start = 194320
    while not client.is_closed:
        height = int(rpc.getStatus()['blockCount'])
        for tx in get_deposits(start, session):
            session.add(tx)
        try:
            session.commit()
        except:
            session.rollback()
        if start < height:
            start += 1000
        if start >= height:
            start = height - 1
        await asyncio.sleep(10)
Пример #3
0
async def height():
    """ Returns the current block count """
    await client.say("The current block height is **{:,}**".format(
        rpc.getStatus()['blockCount']))
Пример #4
0
async def height(ctx):
    """ Returns the current block count """
    await client.say("The current block height is **{:,}**".format(rpc.getStatus()['blockCount']))
    await client.delete_message(ctx.message)