Example #1
0
    async def randomimgin(self, ctx, room_name):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        room = functions.get_room_json(room_name)
        if room:

            embed = discord.Embed(
                colour=discord.Colour.orange(),
                description=
                f"<a:spinning:804022054822346823> Loading >10,000 pictures taken in `^{room['Name']}`, and picking one randomly..."
            )
            functions.embed_footer(ctx, embed)
            loading = await ctx.send(embed=embed)

            room_photos = functions.get_photos_in_room(room_name)
            if room_photos:
                random_photo = room_photos[random.randint(
                    0,
                    len(room_photos) - 1)]

                embed = functions.image_embed(random_photo)
            else:
                embed = functions.error_msg(
                    ctx,
                    f"Not a single picture has been taken in `^{room['Name']}`"
                )
        else:
            embed = functions.error_msg(ctx,
                                        f"Room `^{room_name}` doesn't exist!")

        await loading.delete()
        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(f"Random image in `^{room['Name']}`", embed=embed)
Example #2
0
    async def clear_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            embed = functions.error_msg(ctx, "Please include in an username!")

            await ctx.send(embed=embed)
        else:
            pass
Example #3
0
    async def clear_error(self, ctx, error):
        if isinstance(error, commands.MissingRequiredArgument):
            embed = functions.error_msg(
                ctx,
                "Please include in an username and room!\nUsage: `.randomimgofin <user> <room>`"
            )

            await ctx.send(embed=embed)
        else:
            pass
Example #4
0
    async def randomimgofin(self, ctx, profile, room_name):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        account = functions.check_account_existence_and_return(profile)
        if account:
            profile = account['username']
            room = functions.get_room_json(room_name)
            if room:
                photos = functions.id_to_feed(account['account_id'])

                if photos:
                    found_photos = []
                    # find photos in room
                    for photo in photos:
                        if photo['RoomId'] == room['RoomId']:
                            found_photos.append(photo)

                    if found_photos:
                        random_photos = found_photos[random.randint(
                            0,
                            len(found_photos) - 1)]

                        embed = functions.image_embed(random_photos)
                    else:
                        embed = functions.error_msg(
                            ctx,
                            f"User `@{account['username']}` doesn't appear in `^{room['Name']}`!"
                        )
                else:
                    embed = functions.error_msg(
                        ctx,
                        f"User `@{profile}` doesn't appear in `^{room_name}` at all!"
                    )
            else:
                embed = functions.error_msg(
                    ctx, f"Room `^{room_name}` doesn't exist!")
        else:
            embed = functions.error_msg(ctx,
                                        f"User `@{profile}` doesn't exist!")

        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(f"Random image of `@{profile}`, in `^{room['Name']}`",
                       embed=embed)
Example #5
0
    async def randomimgof(self, ctx, profile):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        account = functions.check_account_existence_and_return(profile)
        if account:
            profile = account['username']
            feed = functions.id_to_feed(account['account_id'])

            if feed:
                random_feed = feed[random.randint(0, len(feed) - 1)]

                embed = functions.image_embed(random_feed)
            else:
                embed = functions.error_msg(
                    ctx, f"User `@{profile}` doesn't appear in any post!")
        else:
            embed = functions.error_msg(ctx,
                                        f"User `@{profile}` doesn't exist!")

        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(f"Random image of `@{profile}`", embed=embed)
Example #6
0
    async def randomimgby(self, ctx, profile):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        account = functions.check_account_existence_and_return(profile)
        if account:
            profile = account['username']
            photos = functions.id_to_photos(account['account_id'])

            if photos:
                random_photos = photos[random.randint(0, len(photos) - 1)]
                embed = functions.image_embed(random_photos)

            else:
                embed = functions.error_msg(
                    ctx,
                    f"User `@{account['username']}` hasn't shared a single post!"
                )
        else:
            embed = functions.error_msg(ctx,
                                        f"User `@{profile}` doesn't exist!")

        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(f"Random image by `@{profile}`", embed=embed)
