async def define_winner(self, message_reaction, message_author, message): bot = self.ctx.bot if (message_author != bot.user and message_reaction.message.id == message.id and message_reaction.emoji in bot_constants.JOKENPO_PIECES): pc_choice, user_choice = choice( bot_constants.JOKENPO_PIECES), message_reaction.emoji pcwin = user_choice == self.jokenpo_winning_elements[pc_choice] userwin = pc_choice == self.jokenpo_winning_elements[user_choice] embed = Embed() embed.add_field(name='Você escolheu', value=user_choice) embed.add_field(name='O computador escolheu', value=pc_choice) if userwin and not pcwin: embed.title = 'Vencedor' embed.description = 'O vencedor foi você!! Parabéns' embed.colour = Colour.dark_green() elif pcwin and not userwin: embed.title = 'Perdedor' embed.description = 'O computador levou a melhor dessa vez, tende de novo!' embed.colour = Colour.dark_red() else: embed.title = 'Empate' embed.description = 'Mentes brilhantes pensam igual, foi um empate!' embed.colour = Colour.orange() await handler.edit_message(message, logger, embed=embed)
def predict_colour(rcode: str) -> Colour: colour = Colour.default() if rcode == "0": colour = Colour.dark_green() elif rcode == "1": colour = Colour.dark_red() return colour
async def element_color(element): switch = { 'Light': Colour.gold(), 'Dark': Colour.dark_purple(), 'Fire': Colour.dark_red(), 'Water': Colour.dark_blue(), 'Forest': Colour.dark_green() } return switch.get(element)
async def show(self, ctx): """Show basic tournament infomation""" data = self.getTournament(ctx) embed = Embed() embed.title = data.get("name") embed.url = COBRA_URL + self.getTournamentId(ctx) embed.color = Colour.dark_green() embed.add_field( name="Organizer", value=data.get("tournamentOrganiser").get("nrdbUsername"), inline=True) embed.add_field(name="Players", value=len(data.get("players")), inline=True) embed.add_field(name="Rounds", value=data.get("preliminaryRounds"), inline=True) await ctx.send(embed=embed)
"nivelian": "https://cdn.discordapp.com/attachments/700683544103747594/711013623257890857/nivelian.png", "neutral": "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/twitter/248/rocket_1f680.png", "void": "https://cdn.discordapp.com/attachments/700683544103747594/711013699841687602/void.png" } errorIcon = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/twitter/248/exclamation-mark_2757.png" winIcon = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/twitter/248/trophy_1f3c6.png" rocketIcon = "https://emojipedia-us.s3.dualstack.us-west-1.amazonaws.com/thumbs/120/twitter/248/rocket_1f680.png" # colours to use in faction-related embed strips factionColours = { "terran": Colour.gold(), "vossk": Colour.dark_green(), "midorian": Colour.dark_red(), "nivelian": Colour.dark_blue(), "neutral": Colour.purple() } # Data representing all ship items in the game. These are used to create bbShip objects, # which are stored in builtInShipObjs in a similar dict format. # Ships to not have tech levels in GOF2, so tech levels will be automaticaly generated # for the sake of the bot during bot.on_ready. builtInShipData = {} # Data representing all module items in the game. These are used to create bbModule objects, # which are stored in builtInModuleObjs in a similar dict format. builtInModuleData = {}
from discord import Colour 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)) ]
async def register(self, ctx): """ Interactive registration procedure for second wallet level """ # Entry message for the user await second_level_account_reg_info(destination=ctx.author) # Wait for answer welcome_verification = await self.bot.wait_for('message', check=check( ctx.message.author), timeout=180) # Verify user answer if welcome_verification.content.upper() in ["YES", "Y"]: # Get private and public key details = self.backoffice.stellar_wallet.create_stellar_account() # Check if details returned if details: # User half of the key details["userHalf"] = details["secret"][:len(details["secret"] ) // 2] # Send information with details of new account await send_new_account_information(ctx=ctx, details=details) # Message on explanation about verification await verification_request_explanation( destination=ctx.message.author) # Wait for user response verification_msg = await self.bot.wait_for( 'message', check=check(ctx.message.author), timeout=60) if verification_msg.content.upper() == details["userHalf"]: system_half = details["secret"][ len(details["secret"]) // 2:] # Second half of private key # getting encrypted version of the key encrypted_key = security_manager.encrypt( private_key=bytes(system_half, 'utf-8')) # Producing data to be stored data_to_store = { "userId": int(ctx.author.id), "publicAddress": details["address"], "privateKey": encrypted_key } # Storing data if self.backoffice.second_level_manager.create_user_wallet( data_to_store=data_to_store): message = f"You have successfully verified your secret key and registered level 2 account" \ f" into Crypto Link system. Public address and 1/2 of private" \ f" key have been securely stored under your Discord User ID {ctx.author.id}. I" \ f"n order for account to become active, you are required to activate it through " \ f"on-chain deposit to address provided to you in previous steps" await custom_messages.system_message( ctx=ctx, color_code=Colour.dark_green(), destination=0, sys_msg_title= ':white_check_mark: Second Level Account' ' Created :white_check_mark:', message=message) load_channels = [ self.bot.get_channel(id=int(chn)) for chn in self.backoffice.guild_profiles. get_all_explorer_applied_channels() ] msg = ':new: User register for wallet level 2. :rocket: ' await send_uplink_message(destinations=load_channels, message=msg) else: message = 'There has been an issue while storing data into the system. Please re-initiate the' \ ' whole process. If issue persists, contact Crypto Link Staff' await custom_messages.system_message( ctx=ctx, color_code=Colour.dark_red(), destination=0, sys_msg_title=':exclamation: Second level wallet ' 'registration error :exclamation: ', message=message) else: message = 'You have provided wrong 1/2 of the key which resulted in private key mismatch.' \ ' Please re-initiate the registration process again' await custom_messages.system_message( ctx=ctx, color_code=Colour.dark_red(), destination=0, sys_msg_title=':exclamation: Key verification Error' ' :exclamation: ', message=message) else: message = 'There has been an issue while trying to create 2 level wallet. Please try again later.' \ ' If the issue persists please contact staff of the Crypto Link team.' await custom_messages.system_message( ctx=ctx, color_code=Colour.dark_red(), destination=0, sys_msg_title=':exclamation: Account Creation Error' ' :exclamation: ', message=message) else: message = 'You have successfully cancelled second level wallet registration procedure.' await custom_messages.system_message( ctx=ctx, color_code=Colour.dark_red(), destination=0, sys_msg_title=':exclamation: Registration Cancelled' ' :exclamation: ', message=message)