async def info(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if not user_db.check_user(user_id): embed = discord.Embed(title="**For first-use**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field(name="First of all, please type `//help`", value="Welcome to CPUchain tipbot !") embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="CPUchain tipbot {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass block = client.getblockchaininfo()['blocks'] hash_rate = round(client.getnetworkhashps() / 1000, 4) difficulty = client.getblockchaininfo()['difficulty'] connection = client.getnetworkinfo()['connections'] client_version = client.getnetworkinfo()['subversion'] blockchain_size = round( client.getblockchaininfo()['size_on_disk'] / 1000000000, 3) embed = discord.Embed(title="**CPUchain info**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field(name="__Current block height__", value="`{0}`".format(block), inline=True) embed.add_field(name="__Network hash rate__", value="`{0} KH/s`".format(hash_rate), inline=True) embed.add_field(name="__Difficulty__", value="`{0}`".format(difficulty), inline=True) embed.add_field(name="__Connection__", value="`{0}`".format(connection), inline=True) embed.add_field(name="__Client Version__", value="`{0}`".format(client_version), inline=True) embed.add_field(name="__Block chain size__", value="`About {0} GB`".format(blockchain_size), inline=True) embed.set_footer(text="CPUchain tipbot {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def info(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if not user_db.check_user(user_id): embed = discord.Embed(title="**For first-use-user**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field(name="First of all, please type `//help`", value="Welcome to world of Tip Magi !") embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip Magi {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass block = client.getinfo()['blocks'] hash_rate = round(client.getnetworkhashps() / 1000, 4) difficulty_pow = client.getinfo()['difficulty']['proof-of-work'] difficulty_pos = client.getinfo()['difficulty']['proof-of-stake'] connection = client.getinfo()['connections'] client_version = client.getinfo()['version'] embed = discord.Embed(title="**Magichain info**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field(name="__Current block height__", value="`{0}`".format(block), inline=True) embed.add_field(name="__Network hash rate__", value="`{0} KH/s`".format(hash_rate), inline=True) embed.add_field(name="__Difficulty (POW)__", value="`{0}`".format(difficulty_pow), inline=True) embed.add_field(name="__Difficulty (POS)__", value="`{0}`".format(difficulty_pos), inline=True) embed.add_field(name="__Connection__", value="`{0}`".format(connection), inline=True) embed.add_field(name="__Client Version__", value="`{0}`".format("m-core:" + client_version), inline=True) embed.set_footer(text="Tip Magi {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def deposit(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if ctx.channel.id == 723493757860708714: if not user_db.check_user(user_id): embed = discord.Embed(title="**For first-use-user**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="First of all, please type `//help`", value="Welcome to world of Tip MBC !") embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) user_name = ctx.author.display_name address = client.getaccountaddress(account) embed = discord.Embed(title="**Your deposit address**", color=0x0043ff) embed.add_field(name="please send MBC to this address.", value="Click to enlarge the QR code") embed.set_thumbnail( url= 'https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl={0}' .format(address)) embed.set_author(name=user_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) await ctx.channel.send("```{0}```".format(address)) else: embed = discord.Embed(title="Oops", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Wrong Channel", value="Please use #tipbot to use this tipbot", ) await ctx.channel.send(embed=embed)
async def balance(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if ctx.channel.id == 723493757860708714: if not user_db.check_user(user_id): embed = discord.Embed(title="**For first-use-user**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="First of all, please type `//help`", value="Welcome to world of Tip MBC !") embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) user_name = ctx.author.display_name balance = client.getbalance(account, config.CONFIRM) unconfirmed_balance = client.getbalance(account, 0) - \ client.getbalance(account, config.CONFIRM) embed = discord.Embed(title="**Your balances**", color=0x0043ff) embed.set_author(name=user_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="{0} MBC".format(str(balance)), value="unconfirmed : {0} MBC".format( str(unconfirmed_balance))) embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: embed = discord.Embed(title="Oops", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Wrong Channel", value="Please use #tipbot to use this tipbot", ) await ctx.channel.send(embed=embed)
async def info(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed( title="**How may I be of service?**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="To see all my available commands type `!help`", value="If you have any issues please let one of the team know.") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass block = client.getblockchaininfo()['blocks'] hash_rate = round(client.getnetworkhashps() / 1000000000, 4) difficulty = round(client.getblockchaininfo()['difficulty'], 4) connection = client.getnetworkinfo()['connections'] client_version = client.getnetworkinfo()['subversion'] embed = discord.Embed( title="**Umbru Network Information**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="**Current Block Height:**", value="`{0}`".format(block)) embed.add_field( name="**Network Hash Rate:**", value="`{0} GH/s`".format(hash_rate)) embed.add_field( name="**Difficulty:**", value="`{0}`".format(difficulty)) embed.add_field( name="**Connections:**", value="`{0}`".format(connection)) embed.add_field( name="**Wallet Version:**", value="`{0}`".format(client_version)) embed.add_field( name="**Explorer:**", value="<https://explorer.umbru.io>") embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def balance(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed( title="**How may I be of service?**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="To see all my available commands type `!help`", value="If you have any issues please let one of the team know.") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION),icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) user_name = ctx.author.display_name balance = client.getbalance(account, config.CONFIRM) unconfirmed_balance = client.getbalance(account, 0) - \ client.getbalance(account, config.CONFIRM) embed = discord.Embed( title="**Your Umbru Balance:**", color=0x7152b6) embed.set_author( name=user_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="{0:.6f} UMBRU".format(balance), value="Unconfirmed: {0:.6f} UMBRU".format(unconfirmed_balance)) embed.set_footer(text="TipBot v{0}".format(config.VERSION),icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def deposit(self, ctx): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed( title="**How may I be of service?**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="To see all my available commands type `!help`", value="If you have any issues please let one of the team know.") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION),icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) user_name = ctx.author.display_name address = client.getaccountaddress(account) embed = discord.Embed( title="**Your Umbru Deposit Address:**", color=0x7152b6) embed.add_field( name="Please use the following address to deposit Umbru.", value="Click on QR Code to enlarge.") embed.set_thumbnail(url='https://chart.googleapis.com/chart?cht=qr&chs=500x500&chl={0}'.format(address)) embed.set_author( name=user_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) await ctx.channel.send("```{0}```".format(address))
async def tip(self, ctx, mention=None, amount=None): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed(title="**How may I be of service?**", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="To see all my available commands type `!help`", value="If you have any issues please let one of the team know." ) embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if mention is None or amount is None: embed = discord.Embed(color=0xffd800) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "No user or amount specified. Please check **!help** for information.", value=" :warning: :warning: :warning: ") embed.set_footer(text="TipBot v{0}]".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) elif not str_isfloat(amount): embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Invalid tip amount. Please check **!help** for information.", value="`{0}`".format(amount)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass tipfrom = str(ctx.author.id) tipto = str(mention.replace('<@', '').replace('>', '')) amount = Decimal(str(float(amount))) if amount < Decimal('0.01'): embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Tip amount must be atleast 0.01 UMBRU", value="`{0}`".format(amount)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: if len(tipto) != 18 and len(tipto) != 17: embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Invalid User. Please check **!help** for information.", value="`{0}`".format(str(mention))) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif tipfrom == tipto: embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="Sorry you cannot tip yourself!", value=" :wink: ") embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif amount > client.getbalance(tipfrom, config.CONFIRM): embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Sorry you do not have enough UMBRU for that.", value="Your balance is: **{0} UMBRU**".format( client.getbalance(tipfrom, config.CONFIRM))) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: if tipto == str(self.bot.user.id): try: move_istrue = client.move( tipfrom, 'tipbot_wallet', float(amount)) except: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Invalid tip amount. Please check **!help** for information.", value="`{0}`".format(amount)) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) if move_istrue: embed = discord.Embed(color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Thank you for the donation!", value="**{0} UMBRU**".format(amount)) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: try: move_istrue = client.move( tipfrom, tipto, float(amount)) except: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Invalid tip amount. Please check **!help** for information.", value="`{0}`".format(amount)) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) if move_istrue: embed = discord.Embed(color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="{0} has tipped {1} `{2} UMBRU`". format( ctx.author.display_name, self.bot.get_user( int(tipto)).display_name, amount), value="Spend it wisely!") embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed)
async def help(self, ctx): user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed( title="**Umbru Bot Command List:**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="**!help**", value="This is the command you have just used :wink:", inline=True) embed.add_field( name="**!info**", value="Show Umbru Core wallet/blockchain info.", inline=True) embed.add_field( name="**!balance**", value="Show your Umbru balances.", inline=True) embed.add_field( name="**!deposit**", value="Show your Umbru deposit address.", inline=True) embed.add_field( name="**!tip**", value="Tip specified user. [!tip @Ryxor 1] to tip 1 UMBRU", inline=True) embed.add_field( name="**!withdraw**", value="Withdraw Umbru from your wallet. [!withdraw ADDRESS AMOUNT]", inline=True) embed.add_field( name="**!withdrawall**", value="Withdraw all Umbru from your wallet. [!withdrawall ADDRESS]", inline=True) embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass embed = discord.Embed( title="**Umbru Bot Command List:**", color=0x7152b6) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="**!help**", value="This is the command you have just used.", inline=True) embed.add_field( name="**!info**", value="Show Umbru Core wallet/blockchain info.", inline=True) embed.add_field( name="**!balance**", value="Show your Umbru balances.", inline=True) embed.add_field( name="**!deposit**", value="Show your Umbru deposit address.", inline=True) embed.add_field( name="**!tip**", value="Tip specified user. [!tip @Ryxor 1] to tip 1 UMBRU", inline=True) embed.add_field( name="**!withdraw**", value="Withdraw Umbru from your wallet. [!withdraw ADDRESS AMOUNT]", inline=True) embed.add_field( name="**!withdrawall**", value="Withdraw all Umbru from your wallet. [!withdrawall ADDRESS]", inline=True) embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def withdraw(self, ctx, address=None, amount=None): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if not user_db.check_user(user_id): embed = discord.Embed( title="**For first-use-user**", color=0x0043ff) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="First of all, please type `//help`", value="Welcome to world of Tip Sugar !") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if address is None or amount is None: embed = discord.Embed(color=0xffd800) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Please check `//help` ", value=" :mag: ") embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if not str_isfloat(amount) or Decimal(amount) < Decimal('0.5'): embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid amount. (amount must be at least 0.5 SUGAR)", value="`{0}`".format(str(amount))) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: sendamount = Decimal(str(float(amount))) - \ Decimal(str(config.FEE)) # Dealing with cases like "001.100" : "float(amount)" account = str(ctx.author.id) validate = client.validateaddress(address) if not validate['isvalid']: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid address.", value="`{0}`".format(str(address))) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif Decimal(amount) > client.getbalance(account, config.CONFIRM): embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="You don't have enough balances.", value="Your balances : ```{0} SUGAR```".format(client.getbalance(account, config.CONFIRM))) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: try: txid = client.sendfrom(account, address, float(sendamount)) except: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid amount.\n(You can not specify the einth decimal place or smaller than that.)", value="`{0}`".format(amount)) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) if len(txid) == 64: tx = client.gettransaction(txid) txfee = tx['fee'] client.move(account, "tipsugar_wallet", Decimal(str(config.FEE))) client.move("tipsugar_wallet", account, -txfee) embed = discord.Embed( title="**Block explorer**", url='https://1explorer.sugarchain.org/tx/{0}'.format(txid), color=0x0043ff) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Withdrawal complete `{0} SUGAR`\nwithdraw fee is `{1} SUGAR`\nPlease check the transaction at the above link.".format(sendamount, str(config.FEE)), value="Your balances : `{0} SUGAR`".format(client.getbalance(account, config.CONFIRM))) embed.set_footer(text="Tip Sugar {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def tip(self, ctx, mention=None, amount=None): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if not user_db.check_user(user_id): embed = discord.Embed( title="**For first-use-user**", color=0x0043ff) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="First of all, please type `//help`", value="Welcome to world of Tip BRWN !") embed.set_thumbnail(url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if mention is None or amount is None: embed = discord.Embed(color=0xffd800) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Please check `//help` ", value=" :mag: ") embed.set_footer( text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif not str_isfloat(amount): embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid amount.", value="`{0}`".format(amount)) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass tipfrom = str(ctx.author.id) tipto = str(mention.replace('<@','').replace('>','')).replace('!','') amount = Decimal(str(float(amount))) # Dealing with cases like "001.100", ".123" : "float(amount)" if amount < Decimal('0.00000001'): embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="amount must be at least 0.00000001 BRWN", value="`{0}`".format(amount)) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: if len(tipto) != 18 and len(tipto) != 17: # length of discord user id is 18 or 17 embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid user.", value="`{0}`".format(str(mention))) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif tipfrom == tipto: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="You cannot tip to yourself.", value=" :thinking: ") embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) elif amount > client.getbalance(tipfrom, config.CONFIRM): embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="You don't have enough balances.", value="Your balances ```{0} BRWN```".format(client.getbalance(tipfrom, config.CONFIRM))) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: if tipto == str(self.bot.user.id): try: move_istrue = client.move(tipfrom, 'tipBRWN_wallet', float(amount)) except: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid amount.\n(You can not specify the einth decimal place or smaller than that.)", value="`{0}`".format(amount)) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) if move_istrue: embed = discord.Embed(color=0x0043ff) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Thank you for donating!", value="```{0} BRWN```".format(amount)) embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: try: move_istrue = client.move(tipfrom, tipto, float(amount)) except: embed = discord.Embed(color=0xff0000) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="invalid amount.\n(You can not specify the einth decimal place or smaller than that.)", value="`{0}`".format(amount)) embed.set_footer( text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) if move_istrue: embed = discord.Embed(color=0x0043ff) embed.set_author( name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="{0} tipped to {1} `{2} BRWN`".format(ctx.author.display_name, self.bot.get_user(int(tipto)).display_name, amount), value="yay!") embed.set_footer(text="Tip BRWN {0} [Owner: {1}]".format(config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def withdrawall(self, ctx, address=None): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) if ctx.channel.id == 723493757860708714: if not user_db.check_user(user_id): embed = discord.Embed(title="**For first-use-user**", color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="First of all, please type `//help`", value="Welcome to world of Tip MBC !") embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) balance = Decimal(client.getbalance(account, config.CONFIRM)) if address is None: embed = discord.Embed(color=0xffd800) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="Please check `//help` ", value=" :mag: ") embed.set_footer(text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if balance < Decimal('0.5'): embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Amount must be at least 0.5 MBC.", value="Your balances : ```{0} MBC```".format( client.getbalance(account, config.CONFIRM))) embed.set_footer( text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: amount = balance - Decimal(str(config.FEE)) validate = client.validateaddress(address) if not validate['isvalid']: embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field(name="invalid address.", value="`{0}`".format(str(address))) embed.set_footer( text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: txid = client.sendfrom(account, address, float(amount)) tx = client.gettransaction(txid) txfee = tx['fee'] client.move(account, "tipmagi_wallet", Decimal(str(config.FEE))) client.move("tipmagi_wallet", account, -txfee) embed = discord.Embed( title="**Block explorer**", url= 'https://microbitcoinorg.github.io/explorer/#/transaction/{0}' .format(txid), color=0x0043ff) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Withdrawal complete `{0} MBC`\nwithdraw fee is `{1} MBC`\nPlease check the transaction at the above link." .format(amount, str(config.FEE)), value="Your balances : `{0} MBC`".format( client.getbalance(account, config.CONFIRM))) embed.set_footer( text="Tip MBC {0} [Owner: {1}]".format( config.VERSION, self.bot.get_user(config.OWNER_ID)), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: embed = discord.Embed(title="Oops", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Wrong Channel", value="Please use #tipbot to use this tipbot", ) await ctx.channel.send(embed=embed)
async def withdrawall(self, ctx, address=None): client = AuthServiceProxy(rpc_connection) user_id = str(ctx.author.id) user_name = ctx.author.name if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed(title="**How may I be of service?**", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="To see all my available commands type `!help`", value="If you have any issues please let one of the team know." ) embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: pass account = str(ctx.author.id) balance = Decimal(client.getbalance(account, config.CONFIRM)) if address is None: embed = discord.Embed(color=0xffd800) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "No address specified. Please check **!help** for information.", value=" :warning: :warning: :warning: ") embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass if balance < Decimal('0.1'): embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Invalid amount (must be at least 0.1 UMBRU).", value="Your Balances: **{0:.6f} UMBRU**".format( client.getbalance(account, config.CONFIRM))) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: amount = balance - Decimal(str(config.FEE)) validate = client.validateaddress(address) if not validate['isvalid']: embed = discord.Embed(color=0xff0000) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="Invalid Umbru address, please check.", value="`{0}`".format(str(address))) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed) else: txid = client.sendfrom(account, address, float(amount)) tx = client.gettransaction(txid) txfee = tx['fee'] client.move(account, "tipbot_wallet", Decimal(str(config.FEE))) client.move("tipbot_wallet", account, -txfee) embed = discord.Embed( title="**Block Explorer**", url='https://explorer.umbru.io/insight/tx/{0}'. format(txid), color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name= "Withdrawal Complete: `{0} UMBRU`\nWithdrawal Fee: `{1} UMBRU`\nClick above link to check on the block explorer." .format(amount, str(config.FEE)), value="Your Balances: `{0:.6f} UMBRU`".format( client.getbalance(account, config.CONFIRM))) embed.set_footer( text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as(format='png', size=256)) await ctx.channel.send(embed=embed)
async def help(self, ctx): user_id = str(ctx.author.id) user_name = ctx.author.name if ctx.channel.id == 723493757860708714: if not user_db.check_user(user_id): user_db.add_user(user_id, user_name) embed = discord.Embed(title="**MBC Bot Command List:**", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="**//help**", value="This is the command you have just used :wink:", inline=True) embed.add_field(name="**//info**", value="Show MBC Core wallet/blockchain info.", inline=True) embed.add_field(name="**//balance**", value="Show your MBC balances.", inline=True) embed.add_field(name="**//deposit**", value="Show your MBC deposit address.", inline=True) embed.add_field( name="**//tip**", value= "Tip specified user. [//tip @Nugetzrul3 1] to tip 1 MBC", inline=True) embed.add_field( name="**//withdraw**", value= "Withdraw MBC from your wallet. [//withdraw ADDRESS AMOUNT]", inline=True) embed.add_field( name="**//withdrawall**", value= "Withdraw all MBC from your wallet. [//withdrawall ADDRESS]", inline=True) embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: pass embed = discord.Embed(title="**MBC Bot Command List:**", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as( format='png', size=256)) embed.add_field( name="**//help**", value="This is the command you have just used.", inline=True) embed.add_field(name="**//info**", value="Show MBC Core wallet/blockchain info.", inline=True) embed.add_field(name="**//balance**", value="Show your MBC balances.", inline=True) embed.add_field(name="**//deposit**", value="Show your MBC deposit address.", inline=True) embed.add_field( name="**//tip**", value= "Tip specified user. [//tip @Nugetzrul3 1] to tip 1 MBC", inline=True) embed.add_field( name="**//withdraw**", value= "Withdraw MBC from your wallet. [//withdraw ADDRESS AMOUNT]", inline=True) embed.add_field( name="**//withdrawall**", value= "Withdraw all MBC from your wallet. [//withdrawall ADDRESS]", inline=True) embed.set_thumbnail( url=self.bot.user.avatar_url_as(format='png', size=1024)) embed.set_footer(text="TipBot v{0}".format(config.VERSION), icon_url=self.bot.user.avatar_url_as( format='png', size=256)) await ctx.channel.send(embed=embed) else: embed = discord.Embed(title="Oops", color=0x7152b6) embed.set_author(name=ctx.author.display_name, icon_url=ctx.author.avatar_url_as(format='png', size=256)) embed.add_field( name="Wrong Channel", value="Please use #tipbot to use this tipbot", ) await ctx.channel.send(embed=embed)