Example #7
0
    async def eventsearch(self, ctx, word):
        functions.log(ctx.guild.name, ctx.author, ctx.command)
        keyword = str(word)
        if len(keyword) < 2:
            embed = functions.error_msg(
                ctx, "Keyword must be at least 2 characters long!")
            await ctx.send(embed=embed)
        else:
            events_found = functions.event_search(keyword)

            embed = discord.Embed(
                colour=discord.Colour.orange(),
                title=f"Events found with keyword \"{keyword}\"",
            )

            events = 0
            if events_found:
                for event in events_found:
                    if (functions.contains_word(event['Name'], keyword)
                            or functions.contains_word(event['Description'],
                                                       keyword)):
                        description = event['Description']
                        if not description:
                            description = "None"

                        events += 1

                        embed.add_field(
                            name=event['Name'],
                            value=
                            f"**[\"{event['Name']}\"](https://rec.net/event/{event['PlayerEventId']})** | [`{functions.id_to_display_name(event['CreatorPlayerId'])}`](https://rec.net/user/{functions.id_to_username(event['CreatorPlayerId'])})```{description}```👥 Attending: `{event['AttendeeCount']}`\n\n~~~~~~~~~~",
                            inline=False)

            if not events:
                embed.add_field(
                    name="None!",
                    value=
                    f"Couldn't find any event that contains the word `{keyword}`",
                    inline=False)

            functions.embed_footer(ctx,
                                   embed)  # get default footer from function
            await ctx.send(embed=embed)
