Пример #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 watch(self, ctx, hypernode: str = ''):
     """Adds a hn to watch, print the current list"""
     try:
         user = User(ctx.message.author.id)
         user_info = user.info()
         msg = ''
         if hypernode:
             hn_status = await self._hn_status()
             if hypernode not in hn_status:
                 # unknown ip
                 msg = "No known Hypernode with ip {}".format(hypernode)
                 em = discord.Embed(description=msg,
                                    colour=discord.Colour.red())
                 em.set_author(name="Error")
                 await self.bot.say(embed=em)
                 return
             # add the hhn to the list
             if hypernode not in user_info.get('hn_watch', []):
                 watch = user_info.get('hn_watch', [])
                 watch.append(hypernode)
                 # TODO: add to reverse index
                 user_info['hn_watch'] = watch
                 msg = "Added {}\n".format(hypernode)
                 user.save(user_info)
         watch_list = await self.hn_watch_list(user_info, for_print=True)
         msg += watch_list
         em = discord.Embed(description=msg, colour=discord.Colour.green())
         em.set_author(name="You're watching...")
         await self.bot.say(embed=em)
     except Exception as e:
         print(e)
         exc_type, exc_obj, exc_tb = sys.exc_info()
         fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
         print(exc_type, fname, exc_tb.tb_lineno)
Пример #3
0
 async def unwatch(self, ctx, hypernode: str = ''):
     """Adds a hn to watch, print the current list"""
     user = User(ctx.message.author.id)
     user_info = user.info()
     msg = ''
     if hypernode:
         # add the hhn to the list
         if hypernode in user_info.get('hn_watch', []):
             watch = user_info.get('hn_watch', [])
             watch = [hn for hn in watch if hn != hypernode]
             # TODO: add to reverse index
             user_info['hn_watch'] = watch
             msg = "Removed {}\n".format(hypernode)
             user.save(user_info)
     watch_list = await self.hn_watch_list(user_info, for_print=True)
     msg += watch_list
     em = discord.Embed(description=msg, colour=discord.Colour.green())
     em.set_author(name="You're watching...")
     await self.bot.say(embed=em)