def iegut():

    while True:
        system("clear")
        print(start2)
        izvele = input("Opcijas izvēle..")
        if izvele == "1":
            print("")
            for i in db.keys():
                print(f"""* {i} *
Personas kods: {db[i][0]}
Summa: {db[i][1]}$
Atdošanas dat.: {db[i][2]}
""")
            input("Nospied Enter lai turpinātu..")
        elif izvele == "2":
            now = datetime.now()
            now2 = now.strftime("%d/%m/%Y")
            b = datetime.strptime(now2, format)
            ir = 0
            for i in db.keys():
                a = datetime.strptime(db[i][2], format)
                if a < b:
                    c = str(a - b)
                    kav = c.split()[:2]
                    ir = 1
                    print(f"""
* {i} *
Personas kods: {db[i][0]}
Summa: {db[i][1]}$
Kavējums: {' '.join(kav)}
""")
            if ir == 0:
                print("Neviens ieraksts netika atrasts")
            input("Nospied Enter lai turpinātu..")
        elif izvele == "3":
            vards = input("Lūdzu norādiet meklētās personas vārdu uzvārdu: ")
            if db.prefix(vards):
                for i in db.prefix(vards):
                    print(f"""
* {i} *
Personas kods: {db[i][0]}
Summa: {db[i][1]}$
Atdošanas dat.: {db[i][2]}
""")
            else:
                print("Persona ar tādu vārdu netika atrasta")
            input("Nospied Enter lai turpinātu..")
        elif izvele == "4":
            break
Example #2
0
async def on_message(message):
    if message.author == client.user:
        return

    if message.content.startswith('$hello'):
        await message.channel.send('potato')

    if message.content.startswith('$iam '):
        splitMessage = message.content.split('-')
        if len(splitMessage) < 2:
            await message.channel.send("you're potato, invalid command")
            return
        player = Player(message.author, splitMessage[1].strip(),
                        splitMessage[2].strip())
        db[get_user_db_key(message.author)] = player.get_user_db_value()
        await message.channel.send(
            "registered @{0} with player name {1}".format(
                message.author, player.name))

    if message.content.startswith('$myguild '):
        data = message.content.split('-')
        guild = Guild(data[1].strip(), data[2].strip())
        player = Player(message.author)
        player.add_guild_to_player(guild)
        guild.add_player_to_guild(player)

    if message.content.startswith('$whatsmyguild'):
        player = Player(message.author)
        player_guild = db[player.get_player_guild_key()]
        await message.channel.send(player_guild)

    if message.content.startswith('$registerguild'):
        data = message.content.split('-')
        guild = Guild(data[1].strip(), data[2].strip())

        result = guild.register_guild_in_db()
        await message.channel.send(result)

    if message.content.startswith('$guilds'):

        matches = db.prefix("guild")
        await message.channel.send(matches)

    if message.content.startswith('$guildreports'):
        data = message.content.split('-')
        guild = Guild(data[1].strip(), data[2].strip())

        result = guild.get_new_guild_reports()
        if (not result):
            await message.channel.send("couldn't find new reports dummy")
        else:
            report_id = result[0]["id"]
            await message.channel.send(
                "Analysis for {0}: https://xivanalysis.com/fflogs/{1}".format(
                    guild.name, report_id))

    if message.content.startswith('$guildmembers'):
        data = message.content.split('-')
        guild = Guild(data[1].strip(), data[2].strip())
        await message.channel.send(db[guild.get_guild_members_key()])