Example #8
0
def Reload(DATE, INDEX_ID, CALENDAR_ID):
    #Getting Required requests
    QUE = "select * from d_dailydatareq where INDEX_ID = {0}"
    Q = QUE.format(INDEX_ID)

    con = ms.connect("127.0.0.1", "root", "123456789+", "epic_trust_vvr")
    Meas = pd.read_sql(Q, con=con)
    con.close()

    Meas = Meas.drop(columns={"SLNO", "VALID_FLAG"})  # Dropping serial Number
    #Seperating Request Types
    CA_REQ = Meas[Meas["FIELD"] == 'CA']
    PRICE_REQ = Meas[Meas["FIELD"] == 'PX_SETTLE']
    CURR_REQ = Meas[Meas["FIELD"] == 'CURR']
    #Fetching data for corresponding Request types.
    #CA IMPORT. Currenty only looking for dividends.
    if (len(CA_REQ) > 0):
        r_data = CA_DATALOAD(DATE).rename(columns={'IDENTIFIER': 'ISIN'})
        CA_dat = pd.merge(CA_REQ[['ISIN']],
                          r_data,
                          on='ISIN',
                          how='left',
                          left_index=False,
                          right_index=False)
        CA_dat = CA_dat[[
            "ACTION_ID", "CORPORATE_ACTION", "COUNTRY_CODE", "CURRENCY",
            "DATAPROVIDER", "EX_DATE", "ISIN", "IDENTIFIER_NAME",
            "MODIFY_DATE", "NAME", "SYMBOL", "TICKER", 'VALUES'
        ]]

        CA_dat = CA_dat.dropna()
        try:
            if CA_dat.empty != 1:
                CA_dat = CA_dat[CA_dat['CORPORATE_ACTION'] == 'DVD_CASH']
                up_pack = CA_dat['VALUES']
                up_pack.index = CA_dat['ISIN']
                #CA_dat.index = CA_dat['ISIN']

                tr = pd.DataFrame(up_pack)
                tr2 = pd.DataFrame()
                for i in range(len(tr)):
                    R1 = tr.iloc[i]
                    sd = R1.values.tolist()
                    r1 = DataFrame.from_records(sd[0])
                    tr1 = r1.set_index('name').T
                    x = tr1[[
                        'CP_GROSS_AMT', 'Frequency', 'Paydate', 'CP_DVD_TYP',
                        'Recdate'
                    ]]
                    tr2 = pd.concat([tr2, x]).reset_index()
                    tr2.loc[i, 'ISIN'] = R1.name
                    #tr2['ISIN'] =  R1.name
                #tr2['ISIN']  = CA_dat['ISIN']#CA_dat.index
                tr2 = tr2.drop(columns={'index', 'level_0'})
                CA_dat_f = pd.merge(CA_dat,
                                    tr2,
                                    on='ISIN',
                                    how='inner',
                                    left_index=False,
                                    right_index=False)
                CA_dat_f = CA_dat_f.rename(columns={
                    'Recdate': 'Record_date',
                    'Paydate': 'PAYMENT_DATE'
                })
                CA_dat_f.columns = map(str.upper, CA_dat_f.columns)
                CA_dat_f['TICKER'] = CA_dat_f['TICKER'].str.upper()
                CA_dat_f = CA_dat_f[[
                    "TICKER", "ISIN", "EX_DATE", "CORPORATE_ACTION",
                    "CP_GROSS_AMT", "CURRENCY", "RECORD_DATE", "PAYMENT_DATE",
                    "DATAPROVIDER", "CP_DVD_TYP", "FREQUENCY"
                ]]
                vals = CA_dat_f.values.tolist()
                d_ca_DATALOAD(vals)
                TICK = list(CA_dat_f['TICKER'].unique())
                pa.Period_Divisor(DATE, TICK, CALENDAR_ID, INDEX_ID)

        except Exception as e:
            s = repr(e)
            con = ms.connect("127.0.0.1", "root", "123456789+",
                             "epic_trust_vvr")
            cursor = con.cursor()
            vals = [exec_time, 'Reload_Func', str(INDEX_ID), s, 'N']
            cursor.execute(
                "insert into d_run_exceptions (Runtimeid, Job_Failed, Index_ID, Error_Message, Resolution_Found) values (%s,%s,%s,%s,%s);",
                vals)
            con.commit()
            con.close()
            func.error_msg(s, 'CA not fulfilled.')

    #PRICE IMPORT
    if (len(PRICE_REQ) > 0):
        r_data = PRICE_DATALOAD(DATE)
        PRICE_dat = pd.merge(PRICE_REQ[['ISIN', 'TICKER', 'FIELD']],
                             r_data[['ISIN', 'DATE', 'PRICE']],
                             on='ISIN',
                             how='left',
                             left_index=False,
                             right_index=False)
        PRICE_dat['DATA_SOURCE'] = 'BLOOMBERG'
        PRICE_dat = PRICE_dat.drop(columns={"ISIN"})
        PRICE_dat = PRICE_dat[[
            'DATE', 'TICKER', 'FIELD', 'PRICE', 'DATA_SOURCE'
        ]]
        PRICE_dat = PRICE_dat.dropna()
        PRICE_dat['TICKER'] = PRICE_dat['TICKER'].str.upper()
        vals = PRICE_dat.values.tolist()
        d_price_DATALOAD(vals)

    #CURR IMPORT
    if (len(CURR_REQ) > 0):
        r_data = CURR_DATALOAD(DATE).rename(
            columns={'CURRENCY_TICKER': 'TICKER'})
        CURR_dat = pd.merge(CURR_REQ[['TICKER', 'FIELD']],
                            r_data[['TICKER', 'DATE', 'PRICE']],
                            on='TICKER',
                            how='left',
                            left_index=False,
                            right_index=False)
        CURR_dat['DATA_SOURCE'] = 'BLOOMBERG'
        CURR_dat = CURR_dat[[
            'DATE', 'TICKER', 'FIELD', 'PRICE', 'DATA_SOURCE'
        ]]
        CURR_dat['TICKER'] = CURR_dat['TICKER'].str.upper()
        vals = CURR_dat.values.tolist()
        d_price_DATALOAD(vals)
