Example #1
0
    def save_data(self):
        try:
            mongo_address = os.getenv('MONGO_ADDRESS')
            db_name = os.getenv('DATABASE_NAME')
            collection = 'clubs'

            database = Database(mongo_address, db_name)

            data = Crawler.extract_data(self)

            if data != None:
                data['club_id'] = self.id
                data['club']['slug'] = TreatData.slugify(
                    data['club']['team_name'])

                now = datetime.now()
                now = now.strftime("%Y-%m-%d %H:%M:%S")
                data['created_at'] = now

                # if data['club']['address']:
                if 'address' in data['club'].keys():
                    club_geo_data = GeoData(data['club']['address'])
                    data['club']['geo_data'] = club_geo_data.get_lat_long()

                if 'name' in data['stadium'].keys():
                    stadium_geo_data = GeoData(data['stadium']['name'])
                    data['stadium'][
                        'geo_data'] = stadium_geo_data.get_lat_long()

                return database.save_not_exists(data, collection)
        except Exception:
            return None
Example #2
0
def messages():
    messages = Database().get_messages('abc')
    res = []
    for msg in messages:
        res.append(msg.dict())
    enable_corss()
    return json.dumps(res)
Example #3
0
    async def sleep(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        reply = [
            f"Go to sleep okay, <@{ctx.author.id}>? ***SMACKS***",
            f"What now, <@{ctx.author.id}>? Sleep? Okay..",
            f"To be honest with you, <@{ctx.author.id}>. " +
            "I don't think I can sle-",
            f"Good night, <@{ctx.author.id}>. *closes eyes*"
        ]
        msg = await ctx.send(random.choice(reply))

        # Bot reacts with salt
        msg = await msg.reply("Z")
        await asyncio.sleep(1)
        await msg.edit(content=f"{msg.content}z")
        await asyncio.sleep(1)
        await msg.edit(content=f"{msg.content}z")
        await asyncio.sleep(1)
        await msg.edit(content=f"{msg.content}.")
        await asyncio.sleep(1)
        await msg.edit(content=f"{msg.content}.")
        await asyncio.sleep(1)
Example #4
0
    async def feedback(self, ctx, *feedback):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        db_ailie.disconnect()

        if feedback:
            # Process complain
            feedback = " ".join(feedback)
            await self.notifyOwner(ctx, feedback, "agree")

            official_server = False
            if ctx.guild.id == int(os.getenv("GUILD_ID")):
                official_server = True

            if not official_server:
                await ctx.send(f"Ding dong, <@{ctx.author.id}>! " +
                               "Your message has been logged. " +
                               "You might wanna join Ailie's server " +
                               "so you can resolve issues and " +
                               "keep updated on Ailie's updated. " +
                               "If so, then do `a;server`.")
            else:
                await ctx.send(f"Ding dong, <@{ctx.author.id}>! " +
                               "Your message has been logged. ")
        else:
            await ctx.send("Can't send anything since you put no messages!")
Example #5
0
    async def pressF(self, ctx, mention: discord.Member):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Check if receiver is initialized
        if not db_ailie.is_initialized(mention.id):
            await ctx.send(f"Tell {mention.mention} to initialize first!")
            db_ailie.disconnect()
            return

        reply = [
            f"Pay respect to the fallen member, {mention.mention}..",
            f"Be strong, {mention.mention}.",
            f"*Believing is the key, {mention.mention}..*",
            f"Never stop trying. You're not alone, {mention.mention}!",
            f"{mention.mention}, keep fighting!",
            f"Sending support to {mention.mention}. From yours truly, " +
            f"<@{ctx.author.id}>.",
        ]
        msg = await ctx.send(random.choice(reply))

        db_ailie.disconnect()

        # Bot reacts with 'F'
        await msg.add_reaction("🇫")
Example #6
0
    async def punish(self, ctx, type, mention: discord.Member):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Check if receiver is initialized
        if not db_ailie.is_initialized(mention.id):
            await ctx.send(f"{mention.mention} haven't initialized yet.")
            db_ailie.disconnect()
            return

        if type.lower() == "toxic":
            negative_gems = -999999999999999999
            db_ailie.store_gems(mention.id, negative_gems)
            msg = await ctx.send(
                f"<@{mention.id}> you have been kicked down to the bottom " +
                "of the toxic pool as that is where you belong to. " +
                "You must've made my Creator mad or something. " +
                "Serve you right! ")
            await asyncio.sleep(1)
            await msg.reply(f"`{negative_gems:,d}` gems for you!")
Example #7
0
    async def create(self, ctx, guild_name):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Create a random Guild ID until there is no duplicate
        guild_check = True
        guild_id = 0

        while guild_check:
            guild_id = random.randint(pow(10, 14), (pow(10, 15) - 1))
            guild_check = db_ailie.guild_exists(guild_id)

        # Guild creation if and only if the user is guildless
        if not db_ailie.is_guildless(ctx.author.id):
            await ctx.send(
                "I don't think you should be creating a guild when you " +
                f"already have one. No, <@{ctx.author.id}>?")
            db_ailie.disconnect()
            return

        # Finally, create guild after all checks is done
        db_ailie.create_guild(ctx.author.id, "Guild Master", guild_id,
                              guild_name)
        await ctx.send(
            f"Congratulations, <@{ctx.author.id}>! You have created " +
            f"a Guild named, `{guild_name}` with the ID, `{guild_id}`.")

        db_ailie.disconnect()
Example #8
0
def timed_job():
    mongo_address = os.getenv('MONGO_ADDRESS')
    db_name = os.getenv('DATABASE_NAME')
    collection = 'team_id'

    database = Database(mongo_address, db_name)

    id = Database.get_team_id()

    url = f'https://uk.soccerway.com/teams/spain/futbol-club-barcelona/{id}'

    item = Crawler(url, id)
    saved_item = item.save_data()

    query = {"id": id}

    if saved_item != None:
        if type(saved_item) is dict:
            print(saved_item['error'])
            data = {"$set": {"status": "crawled"}}
            Database.update(data, query, collection)
        else:
            print(f'Created {id} as {saved_item}')
            data = {"$set": {"status": "crawled"}}
            Database.update(data, query, collection)
    else:
        print(f'{id} not found')
        data = {"$set": {"status": "not found"}}
        Database.update(data, query, collection)
Example #9
0
 def __init__(self):
     self.data = DataProvider()
     self.luis = Luis()
     self.db = Database()
     self.poi = [
         'city center', 'theatre', 'supermarket', 'cinema', 'museum'
     ]
Example #10
0
def places():
    places = Database().get_places('abc')
    res = []
    for msg in places:
        res.append(msg.__dict__)
    enable_corss()
    return json.dumps(res)
Example #11
0
 def __init__(self, player: dict = {}):
     self._db = Database()
     self.id = player['id'] if 'id' in player else self._db.get_next_id('player')
     self.last_name = player['last_name'] if 'last_name' in player else ''
     self.first_name = player['first_name'] if 'first_name' in player else ''
     self.dob = player['dob'] if 'dob' in player else ''
     self.gender = player['gender'] if 'gender' in player else ''
     self.ranking = int(player['ranking']) if 'ranking' in player else ''
Example #12
0
    async def initialize(self, ctx):
        db_ailie = Database()

        if db_ailie.initialize_user(ctx.author.id):
            await ctx.send(
                "You can now use the other commands, "
                + f"<@{ctx.author.id}>. Have fun!"
            )
        else:
            await ctx.send(
                f"You are already initialized, <@{ctx.author.id}>. "
                + "No need to initialize for the second time. Have fun!"
            )
Example #13
0
    async def server(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        db_ailie.disconnect()

        await ctx.send("Here's the link to Ailie's server, " +
                       f"<{os.getenv('SERVER_INVITE')}>.")
Example #14
0
    async def ping(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        db_ailie.disconnect()

        await ctx.send(
            f"Pong, <@{ctx.author.id}>! Sending back this message with " +
            f"{round(self.bot.latency * 1000)}ms latency.")
Example #15
0
    async def username(self, ctx, username):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        db_ailie.set_username(ctx.author.id, username)
        await ctx.send(
            f"Your username is now, {username}. Enjoy, <@{ctx.author.id}>."
        )

        db_ailie.disconnect()
Example #16
0
    async def version(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        db_ailie.disconnect()

        # Change upon version update
        version = "1.10.1"

        await ctx.send(f"Hello, <@{ctx.author.id}>! " +
                       f"My current version is `{version}`!")
Example #17
0
    async def team_show(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        teams = db_ailie.get_all_teams(ctx.author.id)

        embed = discord.Embed(color=discord.Color.purple())
        embed.set_author(
            icon_url=ctx.author.avatar_url, name=ctx.author.name
        )

        output = ""
        for team in teams:
            for t in team[1]:
                hero_name = db_ailie.get_hero_name_from_id(t)
                if hero_name is not None:
                    if team[1].index(t) == 0:
                        output = f"`{hero_name}`"
                    else:
                        output = output + "\n" + f"`{hero_name}`"

            embed.add_field(name=team[0], value=output, inline=False)

        if len(teams) == 0:
            embed.add_field(name="Teams", value="None", inline=False)

        await ctx.send(embed=embed)
        if not isinstance(ctx.channel, discord.channel.DMChannel):
            await ctx.send(
                "Busted, now the others can see what heroes are in your team. "
                + "Easy counter on arena. Next time, be smart and send me "
                + f"a Private Message instead, <@{ctx.author.id}>."
            )
Example #18
0
    async def team(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return
        db_ailie.disconnect()

        msg = await ctx.send(
            f"Time to explain.. Hey, <@{ctx.author.id}>, "
            + "you better read properly. *tsk*"
        )
        await asyncio.sleep(1)
        await msg.reply(
            "Issue `a;team set <key> <hero;hero;hero;hero>` "
            + "to set team."
            + "\nIssue `a;team show` to show team set."
            + "\nIssue `a;team delete` to delete a team."
        )
Example #19
0
    async def bless(self, ctx, type, mention: discord.Member):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Check if receiver is initialized
        if not db_ailie.is_initialized(mention.id):
            await ctx.send(f"{mention.mention} haven't initialized yet.")
            db_ailie.disconnect()
            return

        if type.lower() == "gems":
            positive_gems = 500000
            db_ailie.store_gems(mention.id, positive_gems)
            msg = await ctx.send(
                f"<@{mention.id}> you are recognized by my Creator.")
            await asyncio.sleep(1)
            await msg.reply(f"`{positive_gems:,d}` gems for you!")
Example #20
0
    async def team_delete(self, ctx, key: str):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        exist = db_ailie.is_team_exists(ctx.author.id, key)

        if not exist:
            await ctx.send(
                "Are you sure they key is correct?"
            )
            db_ailie.disconnect()
            return

        db_ailie.delete_team(ctx.author.id, key)
        await ctx.send(
            f"Deleted your team with `{key}` key, <@{ctx.author.id}>."
        )
Example #21
0
    async def quit(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Condition checks
        if not db_ailie.is_guildless(ctx.author.id):
            guild_id = db_ailie.get_guild_id_of_member(ctx.author.id)
            guild_master = db_ailie.get_guild_master(guild_id)
            total_members = db_ailie.total_members(guild_id)
            if total_members != 1:
                if ctx.author.id == guild_master:
                    await ctx.send(
                        "You're the Guild Master and you want to run away from "
                        + f"your responsibilities, <@{ctx.author.id}>? " +
                        "Sorry, but NO!")
                    db_ailie.disconnect()
                    return
                else:
                    db_ailie.quit_guild(ctx.author.id)
                    await ctx.send(f"You're solo now, <@{ctx.author.id}>.")
            else:
                db_ailie.quit_guild(ctx.author.id)
                db_ailie.disband_guild(guild_id)
                await ctx.send(f"You're solo now, <@{ctx.author.id}>.")

        else:
            await ctx.send(
                "Can't quit a Guild when you don't even have one, " +
                f"<@{ctx.author.id}>.")

        db_ailie.disconnect()
Example #22
0
 def __init__(self, tournament: dict = {}):
     self._db = Database()
     self.nb_players = 8
     if tournament and 'id' in tournament:
         self.id = tournament['id']
         existing_tournament = self.get_tournament(self.id)[0][0]
         self.players = existing_tournament['players'] or []
         self.matches = []
         self.rounds = existing_tournament['rounds'] or {}
         self.time_control = existing_tournament['time_control'] or 'bullet'
         self.description = existing_tournament['description'] or None
         self.name = existing_tournament['name'] or None
         self.location = existing_tournament['location'] or tournament['location']
         self.date = existing_tournament['date'] or tournament['date']
     else:
         self.id = None
         self.players = []
         self.matches = []
         self.rounds = {}
         self.time_control = 'bullet'
         self.description = None
         self.name = None
         self.location = None
         self.date = None
Example #23
0
    async def pourSalt(self, ctx, mention: discord.Member):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Check if receiver is initialized
        if not db_ailie.is_initialized(mention.id):
            await ctx.send(f"{mention.mention} haven't initialized yet.")
            db_ailie.disconnect()
            return

        db_ailie.disconnect()

        reply = [
            f"*Pours salt on {mention.mention}.. POURING INTENSIFIED!*",
            f"{mention.mention}, get wrecked in mountains of salt!",
            f"THIS IS FOR GETTING LUCKY, {mention.mention}! TAKE ALL THE " +
            "SALT. TAKE IT!",
            "No one is allowed to get this lucky! Especially you, " +
            f"{mention.mention}!",
            f"*Pours multiple bottles of salt at {mention.mention}.*",
            f"Sending boxes of salt to {mention.mention}. " +
            f"From yours truly, <@{ctx.author.id}>.",
            f"<@{ctx.author.id}> wishes there's no cooldown to this command " +
            f"just to keep spamming salt to you, {mention.mention}. HAHA.",
            f"EVERYONE! Come spam salt to, {mention.mention}!",
        ]
        msg = await ctx.send(random.choice(reply))

        # Bot reacts with salt
        await msg.add_reaction("🧂")
Example #24
0
from helpers.database import Database
import os
from dotenv import load_dotenv
from datetime import datetime

load_dotenv(verbose=True)

mongo_address = os.getenv('MONGO_ADDRESS')
db_name = os.getenv('DATABASE_NAME')
collection = 'team_id'

initial = 9999
final = 20000

now = datetime.now()
now = now.strftime("%Y-%m-%d %H:%M:%S")

database = Database(mongo_address, db_name)

for id in range(int(initial), int(final)):
    exists = Database.connection[f'{collection}'].find_one({"id": id})
    if (exists == None):
        data = {"id": id, "status": "created", "created_at": now}
        print(Database.save(data, collection))
    else:
        print(f'{id} already created')
Example #25
0
    async def join(self, ctx, guild_id: int):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Get Guild Master
        guild_master = db_ailie.get_guild_master(guild_id)

        if db_ailie.is_guildless(ctx.author.id):
            if db_ailie.guild_exists(guild_id):
                # Check if guild is full
                if db_ailie.total_members(guild_id) >= 30:
                    await ctx.send(
                        f"The guild is full. Sorry, <@{ctx.author.id}>.")
                    db_ailie.disconnect()
                    return

                # Check if Guild Master is in the Discord Server
                discord_server = self.bot.get_guild(ctx.message.guild.id)
                if not discord_server.get_member(guild_master):
                    await ctx.send("You must be in the same Discord Server " +
                                   "as the Guild Master.")
                    db_ailie.disconnect()
                    return

                # Get Guild details
                guild_name = db_ailie.get_guild_name(guild_id)

                # Get Guild Master's confirmation
                await ctx.send(
                    f"<@{guild_master}>, please choose to accept or decline " +
                    f"<@{ctx.author.id}>'s application to " +
                    f"`{guild_name}`#`{guild_id}` with `Y` or `N`.")

                # Function to confirm application
                def confirm_application(message):
                    return (message.author.id == guild_master and
                            message.content.upper() in ["YES", "Y", "NO", "N"])

                # Wait for Guild Master's confirmation
                try:
                    msg = await self.bot.wait_for("message",
                                                  check=confirm_application,
                                                  timeout=30)

                    # Application accepted
                    if msg.content.upper() in ["YES", "Y"]:
                        db_ailie.join_guild(ctx.author.id, "Member", guild_id)
                        await ctx.send(
                            f"Welcome to `{guild_name}`#`{guild_id}`, " +
                            f"<@{ctx.author.id}>!")
                    else:
                        # Application rejected else:
                        await ctx.send(
                            f"Application denied! Sorry, <@{ctx.author.id}>..")
                except Exception:
                    await ctx.send(
                        "Looks like your application got ignored, " +
                        f"<@{ctx.author.id}>. Ouch!")
            else:
                await ctx.send("The guild you mentioned does not exist.")
        else:
            guild_name = db_ailie.get_guild_name(guild_id)
            await ctx.send(
                "Aren't you a very loyal person? You are already " +
                f"in `{guild_name}`#`{guild_id}`! No, <@{ctx.author.id}>?")

        db_ailie.disconnect()
Example #26
0
    async def guild(self, ctx):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        if not db_ailie.is_guildless(ctx.author.id):
            # Get guild name to present in output
            guild_name = db_ailie.get_guild_name_of_member(ctx.author.id)
            members_output = [[], [], []]

            # Get all the members
            members = db_ailie.get_members_list(ctx.author.id)
            structured_member = ""
            for member in members:
                structured_member = (structured_member +
                                     f"`{self.bot.get_user(member[0])}` ")
                if member[1] is not None:
                    structured_member = (structured_member +
                                         f" a.k.a. `{member[1]}` ")

                if member[2] == "Guild Master":
                    members_output[0].append(structured_member)
                elif member[2] == "Elder":
                    members_output[1].append(structured_member)
                else:
                    members_output[2].append(structured_member)

                structured_member = ""

            # Finally send the list
            embed = discord.Embed(color=discord.Color.purple(), )
            embed.set_author(icon_url=self.bot.user.avatar_url,
                             name=guild_name)
            embed.add_field(
                name="Guild Master 🎓",
                value="".join(members_output[0]),
                inline=False,
            )

            if len(members_output[1]) == 0:
                members_output[1].append("None")

            if len(members_output[2]) == 0:
                members_output[2].append("None")

            embed.add_field(
                name="Elders 👴",
                value="\n".join(members_output[1]),
                inline=False,
            )
            embed.add_field(
                name="Members 🧍",
                value="\n".join(members_output[2]),
                inline=False,
            )
            await ctx.send(embed=embed)
        else:
            await ctx.send("You can't list your Guild members if you're " +
                           f"not in a Guild, <@{ctx.author.id}>.")

        db_ailie.disconnect()
Example #27
0
    async def promote(self, ctx, mention: discord.Member, *position):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Initialize variables
        position = " ".join(position)
        position = position.title()

        # Check if author has a guild
        if db_ailie.is_guildless(ctx.author.id):
            await ctx.send(f"You're not even in a Guild, <@{ctx.author.id}>!")
            db_ailie.disconnect()
            return

        # Check if author is Guild Master
        guild_id = db_ailie.get_guild_id_of_member(ctx.author.id)
        guild_master = db_ailie.get_guild_master(guild_id)
        if ctx.author.id != guild_master:
            await ctx.send("You're not privileged to change positions of " +
                           f"other members, <@{ctx.author.id}>.")
            db_ailie.disconnect()
            return

        # Abort command upon changing own position
        if guild_master == mention.id:
            await ctx.send(
                f"Can't change your own position, <@{ctx.author.id}>!")
            db_ailie.disconnect()
            return

        # Check position
        if position.lower() not in ["guild master", "elder", "member"]:
            await ctx.send(
                "The position you entered is invalid. For now, only " +
                "Guild Master, Elder, and Member is available.")
            db_ailie.disconnect()
            return
        else:
            # Check if in the same guild
            guardian_one = db_ailie.get_guild_id_of_member(mention.id)
            guardian_two = db_ailie.get_guild_id_of_member(ctx.author.id)
            if guardian_one == guardian_two:
                if position.lower() == "guild master":
                    # Ask for confirmation to change Guild Master
                    await ctx.send(
                        "Are you sure you want to transfer " +
                        f"Guild Master to {mention.mention}? Reply with " +
                        "`Y` or `N` to confirm.")

                    # Function to confirm promotion to Guild Master
                    def confirm_application(message):
                        return (message.author.id == ctx.author.id
                                and message.content.upper()
                                in ["YES", "Y", "NO", "N"])

                    try:
                        msg = await self.bot.wait_for(
                            "message", check=confirm_application, timeout=30)
                        if msg.content.upper() in ["YES", "Y"]:
                            await ctx.send(
                                "Transferring Guild Master position now..")
                            db_ailie.change_position(guild_master, "Member")
                            db_ailie.change_position(mention.id, position)
                            await ctx.send(
                                f"Changed position of {mention.mention} to " +
                                f"{position}.")
                        else:
                            await ctx.send("Aborting Guild Master transfer!")
                    except Exception:
                        await ctx.send("Timeout!")
                        db_ailie.disconnect()
                        return
                else:
                    db_ailie.change_position(mention.id, position)
                    await ctx.send(
                        f"Changed position of {mention.mention} to {position}."
                    )
            else:
                await ctx.send(
                    "Do it again. But mention someone in your Guild!")

        db_ailie.disconnect()
Example #28
0
 def __init__(self):
     self._db = Database(Env_Vars["database"]["host"], Env_Vars["database"]["user"], Env_Vars["database"]["password"], "test")
     #db.create_database("test")
     #db.check_database_exist("test")
     coloumns = "id INT AUTO_INCREMENT PRIMARY KEY, mykey VARCHAR(255),long_url VARCHAR(255)"
     self._db.create_table("mytable", coloumns)
Example #29
0
from nlp.model.tm.lda import LDA
from nlp.model.tm.sentiment_lda import SentimentLDA

warnings.simplefilter("ignore")

pp = pprint.PrettyPrinter(indent=4)

tenants = [
    'master_large_demo', 'vision6', 'fujitsu', 'f5mgroup', 'sheldon',
    'plantminer', 'q4financial'
]

results = Results()

for tenant in tenants:
    database = Database(tenant)
    tenantName = database.getName()

    print(f'Processing {tenantName}...')

    database.process()
    ratingTexts = database.getRatingTexts()

    for ratingText in ratingTexts:
        (ratings, paragraphs) = database.getData(ratingText)

        if len(paragraphs) < 5:
            continue

        result = Result(tenantName, ratingText['formDesignName'], paragraphs)
Example #30
0
    async def profile(self, ctx, mention: discord.Member = None):
        # Check if user is initialized first
        db_ailie = Database()
        if not db_ailie.is_initialized(ctx.author.id):
            await ctx.send(
                "Do `ailie;initialize` or `a;initialize` first before anything!"
            )
            db_ailie.disconnect()
            return

        # Check if person mentioned is initialized
        if mention:
            if not db_ailie.is_initialized(mention.id):
                await ctx.send(f"{mention.mention} is not initialized yet!")
                db_ailie.disconnect()
                return

        if mention is None:
            guardian_id = ctx.author.id
            guardian_name = ctx.author.name
            guardian_avatar = ctx.author.avatar_url
        else:
            guardian_id = mention.id
            guardian_name = mention.name
            guardian_avatar = mention.avatar_url

        # Get all information needed for a profile show off
        username, guild_name, position, gems = db_ailie.get_guardian_info(
            guardian_id
        )
        trophies = db_ailie.get_trophy(guardian_id)
        guild_id = db_ailie.get_guild_id_of_member(guardian_id)
        heroes_obtained = db_ailie.hero_inventory(guardian_id)
        equips_obtained = db_ailie.equip_inventory(guardian_id)
        user_exp = db_ailie.get_user_exp(guardian_id)
        user_level = db_ailie.get_user_level(guardian_id)
        summon_count = db_ailie.get_summon_count(guardian_id)

        # Set embed baseline
        embed = discord.Embed(color=discord.Color.purple())
        embed.set_author(
            name=f"Lvl {user_level}/500 {guardian_name}'s Profile",
            icon_url=guardian_avatar
        )

        # Username, gems, and trophies
        embed.add_field(name="Username 📝", value=f"`{username}`", inline=False)
        embed.add_field(
            name="User EXP 💪", value=f"`{user_exp:,d}`", inline=False)
        embed.add_field(name="Gems 💎", value=f"`{gems:,d}`")
        embed.add_field(name="Trophies 🏆", value=f"`{trophies:,d}`")

        # Total unique and epic exclusive
        heroes_equips_count = (
            "**Summon Count**: "
            + f"`{summon_count:,d}`"
            + "\n**Unique Heroes**: "
            + f"`{len(heroes_obtained[len(heroes_obtained) - 1])}`"
            + "\n**Epic Exclusive Equipments**: "
            + f"`{len(equips_obtained[len(equips_obtained) - 1])}`"
        )
        embed.add_field(
            name="Summons⚔️",
            value=heroes_equips_count,
            inline=False
        )

        # Guild details
        guild_detail = (
            f"**Guild Name**: `{guild_name}`"
            + f"\n**Guild ID**: `{guild_id}`"
            + f"\n**Position**: `{position}`"
        )
        embed.add_field(
            name="Guild Details 🏠",
            value=guild_detail,
            inline=False,
        )

        db_ailie.disconnect()

        await ctx.send(embed=embed)