Example #3
0
def get_stat(value):
    clean_db(db)
    stats = {'lose': 0, 'victory': 0}
    if value == 'month':
        date = datetime.datetime.now()
        keys = db.prefix(str(date.month) + str(date.year))
        for key in keys:
            for key_ in db[key].keys():
                stats[key_] += db[key][key_]
        winrate = int(stats['victory']) / \
            (int(stats['victory']) + int(stats['lose']))
        return f'''Your stats for this month:
    - Victories: {stats['victory']}
    - Loses: {stats['lose']}
    - Winrate: {round(winrate, 2) * 100} %
    '''
    else:
        key = get_key()
        if key in db.keys():
            for key_ in db[key]:
                stats[key_] += db[key][key_]
            winrate = int(stats['victory']) / \
                (int(stats['victory']) + int(stats['lose']))
            return f'''Your stats for this day:
        - Victories: {stats['victory']}
        - Loses: {stats['lose']}
        - Winrate: {round(winrate, 2) * 100} %
        '''
        else:
            return 'You haven\'t stats today'
Example #4
0
    def get_all():

        insults_dict = {}
        for key in db.prefix('insult_'):
            insults_dict[utils.remove_prefix('insult', key)] = db[key]

        return insults_dict
    def get_all():

        names_dict = {}
        for key in db.prefix('name_'):
            names_dict[utils.remove_prefix('name', key)] = db[key]

        return names_dict
Example #6
0
    async def on_raw_reaction_add(self, payload):
        if not payload.member.bot:
            # Check if the reaction is on a role menu message and only proceed if so
            isMenuReaction = False
            for key in db.prefix("ID For Menu"):
                if payload.message_id == db[key]:
                    isMenuReaction = True
                    menuName = key[12:]

            if payload.emoji is discord.Emoji:
                emoji = self.client.get_emoji(payload.emoji.id)
            else:
                emoji = str(payload.emoji)

            if isMenuReaction and (emoji in db["Emojis For Menu " + menuName]):
                # Fetch the necessary info for changing the user's roles
                guild = self.client.get_guild(payload.guild_id)
                user = payload.member
                index = (db["Emojis For Menu " + menuName]).index(emoji)
                addRole = guild.get_role(db["Role IDs For Menu " +
                                            menuName][index])

                # Follow the correct course-of-action based on the role menu type
                if db["Type For Menu " + menuName] == "single":
                    for otherRoleID in db["Role IDs For Menu " + menuName]:
                        otherRole = guild.get_role(otherRoleID)
                        if otherRole in user.roles:
                            await user.remove_roles(otherRole)

                await user.add_roles(addRole)
    def name_in_message(message):

        name_keys = db.prefix('name_')

        for key in name_keys:
            if db[key].lower() in message.lower():

                return db[key]
Example #8
0
def find_matches(prefix: str) -> None:
    """List all keys that match the given prefix."""
    matches = list(database.prefix(prefix))

    if matches:
        click.echo(success(f"Matches found for '{prefix}':\n"))
        click.echo("\n".join(matches))
    else:
        click.echo(failure(f"No matches found for '{prefix}'"))
Example #9
0
def db_test():
    db["key1"] = name
    db["key2"] = street
    db["number"] = number
    keys = db.keys()
    matches = db.prefix("n")
    print(matches)
    value = db["name"]
    print(value)
    value2 = db["number"]
    print(value2)
Example #10
0
def list_spoiler_channels(server_id):
    all_autospoiled = False
    channels = []
    server_options = db.prefix(server_id)
    for server_option in server_options:
        sections = server_option.split('_')
        if sections[1] + "_" + sections[2] == "autospoilering_all" and db[
                server_option] == "True":
            all_autospoiled = True
        if sections[2] == "autospoilering" and db[server_option] == "True":
            channels.append(sections[1])
    return channels, all_autospoiled
Example #11
0
    def add_insult(insult):

        insults = list(db.prefix('insult_'))

        biggest_id = 0
        for item in insults:
            id = int(utils.remove_prefix('insult', item))

            if biggest_id < id:
                biggest_id = id

        db["insult_" + str(biggest_id + 1)] = insult
        return "L'ajout de : " + insult + " a fonctionné !"
    def add_name(name):

        names = list(db.prefix('name_'))

        biggest_id = 0
        for item in names:
            id = int(utils.remove_prefix('name', item))

            if biggest_id < id:
                biggest_id = id

        db["name_" + str(biggest_id + 1)] = name
        return "L'ajout de : " + name + " a fonctionné !"
