예제 #1
0
    async def accept(self, ctx):
        """Accept the Pawer terms, run deposit first"""
        user = User(ctx.author.id)
        user_info = user.info()
        # if accepted, say when and gives address
        if user_info:
            if user_info['accept']:
                msg = "Your :bis: address is `{}`".format(user_info['address'])
                em = discord.Embed(description=msg,
                                   colour=discord.Colour.orange())
                em.set_author(
                    name="{}, you already accepted the terms on {}".format(
                        ctx.author.display_name,
                        ts_to_string(user_info['accept'])))
                await ctx.send(embed=em)
                return
        # If not, creates wallet and stores accepted.
        address = user.create_wallet()
        info = {"accept": int(time.time()), "address": address}
        user.save(info)

        self.bot.tip_module.add_user(address, ctx.author.id,
                                     ctx.author.display_name)

        # TODO: safety, store an encrypted backup of the wallet elsewhere.
        msg = "Your {} address is `{}`".format(EMOJIS['Bismuth'],
                                               info['address'])
        em = discord.Embed(description=msg, colour=discord.Colour.green())
        em.set_author(
            name="{}: Terms accepted".format(ctx.author.display_name))
        await ctx.send(embed=em)
예제 #2
0
 async def info(self, ctx):
     # TODO: cache?
     status = User.status()
     # print(status)
     # How to
     msg = "Current supply: {} {}\n".format(int(status['supply']),
                                            EMOJIS['Bismuth'])
     msg += "Block height  : {} \n".format(status['blocks'])
     msg += "Protocol      : {} \n".format(status['protocolversion'])
     msg += "Node version  : {} \n".format(status['walletversion'])
     msg += "Consensus     : {}  ({:0.2f}%)\n".format(
         status['consensus'], status['consensus_percent'])
     msg += "Difficulty    : {} \n".format(status['difficulty'])
     msg += "Connections   : {} \n".format(status['connections'])
     # msg += "Time of info  : {} \n".format(status['difficulty'])
     if 'extended' in status:
         msg += "Wallet version: {} \n".format(
             status['extended']['version'])
     em = discord.Embed(description=msg, colour=discord.Colour.green())
     em.set_author(name="Bismuth PoW status from {} on {} UTC".format(
         status['server'], ts_to_string(float(status['server_timestamp']))))
     await self.bot.say(embed=em)