Example #9
0
    async def cringebiocheck(self, ctx, profile):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        account = functions.check_account_existence_and_return(profile)
        if account:
            bio = functions.get_bio(account['account_id'])
            pfp = functions.id_to_pfp(account['account_id'], True)

            print(
                f"{ctx.command} > {account['account_id']}, {account['username']}, {bio}, {pfp}"
            )

            embed = functions.default_embed()
            embed.add_field(name=f"{account['username']}'s bio:",
                            value=f"```{bio}```")

            flags = ""
            cringe_check_list = functions.load("cringe_word_list.json")
            cringe_score = 0
            cringe_rating_dict = {
                0: "Not cringe!",
                1: "A little cringe!",
                2: "Cringe!",
                3: "Very cringe!",
                4: "Yikes..!",
                5: "Radically cringe!",
                6: "Super cringe!",
                7: "Mega cringe!",
                8: "Ultra cringe!",
                9: "THE CRINGIEST!",
                10: "All hope for humanity has been lost!"
            }

            if bio:
                split_bio = bio.split(" ")
                for word in split_bio:
                    for flag in cringe_check_list:
                        if flag.casefold() in word.casefold():
                            cringe_score += 1
                            flags += f"`{flag}`, "

                if cringe_score > len(cringe_rating_dict) - 1:
                    cringe_rating = cringe_rating_dict[len(cringe_rating_dict)
                                                       - 1]
                else:
                    cringe_rating = cringe_rating_dict[cringe_score]

                embed.add_field(name="Cringe score",
                                value=f"`{cringe_score}` ({cringe_rating})",
                                inline=False)

                if flags:
                    embed.add_field(
                        name="Flags",
                        value=
                        f"||{flags}||\nThis command is just for fun, and not meant to shame anybody!",
                        inline=False)

            embed.set_author(name=f"🔗 {account['username']}'s profile",
                             url=f"https://rec.net/user/{account['username']}",
                             icon_url=pfp)
        else:
            embed = functions.error_msg(ctx,
                                        f"User `@{profile}` doesn't exist!")

        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(embed=embed)
Example #10
0
    async def cringenamecheck(self, ctx, profile):
        functions.log(ctx.guild.name, ctx.author, ctx.command)

        account = functions.check_account_existence_and_return(profile)
        if account:
            embed = functions.default_embed()

            cringe_check_list = functions.load("cringe_word_list.json")
            cringe_score = 0
            cringe_rating = {
                0: "Not cringe!",
                1: "Maybe a little cringe?",
                2: "Little cringe.",
                3: "A bit cringe!",
                4: "Cringe!",
                5: "Quite cringe!",
                6: "Very cringe!",
                7: "Super cringe!",
                8: "Incredibly cringe!",
                9: "Ludicrously cringe!",
                10: "THE CRINGIEST!"
            }

            display_name = functions.id_to_display_name(account['account_id'])
            cringe_words = [
                ele for ele in cringe_check_list
                if (ele.casefold() in display_name.casefold())
            ]
            cringe_score = len(cringe_words) * 2

            for char in display_name:
                if not char.isalpha():
                    cringe_score += 1
                    cringe_words.append(char)

            if cringe_score > 10:
                cringe_score = 10

            embed.add_field(name=f"{account['username']}'s display name:",
                            value=f"```{display_name}```")
            embed.add_field(
                name="Cringe score",
                value=f"`{cringe_score}` ({cringe_rating[cringe_score]})",
                inline=False)

            flags = ""
            for flag in cringe_words:
                flags += f"`{flag}`, "

            if flags:
                embed.add_field(
                    name="Flags",
                    value=
                    f"||{flags}||\nThis command is just for fun, and not meant to shame anybody!",
                    inline=False)

            pfp = functions.id_to_pfp(account['account_id'], True)
            embed.set_author(name=f"🔗 {account['username']}'s profile",
                             url=f"https://rec.net/user/{account['username']}",
                             icon_url=pfp)
        else:
            embed = functions.error_msg(ctx,
                                        f"User `@{profile}` doesn't exist!")

        functions.embed_footer(ctx, embed)  # get default footer from function
        await ctx.send(embed=embed)
Example #11
0
                    msg, user_auth_public_key)

                if sig_verified:
                    print("The signature is authentic")
                    pwmsg_parts = pwmsg.split("|".encode())
                    uid = pwmsg_parts[0]

                    USER_PATH = user_path_dic.get(uid.decode())

                    ts = pwmsg_parts[2]
                    pwd_hash = SHA256.new(pwmsg_parts[1])
                    if not functions.is_timestamp_valid(
                            time.time(), float(ts)):
                        print("Timestamp error")
                        error_msg = functions.error_msg(
                            "Timestamp error", user_enc_public_key,
                            server_auth_privatekey)

                        netif.send_msg(CLIENT, error_msg)
                        status, msg = netif.receive_msg(blocking=False)
                        serverauth = False
                        continue
                    else:
                        with open('server_machine/info.json') as json_file:
                            data = json.load(json_file)
                            # check the user ID exists
                            valid_header = "VALID|".encode()
                            if pwmsg_parts[0].decode() in data:
                                # check password
                                if pwd_hash.hexdigest() == data[
                                        uid.decode()].lower():