Example #13
0
def delete_spoiler_channels(server_id, channel, all_channels):
    if all_channels == True:
        server_options = db.prefix(server_id)
        if f"{server_id}_autospoilering_all" in db.keys():
            db[f"{server_id}_autospoilering_all"] = "False"
        for server_option in server_options:
            sections = server_option.split('_')
            if sections[2] == "autospoilering":
                db[server_option] = "False"
    else:
        if f"{server_id}_autospoilering_all" in db.keys():
            db[f"{server_id}_autospoilering_all"] = "False"
        if f"{server_id}_{channel}_autospoilering" in db.keys():
            db[f"{server_id}_{channel}_autospoilering"] = "False"
Example #14
0
def levels():
    users = db.prefix(f"level_")
    userArray = []
    levels = ''
    i = 0
    if len(users) > 0:
        for element in users:
            userLvl = db[element]
            userID = element.replace(f"level_", "")
            userArray.append({"user": f'{userID}', "lvl": userLvl})

        def get_my_key(obj):
            return obj['lvl']

        userArray.sort(key=get_my_key)
        userArray.reverse()
        for element in userArray:
            person = client.get_user(int(element["user"]))
            i += 1
            xp = element['lvl']
            nextInt = int(xp / 1000 + 1) * 1000
            leftNext = nextInt - xp
            thisLevelXp = 1000 - leftNext
            if (client.get_user(int(element['user'])) != None):

                person = client.get_user(int(element['user'])).name + '%23____'
                member = client.get_user(int(element['user']))
                try:
                    xpcolor = db[f'cardXp_{element["user"]}']
                except:
                    xpcolor = 'ff4085'

                try:
                    bgcolor = db[f'cardBg_{element["user"]}']
                except:
                    bgcolor = None
                levels += f'''
                    
                        <center>
                        <img width=800 src='https://vacefron.nl/api/rankcard?username={person}&avatar={client.get_user(int(element['user'])).avatar_url}&level={int(xp/1000)}+++++++++++++Rank+{i}&rank=&currentxp={thisLevelXp}&nextlevelxp=1000&previouslevelxp=0&custombg={bgcolor}&xpcolor={xpcolor}&isboosting=false'>
                        </center>
                        
<br><br><br><br>

                        '''
    page = render_template('levels.html')
    style = render_template('style.css')
    return page.format(style=style, levels=levels)
Example #15
0
    def __init__(self, client):
        self.client = client

        # Gives this cog the attributes needed for the auto help command.
        self.parameters = [
            "<@user> <reason>", "<numOfMessages>", "<@user> <reason>",
            "<@user>", "<@user> <reason>"
        ]

        self.shortDescs = [
            "Allows mods to vote-ban a user.",
            "Deletes specified number of messages.",
            "Allows mods and admins to anonymously warn a user.",
            "Allows admins to reset a user's warnings.",
            "Allows anyone to report a user for a reason."
        ]

        self.longDescs = [
            "Opens a poll for mods and admins to vote as to whether or not the specified user should be banned. After 30 minutes, the poll will close and, if there is a majority approval, the user in question will be banned. In all other instances, the user will not be banned.",
            "Mass-deletes the specified number of messages from the channel in which the command was sent. The amount of messages that can be deleted is limited to your server status. Mods may purge only 10 messages at a time, admins up to 25, and owners up to 50 for safety.",
            "Sends an anonymous warning embed to the user's DMs that includes the server where the warning originated, how many warnings they have currently received, and what they were warned for.",
            "Resets the specified user's warning count back to 0.",
            "Allows any user to report another user for the given reason. If the user in question is a normal member, the report will be sent to mods and admins. If the user is a mod or admin, the report will only be sent to the owners' DMs"
        ]

        self.paramDescs = [
            "`<@user>` Ping the user or include their exact user name and 4-digit ID number.\n`<reason>` The reason for the ban.",
            "`<numOfMessages>` The number of messages you'd like to delete.",
            "`<@user>` Ping the user or include their exact user name and 4-digit ID number.\n`<reason>` The reason for the warning.",
            "`<@user>` Ping the user or include their exact user name and 4-digit ID number.",
            "`<@user>` Ping the user or include their exact user name and 4-digit ID number.\n`<reason>` The reason for reporting the user."
        ]

        self.restrictions = [
            "Only mods", "Only members of power", "Only members of power",
            "Only admins", "Anyone"
        ]

        # Reset all pending bans
        for pendingBan in db.prefix("Ban Pending For "):
            db[pendingBan] = False
