async def _media_search_(self, ctx, *args): print(str(args[0])) search = media_search(query=f'{args[0]}')['items'] alpha_xi = search[0] alpha_xo = search[1] alpha_bi = search[2] embed = discord.Embed( title=alpha_xi["data"][0]["title"], description=f"{ctx.author.mention}, here's what I got!", color=Color.blue()) embed.set_image(url=alpha_xi['links'][0]['href']) embed.add_field(name="Description", value=alpha_xi["data"][0]['description']) await ctx.send(embed=embed) embed = discord.Embed(title=alpha_xo["data"][0]["title"], color=Color.blue()) embed.set_image(url=alpha_xo['links'][0]['href']) embed.add_field(name="Description", value=alpha_xo["data"][0]['description']) await ctx.send(embed=embed) embed = discord.Embed(title=alpha_bi["data"][0]["title"], color=Color.blue()) embed.set_image(url=alpha_bi['links'][0]['href']) embed.add_field(name="Description", value=alpha_bi["data"][0]['description']) await ctx.send(embed=embed)
async def timer(self, ctx): """ Gets the Next Timer! :param ctx: :return: """ next_timer = Timer.objects.filter( corp_timer=False, eve_time__gte=datetime.datetime.utcnow().replace( tzinfo=timezone.utc)).first() time_until = pendulum.now(tz="UTC").diff_for_humans( next_timer.eve_time, absolute=True) embed = Embed(title="Next Timer") embed.description = next_timer.details if next_timer.objective == "Friendly": embed.colour = Color.blue() elif next_timer.objective == "Hostile": embed.colour = Color.red() else: embed.colour = Color.white() try: embed.set_footer(text="Added By {0}".format( next_timer.eve_character.character_name)) except Exception as e: logger.error(e) pass embed.add_field(name="Structure:", value=next_timer.structure) embed.add_field(name="Location:", value="{0} - {1}".format(next_timer.system, next_timer.planet_moon)) embed.add_field(name="Eve Time:", value=next_timer.eve_time.strftime("%Y-%m-%d %H:%M"), inline=False) return await ctx.send(embed=embed)
async def kinsy(self, ctx): """ Returns the Kinsy Video """ await ctx.trigger_typing() embed = Embed(title="JUST JUMP IN!!") embed.set_thumbnail( url= "https://images.evetech.net/characters/1630472146/portrait?size=128" ) embed.colour = Color.blue() embed.description = "Just Jump In And WARP TO ME!!" url = get_site_url() embed.add_field( name="The Link", value= "https://cdn.discordapp.com/attachments/685827175626440735/949349523774398565/My_Movie.mp4" .format(url, url), inline=False) return await ctx.send(embed=embed)
async def list_role(self, ctx): """ list roles from a channel. """ if ctx.message.author.id not in app_settings.get_admins( ): # https://media1.tenor.com/images/1796f0fa0b4b07e51687fad26a2ce735/tenor.gif return await ctx.message.add_reaction(chr(0x1F44E)) await ctx.message.channel.trigger_typing() input_string = ctx.message.content[11:] channel_name = get(ctx.guild.channels, name=input_string) roles = {} if channel_name: for role in channel_name.overwrites: roles[role.name] = {} overides = channel_name.overwrites_for(role) for _name, _value in overides: if _value is not None: roles[role.name][_name] = _value pass embed = Embed(title=f"'{channel_name.name}' Channel Roles") embed.colour = Color.blue() message = "" for key, role in roles.items(): _msg = f"\n`{key}` Role:\n" for r, v in role.items(): _msg += f"{r}: {v}\n" message += _msg embed.description = message return await ctx.send(embed=embed)
async def list_role(self, ctx): """ list roles from a channel. """ await ctx.message.channel.trigger_typing() input_string = ctx.message.content[11:] channel_name = get(ctx.guild.channels, name=input_string) roles = {} if channel_name: for role in channel_name.overwrites: roles[role.name] = {} overides = channel_name.overwrites_for(role) for _name, _value in overides: if _value is not None: roles[role.name][_name] = _value pass embed = Embed(title=f"'{channel_name.name}' Channel Roles") embed.colour = Color.blue() message = "" for key, role in roles.items(): _msg = f"\n`{key}` Role:\n" for r, v in role.items(): _msg += f"{r}: {v}\n" message += _msg embed.description = message return await ctx.send(embed=embed)
async def work(self, ctx): isSuccessful = random.choice([True, False, True, False, True, False]) amount = int(random.randint(15, 50) * random.uniform(0.95, 2.95)) embed = libneko.Embed( title= f"Work {'Successful <:le:808638475229986876>' if isSuccessful else 'Failed <:nogis:808638474646978560>'}" ) if isSuccessful: embed.color = random.choice( [Color.green(), Color.blue(), Color.blurple()]) embed.add_field(name="Outcome:", value=random.choice( workOutcome[isSuccessful]).format( ctx.author, amount)) await self.bot.eco.edit_money(ctx.author.id, amount, "wallet", "add") else: embed.color = random.choice( [Color.red(), Color.orange(), 0xffff00]) embed.add_field(name="Outcome:", value=random.choice( workOutcome[isSuccessful]).format(ctx.author)) embed.set_footer(icon_url=str(ctx.author.avatar_url), text=f"Invoked by {ctx.author}") try: await ctx.send(f"{ctx.author.mention}", embed=embed) except discord.errors.Forbidden: await ctx.send( f"{ctx.author.mention}, I am unable to send the requested data! Please grant the bot the \"Embed Links\" permission or ask an admin / moderator to do so." )
async def auth(self, ctx): """ Returns a link to the AllianceAuth Install Used by many other Bots and is a common command that users will attempt to run. """ await ctx.trigger_typing() embed = Embed(title="AllianceAuth") embed.set_thumbnail( url= "https://assets.gitlab-static.net/uploads/-/system/project/avatar/6840712/Alliance_auth.png?width=128" ) embed.colour = Color.blue() embed.description = "All Authentication functions for this Discord server are handled through our Alliance Auth install" regex = r"^(.+)\/d.+" matches = re.finditer(regex, settings.DISCORD_CALLBACK_URL, re.MULTILINE) for m in matches: url = m.groups() embed.add_field(name="Auth Link", value="[{}]({})".format(url[0], url[0]), inline=False) return await ctx.send(embed=embed)
async def lookup(self, ctx): """ Gets Auth data about a character Input: a Eve Character Name """ input_name = ctx.message.content[8:] char = EveCharacter.objects.get(character_name=input_name) main = char.character_ownership.user.profile.main_character state = char.character_ownership.user.profile.state.name groups = char.character_ownership.user.groups.all().values_list( 'name', flat=True) try: discord = "<@{}>".format(char.character_ownership.user.discord.uid) except: discord = "unknown" alts = char.character_ownership.user.character_ownerships.all( ).select_related('character', 'zkill').values_list( 'character__character_name', 'character__corporation_ticker', 'character__character_id', 'character__corporation_id', 'character__zkill__zk_12m', 'character__zkill__zk_3m') zk12 = 0 zk3 = 0 for alt in alts: if alt[4]: zk12 += alt[4] zk3 += alt[5] embed = Embed(title="Character Lookup") embed.colour = Color.blue() embed.description = "**{0}** is linked to **{1} [{2}]** (State: {3})".format( char, main, main.corporation_ticker, state) alt_list = [ "[{}](https://evewho.com/character/{}) *[ [{}](https://evewho.com/corporation/{}) ]*" .format(a[0], a[2], a[1], a[3]) for a in alts ] for idx, names in enumerate( [alt_list[i:i + 6] for i in range(0, len(alt_list), 6)]): if idx < 21: embed.add_field(name="Linked Characters {}".format(idx + 1), value=", ".join(names), inline=False) else: embed.add_field( name= "Linked Characters {} **( Discord Limited There are More )**" .format(idx), value=", ".join(names), inline=False) break embed.add_field(name="Groups", value=", ".join(groups), inline=False) embed.add_field(name="12m Kills", value=zk12, inline=True) embed.add_field(name="3m Kills", value=zk3, inline=True) embed.add_field(name="Discord Link", value=discord, inline=False) return await ctx.send(embed=embed)
async def jumpbridges(self, ctx): """ List all known Jumpbridges's """ embed = Embed(title=f"Known Jump Bridges") embed.colour = Color.blue() embed.description = "These do not auto populate. Please advise admins of ommisions/errors!\n\n" jbs = MapJumpBridge.objects.all().select_related( 'from_solar_system', 'to_solar_system', 'owner') for jb in jbs: embed.description += f"`{jb.from_solar_system.name}` > `{jb.to_solar_system}` [{jb.owner.name}]\n" return await ctx.send(embed=embed)
async def sg_audit(self, ctx): """ Smart Group Audit of a user Input: [group name]|[main_character] """ if ctx.message.channel.id not in settings.ADMIN_DISCORD_BOT_CHANNELS: return await ctx.message.add_reaction(chr(0x1F44E)) input_name = ctx.message.content[10:].split("|") embed = Embed( title="{group} Audit: {character_name}".format( character_name=input_name[1], group=input_name[0]) ) try: char = EveCharacter.objects.get(character_name=input_name[1]) group = Group.objects.get(name=input_name[0]) try: main = char.character_ownership.user checks = group.smartgroup.run_check_on_user(main) embed.colour = Color.blue() for c in checks: msg = c.get("message") if not msg: msg = "Pass: {}".format(c.get("check")) embed.add_field( name="{} (Pass: {})".format(c.get("filter").filter_object.description, c.get("check")), value=msg, inline=False ) return await ctx.send(embed=embed) except ObjectDoesNotExist as e: return await ctx.send("Member or Group issues") except EveCharacter.DoesNotExist: embed.colour = Color.red() embed.description = ( "Character **{character_name}** does not exist in our Auth system" ).format(character_name=input_name[1]) return await ctx.send(embed=embed)
async def route(self, ctx): """ Find route in eve with JB's """ input_names = ctx.message.content[7:].split(":") start = MapSystem.objects.get(name=input_names[0]) end = MapSystem.objects.get(name=input_names[1]) message = routes.route(start.system_id, end.system_id) dotlan_url = "https://evemaps.dotlan.net/route/{}".format( message.get("dotlan")) embed = Embed(title=f"{start.name} to {end.name}") embed.colour = Color.blue() embed.description = "Shortest Route is: {} Jumps\n\n{}".format( message.get("length"), message.get("path_message")) embed.add_field(name="Dotlan", value=f"[Route Link]({dotlan_url})") return await ctx.send(embed=embed)
async def about(self, ctx): """ All about the bot """ await ctx.trigger_typing() embed = Embed(title="AuthBot: The Authening") embed.set_thumbnail( url= "https://cdn.discordapp.com/icons/516758158748811264/ae3991584b0f800b181c936cfc707880.webp?size=128" ) embed.colour = Color.blue() embed.description = "This is a multi-de-functional discord bot tailored specifically for Alliance Auth Shenanigans." regex = r"^(.+)\/d.+" matches = re.finditer(regex, settings.DISCORD_CALLBACK_URL, re.MULTILINE) for m in matches: url = m.groups() embed.set_footer( text="Lovingly developed for Init.™ by AaronRin and ArielKable") embed.add_field(name="Number of Servers:", value=len(self.bot.guilds), inline=True) embed.add_field(name="Unwilling Monitorees:", value=len(self.bot.users), inline=True) embed.add_field(name="Auth Link", value="[{}]({})".format(url[0], url[0]), inline=False) embed.add_field(name="Version", value="{}@{}".format(__version__, __branch__), inline=False) # embed.add_field( # name="Creator", value="<@318309023478972417>", inline=False # ) return await ctx.send(embed=embed)
async def about(self, ctx): """ All about the bot """ await ctx.trigger_typing() embed = Embed(title="AuthBot: The Authening") embed.set_thumbnail( url= "https://cdn.discordapp.com/icons/713666554629455892/a4c362c2037b239f2c3ef4aeeda9375a.png?size=128" ) embed.colour = Color.blue() embed.description = "This is a multi-de-functional discord bot tailored specifically for miller cunts." regex = r"^(.+)\/d.+" matches = re.finditer(regex, settings.DISCORD_CALLBACK_URL, re.MULTILINE) for m in matches: url = m.groups() embed.set_footer( text="Lovingly developed for V0LTA.™ by Miller Thwots") embed.add_field(name="Number of Servers:", value=len(self.bot.guilds), inline=True) embed.add_field(name="Unwilling Monitorees:", value=len(self.bot.users), inline=True) embed.add_field(name="Auth Link", value="[{}]({})".format(url[0], url[0]), inline=False) embed.add_field(name="Version", value="{}@{}".format(__version__, __branch__), inline=False) # embed.add_field( # name="Creator", value="<@318309023478972417>", inline=False # ) return await ctx.send(embed=embed)
async def altcorp(self, ctx): """ Gets Auth data about an altcorp Input: a Eve Character Name """ if ctx.message.channel.id not in settings.ADMIN_DISCORD_BOT_CHANNELS: return await ctx.message.add_reaction(chr(0x1F44E)) input_name = ctx.message.content[9:] chars = EveCharacter.objects.filter(corporation_name=input_name) own_ids = [settings.DISCORD_BOT_MEMBER_ALLIANCES] alts_in_corp = [] for c in chars: if c.alliance_id not in own_ids: alts_in_corp.append(c) mains = {} for a in alts_in_corp: try: main = a.character_ownership.user.profile.main_character if main.character_id not in mains: mains[main.character_id] = [main, 0] mains[main.character_id][1] += 1 alt_corp_id = a.corporation_id except Exception as e: logger.error(e) pass output = [] base_string = "[{}]({}) [ [{}]({}) ] has {} alt{}" for k, m in mains.items(): output.append( base_string.format(m[0], evewho.character_url(m[0].character_id), m[0].corporation_ticker, evewho.corporation_url(m[0].corporation_id), m[1], "s" if m[1] > 1 else "")) for strings in [output[i:i + 10] for i in range(0, len(output), 10)]: embed = Embed(title=input_name) embed.colour = Color.blue() embed.description = "\n".join(strings) await ctx.send(embed=embed)
async def auth_slash(self, ctx): """ Returns a link to the AllianceAuth Install Used by many other Bots and is a common command that users will attempt to run. """ embed = Embed(title="AllianceAuth") embed.set_thumbnail( url= "https://assets.gitlab-static.net/uploads/-/system/project/avatar/6840712/Alliance_auth.png?width=128" ) embed.colour = Color.blue() embed.description = "All Authentication functions for this Discord server are handled through our Alliance Auth install" url = get_site_url() embed.add_field(name="Auth Link", value="[{}]({})".format(url, url), inline=False) return await ctx.respond(embed=embed)
async def lookup(self, ctx): """ Gets Auth data about a character Input: a Eve Character Name """ input_name = ctx.message.content[8:] embed = Embed(title="Character Lookup {character_name}".format( character_name=input_name)) try: char = EveCharacter.objects.get(character_name=input_name) try: main = char.character_ownership.user.profile.main_character state = char.character_ownership.user.profile.state.name groups = char.character_ownership.user.groups.all( ).values_list('name', flat=True) try: discord_string = "<@{}>".format( char.character_ownership.user.discord.uid) except Exception as e: logger.error(e) discord_string = "unknown" if aastatistics_active(): alts = char.character_ownership.user.character_ownerships.all( ).select_related('character', 'character_stats').values_list( 'character__character_name', 'character__corporation_ticker', 'character__character_id', 'character__corporation_id', 'character__character_stats__zk_12m', 'character__character_stats__zk_3m') zk12 = 0 zk3 = 0 else: alts = char.character_ownership.user.character_ownerships.all( ).select_related('character').values_list( 'character__character_name', 'character__corporation_ticker', 'character__character_id', 'character__corporation_id') zk12 = "Not Installed" zk3 = "Not Installed" if aastatistics_active(): for alt in alts: if alt[4]: zk12 += alt[4] zk3 += alt[5] embed.colour = Color.blue() embed.description = "**{0}** is linked to **{1} [{2}]** (State: {3})".format( char, main, main.corporation_ticker, state) alt_list = [ "[{}](https://evewho.com/character/{}) *[ [{}](https://evewho.com/corporation/{}) ]*" .format(a[0], a[2], a[1], a[3]) for a in alts ] for idx, names in enumerate( [alt_list[i:i + 6] for i in range(0, len(alt_list), 6)]): if idx < 6: embed.add_field( name="Linked Characters {}".format(idx + 1), value=", ".join(names), inline=False) else: embed.add_field( name= "Linked Characters {} **( Discord Limited There are More )**" .format(idx), value=", ".join(names), inline=False) break if len(groups) > 0: embed.add_field(name="Groups", value=", ".join(groups), inline=False) if aastatistics_active(): embed.add_field(name="12m Kills", value=zk12, inline=True) embed.add_field(name="3m Kills", value=zk3, inline=True) embed.add_field(name="Discord Link", value=discord_string, inline=False) return await ctx.send(embed=embed) except ObjectDoesNotExist: users = char.ownership_records.values('user') users = User.objects.filter(id__in=users) characters = EveCharacter.objects.filter( ownership_records__user__in=users).distinct() embed = Embed(title="Character Lookup") embed.colour = Color.blue() embed.description = "**{0}** is Unlinked searching for any characters linked to known users".format( char, ) user_names = ["{}".format(user.username) for user in users] embed.add_field(name="Old Users", value=", ".join(user_names), inline=False) alt_list = [ "[{}](https://evewho.com/character/{}) *[ [{}](https://evewho.com/corporation/{}) ]*" .format(a.character_name, a.character_id, a.corporation_ticker, a.corporation_id) for a in characters ] for idx, names in enumerate( [alt_list[i:i + 6] for i in range(0, len(alt_list), 6)]): if idx < 6: embed.add_field(name="Found Characters {}".format(idx + 1), value=", ".join(names), inline=False) else: embed.add_field( name= "Found Characters {} **( Discord Limited There are More )**" .format(idx), value=", ".join(names), inline=False) break return await ctx.send(embed=embed) except EveCharacter.DoesNotExist: embed.colour = Color.red() embed.description = ( "Character **{character_name}** does not exist in our Auth system" ).format(character_name=input_name) return await ctx.send(embed=embed)