async def send_payments_details(destination, record, action_name): """ Send payment details on query to user """ ledger_record = Embed( title=f':bookmark_tabs: {action_name} :bookmark_tabs: ', colour=Colour.dark_orange()) ledger_record.add_field(name=f':calendar: Date and time :calendar: ', value=f'`{record["created_at"]}`') ledger_record.add_field(name=CONST_PAG, value=f'`{record["paging_token"]}`') ledger_record.add_field(name=f':map: Source account :map:', value=f'```{record["source_account"]}```', inline=False) ledger_record.add_field(name=':cowboy: Recipient :cowboy: ', value=f'```{record["to"]}```', inline=False) ledger_record.add_field(name=CONST_HASH, value=f'`{record["transaction_hash"]}`', inline=False) ledger_record.add_field( name=':moneybag: Amount :moneybag: ', value=f'`{record["amount"]} {record["asset_type"]}`', inline=False) ledger_record.add_field( name=f':person_running: Ledger Activity :person_running: ', value=f'[Transactions]({record["_links"]["transaction"]["href"]})\n' f'[Effects]({record["_links"]["effects"]["href"]})\n' f'[Succeeds]({record["_links"]["succeeds"]["href"]})\n' f'[Precedes]({record["_links"]["precedes"]["href"]})') await destination.send(embed=ledger_record)
async def comic(ctx): """ Shows the latest xkcd webcomic with alt text. """ embed = xkcd_embed(get_xkcd_latest()) embed.color = Colour.dark_orange() await bot.say(None, embed=embed)
async def qr(self, ctx): """ Send the QR only to user """ user_profile = self.backoffice.account_mng.get_user_memo(user_id=ctx.message.author.id) if user_profile: coins_string = ', '.join([str(coin.upper()) for coin in self.list_of_coins]) deposit_embed = Embed(title='Deposit QR code', colour=Colour.dark_orange()) deposit_embed.add_field(name=':gem: Supported CryptoCurrencies:gem: ', value=f'```{coins_string}```', inline=False) memo = user_profile["stellarDepositId"] uri = self.backoffice.stellar_wallet.generate_uri(address=self.backoffice.stellar_wallet.public_key, memo=memo) image = pyqrcode.create(content=uri, error='L') image.png(file=f'{ctx.message.author.id}.png', scale=6, module_color=[0, 255, 255, 128], background=[17, 17, 17], quiet_zone=4) qr_to_send = File(f'{ctx.message.author.id}.png') deposit_embed.set_image(url=f"attachment://{ctx.message.author.id}.png") deposit_embed.set_footer(text=f'{self.command_string}wallet deposit qr -> Only QR') await ctx.author.send(file=qr_to_send, embed=deposit_embed) self.clean_qr_image(author_id=ctx.message.author.id) else: title = '__Deposit information error__' message = f'Deposit details for your account could not be obtained at this moment from the system. ' \ f'Please try again later, or contact one of the staff members. ' await custom_messages.system_message(ctx=ctx, color_code=1, message=message, destination=1, sys_msg_title=title)
async def payment(self, ctx): if ctx.invoked_subcommand is None: title = ':incoming_envelope: __Available Transaction Commands__ :incoming_envelope: ' description = "Commands dedicated to execution of transactions/payments" list_of_values = [{ "name": ":cowboy: XLM Discord related payments :cowboy:", "value": f"```{self.command_string}2 tx user <@discord.Member> " f"<wallet level:int> <amount>```\n" f"**__Wallet Levels__**\n" f":one: => Transaction to 1st level Discord wallet based on MEMO\n" f":two: => Transaction to 2nd level Discord wallet owned by user over Discord\n" f"***Note***: All data is automatically obtained from the CL system once " f"recipient selected." f"\n`Aliases: usr, u`" }, { "name": ":map: XLM Non-Discord related recipients :map:", "value": f"```{self.command_string}2 tx address <address> <amount>" f" <memo=optional>```\n" f"`Aliases: addr, a, add`" }] await custom_messages.embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
async def on_member_remove(self, member): """ Clean up process once member leaves the guild """ if not member.bot: if self.bot.backoffice.account_mng.check_user_existence( user_id=member.id): print( Fore.LIGHTYELLOW_EX + f'{member} left {member.guild}... Notifying him on funds') warning_embed = Embed( title=f':warning: __{self.bot.user}__ :warning: ', description= 'This is automatic notification from Crypto Link Payment system bot', colour=Colour.dark_orange()) warning_embed.add_field( name='Notification', value= f'You have left the {member.guild} where {self.bot.user} payment system ' f'is present. Hope you did not have any funds in your wallet.' ' Funds can be accessed from any community where the system is present.', inline=False) await member.send(embed=warning_embed) else: print(Fore.LIGHTYELLOW_EX + f'{member} left {member.guild}... Not Registered')
async def balance(self, ctx): user_balances = self.backoffice.wallet_manager.get_balances(user_id=ctx.message.author.id) coin_data = self.backoffice.integrated_coins if user_balances: all_wallets = list(user_balances.keys()) # initiate Discord embed balance_embed = Embed(title=f":office_worker: Wallet details for {ctx.message.author} :office_worker:", timestamp=datetime.utcnow(), colour=Colour.dark_orange()) balance_embed.set_thumbnail(url=ctx.message.author.avatar_url) for wallet_ticker in all_wallets: if wallet_ticker == 'xlm': coin_settings = coin_data[wallet_ticker] token_balance = get_normal(value=str(user_balances[wallet_ticker]), decimal_point=int(coin_settings["decimal"])) if coin_settings["coinGeckoListing"]: token_to_usd = convert_to_usd(amount=float(token_balance), coin_name='stellar') else: token_to_usd = {"total": 0, "usd": 0} balance_embed.add_field( name=f"{coin_settings['emoji']} {coin_settings['name']} Balance {coin_settings['emoji']}", value=f'{token_balance} {coin_settings["emoji"]} (${token_to_usd["total"]}) \n' f'Rate: ${token_to_usd["usd"]}/XLM', inline=False) await ctx.author.send(embed=balance_embed) else: title = '__Stellar Wallet Error__' message = f'Wallet could not be obtained from the system please try again later' await custom_messages.system_message(ctx=ctx, color_code=1, message=message, destination=1, sys_msg_title=title)
async def voter(self, ctx): if ctx.invoked_subcommand is None: title = ':joystick: __Available commands as voter__ :joystick: ' description = f"All commands dedicated to all voters who have voted for " \ f"***{self.bot.bot_settings['delegateName']}*** delegate." \ "you can use ***v*** as a synonym for ***voter***" list_of_values = [{"name": ":cowboy: Activate Profile", "value": f"```{self.command_string}voter management```" f"`Aliases: mng`"}, {"name": ":mag_right: Check Last 4 payments", "value": f"```{self.command_string}voter payments <public address>```\n" f"`Aliases: p`"}, {"name": ":mag_right: Check current state in Delegate", "value": f"```{self.command_string}voter state <public address>```\n" f"`Aliases: nfo, i`"}, {"name": ":mega: Apply for available automatic notifications", "value": f"```{self.command_string}voter notify```"}, {"name": ":mega: Check ROI based on vote size", "value": f"```{self.command_string}voter rate```"}, {"name": ":warning: Important :warning: ", "value": f"`If you have registered yourself into Discord system than ***public address***" f" is not needed when executing commands above. Your public key will be " f" pulled automatically from database`"} ] await embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
def make_poll_result_embed(bot: 'MiniMaid', ctx: Context, poll: Poll, choices: list) -> Embed: """ 投票結果のEmbedを生成します。 :param bot: Botのインスタンス :param ctx: Context :param poll: 生成する投票 :param choices: 表示する票数 (選択肢, 個数, パーセント) :return: 生成したEmbed """ message_url = MESSAGE_URL_BASE.format(poll.guild_id, poll.channel_id, poll.message_id) user = bot.get_user(poll.owner_id) embed = Embed(description=f"**[{poll.title}]({message_url})**", colour=Colour.dark_orange()) embed.set_author( name=(str(user) if user is not None else str(poll.owner_id)), icon_url=(user.avatar_url_as(format="png", size=128) if user is not None else None)) embed.set_footer(text=f"{ctx.prefix}poll end {poll.id} で投票を終了できます。") for choice, count, percent in choices: graph = '\U00002b1c' * int(percent // 10) embed.add_field(name=f"{choice.emoji} {choice.value} ({count}票)", value=f"{graph} {int(percent)}%", inline=False) return embed
async def deposit(self, ctx): """ Returns deposit information to user """ if ctx.invoked_subcommand is None: user_profile = self.backoffice.account_mng.get_user_memo(user_id=ctx.message.author.id) if user_profile: coins_string = ', '.join([str(coin.upper()) for coin in self.list_of_coins]) description = ' :warning: To top up your Discord wallets, you will need to send from your preferred' \ ' wallet(GUI, CLI) to the address and deposit ID provided below. Of them will result in ' \ 'funds being lost to which staff of Launch Pad Investments is not ' \ 'responsible for. :warning:' deposit_embed = Embed(title='How to deposit', colour=Colour.dark_orange(), description=description) deposit_embed.add_field(name=':gem: Supported CryptoCurrencies:gem: ', value=f'```{coins_string}```', inline=False) deposit_embed.add_field( name=f' {CONST_STELLAR_EMOJI} Deposit Details {CONST_STELLAR_EMOJI}', value=f'\n:map: Public Address :map: \n' f'```{self.backoffice.stellar_wallet.public_key}```\n' f':compass: MEMO :compass:\n' f'```{user_profile["stellarDepositId"]}```', inline=False) deposit_embed.add_field(name=':warning: **__Warning__** :warning:', value='Be sure to include and provide appropriate **__MEMO__** as text and Wallet ' 'address for each currency , otherwise your deposit will be lost!', inline=False) deposit_embed.add_field(name="Currently available currencies on Crypto Link", value=f'```{coins_string}```', inline=False) deposit_embed.add_field(name=":printer: QR Code :printer: ", value=f'Bellow is your personal QR code including your deposit address and ' f'MEMO. Scan it with mobile application supporting QR. Be sure to ' f'recheck the data once you scan it.', inline=False) memo = user_profile["stellarDepositId"] uri = self.backoffice.stellar_wallet.generate_uri(address=self.backoffice.stellar_wallet.public_key, memo=memo) image = pyqrcode.create(content=uri, error='L') image.png(file=f'{ctx.message.author.id}.png', scale=6, module_color=[0, 255, 255, 128], background=[17, 17, 17], quiet_zone=4) qr_to_send = File(f'{ctx.message.author.id}.png') deposit_embed.set_image(url=f"attachment://{ctx.message.author.id}.png") deposit_embed.set_footer(text=f'{self.command_string}wallet deposit qr -> Only QR') await ctx.author.send(file=qr_to_send, embed=deposit_embed) self.clean_qr_image(author_id=ctx.message.author.id) else: title = '__Deposit information error__' message = f'Deposit details for your account could not be obtained at this moment from the system. ' \ f'Please try again later, or contact one of the staff members. ' await custom_messages.system_message(ctx=ctx, color_code=1, message=message, destination=1, sys_msg_title=title)
def __init__(self, cetus, earth, vallis): title = "Timers" Embed.__init__(self, title=title, type="rich") self.colour = Colour.dark_orange() self.addCetusTimer(cetus) self.addEarthTimer(earth) self.addVallisTimer(vallis)
def __init__(self, sortie): boss = sortie['boss'] title = "Sortie: " + boss Embed.__init__(self, title=title, type="rich") if sortie['expired']: self.description = "Expired" else: self.description = "Ends in " + sortie['eta'] self.colour = Colour.dark_orange() for mission in sortie['variants']: self.addFieldMission(mission)
async def notify(self, ctx): if ctx.invoked_subcommand is None: title = 'Automatic notifications system' description = "Bellow are all available services which allow you to apply your registered public key " \ "to be monitored for various activities. " list_of_values = [{"name": ":money_with_wings: Get notifications to DM when delegate sends you payment", "value": f"```{self.command_string}voter notify reward <on/off>```"} ] await embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
def get_random_color() -> Colour: """ TODO: Add more colors that look good :return: """ colors = [ Colour.blurple(), Colour.dark_blue(), Colour.dark_orange(), Colour.dark_magenta(), Colour.teal(), Colour.magenta(), Colour.dark_gold(), Colour.blurple() ] return random.choice(colors)
async def delegate(self, ctx): if ctx.invoked_subcommand is None: title = ':joystick: __Available delegate stats__ :joystick: ' description = "All commands dedicated to query delegate characteristics" list_of_values = [{"name": "Overall Statistics", "value": f"```{self.command_string}delegate stats```\n" f"`Aliases: s`"}, {"name": "Review 5 last blocks", "value": f"```{self.command_string}delegate blocks```\n" f"`Aliases: b`"} ] await embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
async def me(self, ctx): utc_now = datetime.utcnow() wallet_data = self.backoffice.wallet_manager.get_full_details(user_id=ctx.message.author.id) xlm_balance = float(wallet_data["xlm"]) / (10 ** 7) rates = get_rates(coin_name='stellar') acc_details = Embed(title=f':office_worker: {ctx.author} :office_worker:', description=f' ***__Basic details on your Discord account__*** ', colour=Colour.dark_orange(), timestamp=utc_now) acc_details.set_author(name=f'Discord Account details', icon_url=ctx.author.avatar_url) acc_details.add_field(name=":map: Wallet address :map: ", value=f"```{self.backoffice.stellar_wallet.public_key}```") acc_details.add_field(name=":compass: MEMO :compass: "******"```{wallet_data['depositId']}```", inline=False) acc_details.add_field(name=':moneybag: Stellar Lumen (XLM) Balance :moneybag: ', value=f'`{xlm_balance:.7f}` {CONST_STELLAR_EMOJI}', inline=False) if rates: in_eur = rate_converter(xlm_balance, rates["stellar"]["eur"]) in_usd = rate_converter(xlm_balance, rates["stellar"]["usd"]) in_btc = rate_converter(xlm_balance, rates["stellar"]["btc"]) in_eth = rate_converter(xlm_balance, rates["stellar"]["eth"]) in_rub = rate_converter(xlm_balance, rates["stellar"]["rub"]) in_ltc = rate_converter(xlm_balance, rates["stellar"]["ltc"]) acc_details.add_field(name=f':flag_us: USA', value=f'$ {in_usd:.4f}') acc_details.add_field(name=f':flag_eu: EUR', value=f'€ {in_eur:.4f}') acc_details.add_field(name=f':flag_ru: RUB', value=f'₽ {in_rub:.4f}') acc_details.add_field(name=f'BTC', value=f'₿ {in_btc:.8f}') acc_details.add_field(name=f'ETH', value=f'Ξ {in_eth:.8f}') acc_details.add_field(name=f'LTC', value=f'Ł {in_ltc:.8f}') acc_details.add_field(name=f'{CONST_STELLAR_EMOJI} More On Stellar Lumen (XLM) {CONST_STELLAR_EMOJI}', value=f'[Stellar](https://www.stellar.org/)\n' f'[Stellar Foundation](https://www.stellar.org/foundation)\n' f'[Stellar Lumens](https://www.stellar.org/lumens)\n' f'[CMC](https://coinmarketcap.com/currencies/stellar/)\n' f'[Stellar Expert](https://stellar.expert/explorer/public)') acc_details.set_footer(text='Conversion rates provided by CoinGecko') await ctx.author.send(embed=acc_details)
def set_embed_color(embed, card_details): faction = card_details['faction']['name'] if faction == 'Monster': embed.color = Colour.red() elif faction == 'Neutral': embed.color = Colour.dark_orange() elif faction == 'Nilfgaard': embed.color = Colour.darker_grey() elif faction == 'Northern Realms': embed.color = Colour.blue() elif faction == "Scoia'tael": embed.color = Colour.green() elif faction == 'Skellige': embed.color = Colour.purple() return embed
async def wallet(self, ctx): if ctx.invoked_subcommand is None: title = ':joystick: __Available Wallet Commands__ :joystick: ' description = "All commands available to operate execute wallet related actions.\n" \ "`Aliases: one, st, first, 1`" list_of_values = [{"name": " :woman_technologist: Get Full Account Balance Report :woman_technologist: ", "value": f"```{self.command_string}wallet balance```\n" f"`Aliases: bal, balances,b`"}, {"name": ":bar_chart: Get Wallet Statistics :bar_chart:", "value": f"```{self.command_string}wallet stats```"}, {"name": ":inbox_tray: Get Deposit Instructions :inbox_tray:", "value": f"```{self.command_string}wallet deposit```"}, {"name": ":outbox_tray: Get Withdrawal Instructions :outbox_tray: ", "value": f"```{self.command_string}withdraw```"}] await custom_messages.embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
async def account(self, ctx): if ctx.invoked_subcommand is None: title = ':joystick: __Available Custodial Account Commands__ :joystick: ' description = "All commands available to operate with wallet level 2" list_of_values = [{ "name": ":information_source: Get Account Details :information_source: ", "value": f"```{self.command_string}custodial account info```\n" f"`Aliases: nfo`" }] await custom_messages.embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=0, c=Colour.dark_orange())
async def management(self, ctx): if ctx.invoked_subcommand is None: title = ':joystick: __Welcome to Voter Management System __ :joystick: ' description = "If you have voted for delegate, you can register your public key into the system. " \ "It will be appended under your Discord User name. Check for benefits." list_of_values = [{"name": ":information_source: Benefits when registered", "value": f"```1. No more copy pasting of your public key" f"2. Automatic notifications to DM when payments are sent out\n```"}, {"name": ":new: Create new profile", "value": f"```{self.command_string}voter management register <public address>```"}, {"name": ":octagonal_sign: Delete profile from system", "value": f"```{self.command_string}voter management remove```"}, {"name": ":office_worker: Review registration details", "value": f"```{self.command_string}voter management me```"} ] await embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
async def pairingsRound(self, ctx, round: int = -1): """Show tournament current pairings or for specific round. To show parirings for the latest round: !cobra pairings To show parirings for the second round: !cobra pairings 2""" data = self.getTournament(ctx) # Create Dictionary PlayerID:PlayerName for pairings players = {None: "Bye"} # Null players are Bye for player in data.get("players"): players.update({player.get("id"): player.get("name")}) if round < 0: round = len(data.get("rounds")) - 1 else: round -= 1 tables, player1, player2 = "", "", "" # Loop over each pair in round for pair in data.get("rounds")[round]: self.logger.log(logging.DEBUG, pair) p1 = pair.get("player1").get("id") p2 = pair.get("player2").get("id") tables = tables + str(pair.get("table")) + "\n" player1 += players[p1] + "\n" player2 += players[p2] + "\n" embed = Embed() embed.title = data.get("name") embed.description = "Pairings for round " + str(round + 1) embed.url = COBRA_URL + self.getTournamentId(ctx) embed.color = Colour.dark_orange() embed.add_field(name="Table", value=tables, inline=True) embed.add_field(name="Player 1", value=player1, inline=True) embed.add_field(name="Player 2", value=player2, inline=True) await ctx.send(embed=embed)
async def tx_info_for_hash(destination, data: dict, signatures, date: str, memo): single_info = Embed(title=f':hash: Transaction Hash Details :hash:', colour=Colour.dark_orange()) single_info.add_field( name=f':sunrise: Horizon Link :sunrise:', value=f'[Transaction Hash]({data["_links"]["self"]["href"]})') single_info.add_field(name=':ledger: Ledger :ledger: ', value=f'`{data["ledger"]}`') single_info.add_field(name=CONST_PAG, value=f'`{data["paging_token"]}`', inline=True) single_info.add_field(name=f':calendar: Created :calendar: ', value=f'`{data["created_at"]}`', inline=False) single_info.add_field(name=f' :map: Source account :map: ', value=f'`{data["source_account"]}`', inline=False) single_info.add_field(name=f' :pencil: Memo :pencil: ', value=f'`{memo}`', inline=False) single_info.add_field(name=f':pen_ballpoint: Signers :pen_ballpoint: ', value=signatures, inline=False) single_info.add_field(name=CONST_HASH, value=f'`{data["hash"]}`', inline=False) single_info.add_field( name=':money_with_wings: Fee :money_with_wings: ', value=f'`{round(int(data["fee_charged"]) / 10000000, 7):.7f} XLM`', inline=False) single_info.add_field( name=f':sunrise: Horizon Link :sunrise:', value=f'[Ledger]({data["_links"]["ledger"]["href"]})\n' f'[Transactions]({data["_links"]["transaction"]["href"]})\n' f'[Effects]({data["_links"]["effects"]["href"]})\n' f'[Operations]({data["_links"]["succeeds"]["href"]})\n' f'[Succeeds]({data["_links"]["succeeds"]["href"]})\n' f'[Precedes]({data["_links"]["precedes"]["href"]})') await destination.send(embed=single_info)
async def tx_info_for_account(destination, record: dict, signers: str, memo, date): account_record = Embed( title=f':record_button: Account Transaction Record :record_button:', colour=Colour.dark_orange()) account_record.add_field(name=':ledger: Ledger :ledger: ', value=f'`{record["ledger"]}`') account_record.add_field(name=CONST_PAG, value=f'`{record["paging_token"]}`') account_record.add_field(name=f':calendar: Created :calendar: ', value=f'`{date}`', inline=True) account_record.add_field(name=f' :map: Source account :map: ', value=f'```{record["source_account"]}```', inline=False) account_record.add_field(name=f' :pencil: Memo :pencil: ', value=f'`{memo}`', inline=False) account_record.add_field(name=f':pen_ballpoint: Signers :pen_ballpoint: ', value=signers, inline=False) account_record.add_field(name=CONST_HASH, value=f'`{record["hash"]}`', inline=False) account_record.add_field( name=':money_with_wings: Fee :money_with_wings: ', value=f'`{round(int(record["fee_charged"]) / 10000000, 7):.7f} XLM`', inline=False) account_record.add_field( name=f':sunrise: Horizon Link :sunrise:', value=f'[Account]({record["_links"]["account"]["href"]})\n' f'[Ledger]({record["_links"]["ledger"]["href"]})\n' f'[Transactions]({record["_links"]["transaction"]["href"]})\n' f'[Effects]({record["_links"]["effects"]["href"]})\n' f'[Operations]({record["_links"]["succeeds"]["href"]})\n' f'[Succeeds]({record["_links"]["succeeds"]["href"]})\n' f'[Precedes]({record["_links"]["precedes"]["href"]})') await destination.send(embed=account_record)
async def two(self, ctx): if ctx.invoked_subcommand is None: title = ':wave: __Welcome to Level 2 wallet system__ :wave: ' description = "Unlike Wallet __Level 1 system__, ***Level 2*** allows for full control of your" \ " ***private keys*** and with it, ability to import Discord wallet into other applications." \ " Upon successful registration and key verification, Crypto Link Stores and safely " \ "encrypts part of your private key. When executing on-chain actions for wallet over Discord," \ " you will be required to provide second part of the private key (sign) before action can be " \ " streamed to the Stellar network\n" \ "`Aliases: cust, c, 2`" list_of_values = [{ "name": ":new: Register for in-active wallet :new: ", "value": f"```{self.command_string}two register```\n" f"`Aliases: get, new. reg`" }, { "name": ":joystick: Group of commands to obtain info on Layer two Account :joystick: ", "value": f"```{self.command_string}two account```\n" f"`Aliases: acc, a`" }, { "name": ":money_with_wings: Group of commands to create various transactions " ":money_with_wings:", "value": f"```{self.command_string}two payment```\n" f"`Aliases: pay, p, tx, transactions`" }] await custom_messages.embed_builder(ctx=ctx, title=title, description=description, data=list_of_values, destination=1, c=Colour.dark_orange())
async def tx_info_for_ledger(destination, ledger_id, record: dict, signatures, date): """ Send transaction information based on ledger """ ledger_record = Embed( title=f':record_button: Record for {ledger_id} :record_button:', colour=Colour.dark_orange()) ledger_record.add_field(name=CONST_PAG, value=f'`{record["paging_token"]}`', inline=False) ledger_record.add_field(name=f':calendar: Created :calendar: ', value=f'`{date}`', inline=False) ledger_record.add_field(name=f' :map: Source account :map: ', value=f'`{record["source_account"]}`', inline=False) ledger_record.add_field(name=f' Source account Sequence ', value=f'`{record["source_account_sequence"]}`', inline=False) ledger_record.add_field(name=f':pen_ballpoint: Signers :pen_ballpoint: ', value=signatures, inline=False) ledger_record.add_field(name=CONST_HASH, value=f'`{record["hash"]}`', inline=False) ledger_record.add_field( name=f':sunrise: Horizon Link :sunrise:', value=f'[Record]({record["_links"]["self"]["href"]})\n' f'[Account]({record["_links"]["account"]["href"]})\n' f'[Ledger]({record["_links"]["ledger"]["href"]})\n' f'[Transactions]({record["_links"]["transaction"]["href"]})\n' f'[Effects]({record["_links"]["effects"]["href"]})\n' f'[Succeeds]({record["_links"]["succeeds"]["href"]})\n' f'[Precedes]({record["_links"]["precedes"]["href"]})') await destination.send(embed=ledger_record)
target = await ctx.guild.fetch_member(case.target) if case.caseType == CaseType.NOTE: embed.colour = Colour.blue() embed.title = f"Note" elif case.caseType == CaseType.WARNING: embed.colour = Colour.gold() embed.title = f"Warning" elif case.caseType == CaseType.KICK: embed.colour = Colour.orange() embed.title = f"Kick" elif case.caseType == CaseType.TEMPBAN: embed.colour = Colour.dark_orange() embed.title = f"Temp-ban" elif case.caseType == CaseType.BAN: embed.colour = Colour.red() embed.title = f"Ban" embed.title += f" added for {target.display_name}" embed.description = case.message embed.set_footer(text=f"Case ID: {case.caseId} - Added by {moderator.display_name}") embed.timestamp = case.date return embed async def getCaseTargetEmbed(ctx, case: Case): embed = discord.Embed()
from random import seed, randint from datetime import datetime seed(datetime.now()) colours = [ Colour.teal(), Colour.dark_teal(), Colour.green(), Colour.dark_green(), Colour.blue(), Colour.dark_blue(), Colour.purple(), Colour.dark_purple(), Colour.magenta(), Colour.dark_magenta(), Colour.gold(), Colour.dark_gold(), Colour.orange(), Colour.dark_orange(), Colour.red(), Colour.dark_red(), Colour.lighter_grey(), Colour.light_grey(), Colour.dark_grey(), Colour.darker_grey(), Colour.blurple(), Colour.greyple(), Colour.from_rgb(randint(0, 255), randint(0, 255), randint(0, 255)) ]
class Leaderboard: colors = [Colour.gold(), Colour.light_grey(), Colour.dark_orange()] async def check_server_leaderboard(msg_obj, client): try: data = None with open("leaderboards/" + msg_obj.server.id + ".json") as file: data = json.load(file) for ping in range(len(data)): await client.send_message(msg_obj.channel, embed=Leaderboard.embed_constructor( data[ping], msg_obj.server, ping + 1, Leaderboard.colors[ping])) except Exception as e: print(e) await client.send_message( msg_obj.channel, error + "No leaderboard for this server!") #TODO: Maybe divide interval by ping_count to determine a ping's "value" and compare values for leaderboard spots # maybe only use the worth as a modifier to multiply ping_count by for a "value" def try_add_to_leaderboard(server_id, ping): # try to open an existing leaderboard and if possible add this ping try: leaderboard_path = "leaderboards/" + server_id + ".json" print("checking if ping should be added") data = None insert_index = -1 ping_json = ping.asJSON() with open(leaderboard_path) as file: data = json.load(file) ping_count = ping_json['ping_count'] for i in range(0, len(data)): if data[i]['ping_count'] < ping_count: insert_index = i print("ping marked for insertion") break if insert_index == -1 and len(data) < 3: insert_index = -2 # add the ping if insert_index was actually changed if insert_index > -1: with open(leaderboard_path, "w") as outfile: data.insert(insert_index, ping_json) if len(data) == 4: del data[3] json.dump(data, outfile) print("ping inserted") # if there's room for the ping, just add it elif insert_index == -2: with open(leaderboard_path, "w") as outfile: data.append(ping_json) print("ping appended") json.dump(data, outfile) # if there's no existing leaderboard for this server, make one and add this ping except Exception as e: print("error ", e) print("making leaderboard") with open("leaderboards/" + server_id + ".json", "w") as outfile: data = [] data.append(ping.asJSON()) json.dump(data, outfile) #TODO: Add discriminator to the JSON def embed_constructor(ping_json, server, num, color): embed = Embed() author = ping_json["author"] author_icon = ping_json["avatar"] embed.colour = color embed.set_author(name="#{0}".format(num)) embed.set_thumbnail(url=author_icon) embed.add_field(name="Author", value=author) embed.add_field(name="Message", value=ping_json["user_message"]) mentions = ping_json["mentions"] embed.add_field(name="Mentions", value=pingutils.get_formatted_name_list( server, mentions)) embed.add_field(name="Ping Count", value=ping_json["ping_count"]) interval = ping_json["interval"] embed.add_field(name="Interval", value="{0} seconds".format(interval)) return embed
async def system_payment_notifications(self): payment_notifications = self.bot.setting.get_setting( setting_name='payment_notifications') if payment_notifications["status"] == 1: rpc_wallet_resp = self.xcash_manager.xcash_rpc_wallet.get_last_outgoing_transfers( last_processed_height=payment_notifications["value"]) if rpc_wallet_resp["result"]: new_outgoing = rpc_wallet_resp["result"]["out"] payment_channel = self.bot.get_channel( id=int(payment_notifications["channel"])) # Get the price of xcash on market xcash_value = self.bot.dpops_queries.xcash_explorer.price() if xcash_value.get("USD"): xcash_usd = xcash_value["USD"] else: xcash_usd = 0.0 for tx in new_outgoing: xcash_payment_value = float(tx['amount']) / (10**6) usd_final = round((xcash_payment_value * xcash_usd), 4) payments_emb = Embed( title=f':incoming_envelope: I have sent out payments!', description= f'Use `!voter payments` to check if you have ' f'been part of the batch.', colour=Colour.dark_orange()) payments_emb.set_thumbnail(url=self.bot.user.avatar_url) payments_emb.add_field( name=f":date: Time", value= f"`{datetime.fromtimestamp(int(tx['timestamp']))}`") payments_emb.add_field(name=f":bricks: Block Height", value=f"`{tx['height']}`", inline=True) payments_emb.add_field( name=f":money_with_wings: Total sent in batch", value= f":coin: `{float(tx['amount']) / (10 ** 6):,} XCASH`\n" f":flag_us: `${usd_final}`", inline=False) payments_emb.add_field(name=f":id: Transaction ID ", value=f"```{tx['txid']}```", inline=False) payments_emb.set_footer(text="Thank you for votes") payments_emb.set_author( name=f'{self.bot.user}', url='http://xpayment.x-network.eu/') await payment_channel.send(embed=payments_emb) if self.twitter_messages and self.tweet_service_status( setting_name="t_payment_batch"): print("sending payment sent.") init_text = ["I have just paid", "I have just sent "] tt = f"{random.choice(init_text)} my voters reward for their votes," \ f" in total of {float(tx['amount']) / (10 ** 6):,} XCASH (${usd_final})" \ f" {self.produce_hash_tag_list(6)}." self.tweet(text=tt) if self.bot.setting.update_settings_by_dict( setting_name="payment_notifications", value={"value": int(new_outgoing[-1]["height"])}): print("db updated successfully") else: print("Could not update DB") else: print("No new payments done")