Example #16
0
    async def on_raw_reaction_remove(self, payload):
        if True:
            # Check if the reaction is on a role menu message and only proceed if so
            isMenuReaction = False
            for key in db.prefix("ID For Menu"):
                if payload.message_id == db[key]:
                    isMenuReaction = True
                    menuName = key[12:]

            if payload.emoji is discord.Emoji:
                emoji = self.client.get_emoji(payload.emoji.id)
            else:
                emoji = str(payload.emoji)

            if (isMenuReaction and
                (emoji in db["Emojis For Menu " + menuName])) and (
                    db["Persist For Menu " + menuName] == "no"):
                # Fetch the necessary info for changing the user's roles
                guild = self.client.get_guild(payload.guild_id)
                user = guild.get_member(payload.user_id)
                index = (db["Emojis For Menu " + menuName]).index(emoji)
                removeRole = guild.get_role(db["Role IDs For Menu " +
                                               menuName][index])

                # Follow the correct course-of-action based on whether the role should persist
                otherRolesSelected = False
                channel = guild.get_channel(payload.channel_id)
                roleMenu = await channel.fetch_message(payload.message_id)
                for reaction in roleMenu.reactions:
                    reactionUsers = await reaction.users().flatten()
                    if (reaction.emoji in db["Emojis For Menu " +
                                             menuName]) and (user
                                                             in reactionUsers):
                        otherRolesSelected = True

                if not otherRolesSelected:
                    for roleID in db["Role IDs For Menu " + menuName]:
                        await user.remove_roles(guild.get_role(roleID))
                else:
                    await user.remove_roles(removeRole)
def kont_mekl(meklet):
    sakrit_elementi = db.prefix(meklet)
    return {k: db[k] for k in sakrit_elementi}
Example #18
0
def deleteAllUsers():
    users = db.prefix("")
    for i in range(0, len(users)):
        del db[users[i]]
        print("Successfully deleted user: "******"NumberOfUsers"] = "-1"
Example #19
0
    def send_insult(name):
        insult_keys = db.prefix('insult_')

        selected_insult = insult_keys[randint(0, len(insult_keys) - 1)]
        return db[selected_insult].replace('#', name.upper())
Example #20
0
def search_contacts(search):
    match_keys = db.prefix(search)
    return {k: db[k] for k in match_keys}
Example #21
0
import socket
import sys
import os
from time import sleep
import random
from replit import db
db["key"] = "value"
value = db["key"]
del db["key"]
keys = db.keys()
matches = db.prefix("prefix")
os.system("clear")
red = "\033[31m"
green = "\033[32m"
yellow = "\033[33m"
blue = "\033[34m"
purple = "\033[35m"
cyan = "\033[36m"
white = "\033[37m"
ksmk = 0
print(
    red, """
     __/)     (\__
  ,-'~~(   _   )~~`-.
 /      \/'_`\/      \
|       /_(_)_\       |
|     _(/(\_/)\)_     |
|    / // \ / \\ \    |
 \  | ``  / \ ''  |  /
  \  )   /   \   (  /
   )/   /     \   \(
Example #22
0
from replit import db
db["admin_id"] = "1024"
ask = input("Enter your ID: ")
lol = db["admin_id"]
keys = db.keys()
matches = db.prefix("admin_id")
print(keys)
print(matches)
Example #23
0
async def getAllRecordsForUser(key: str):
  """"Returns all values that start with the same str"""
  return db.prefix(key)