示例#1
0
async def pls_googleimages(ctx, text, results):  # noqa: C901
    if words(text) == False:
        result = googleSearchImages(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        await ctx.send("Results:")
        await asyncio.sleep(1)
        for x in range(0, results):
            if words(alphabet[x]) == False:
                await ctx.channel.send(alphabet[x])
                await asyncio.sleep(1)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?hl=en&tbm=isch&sxsrf=ALeKk01Eh6GNz2vJrxJ-7rB-HY2SE-4xJQ%3A1615321310276&source=hp&biw=1366&bih=657&ei=3thHYNbEDpLZ-gSE-b6oCg&q={}&oq={}&gs_lcp=CgNpbWcQAzIFCAAQsQMyBQgAELEDMgUIABCxAzICCAAyBQgAELEDMgIIADIFCAAQsQMyBQgAELEDMgIIADIFCAAQsQM6BwgjEOoCECc6BAgjECc6CAgAELEDEIMBUOaYC1jTmwtgzJ0LaAFwAHgAgAFiiAHcAZIBATOYAQCgAQGqAQtnd3Mtd2l6LWltZ7ABCg&sclient=img&ved=0ahUKEwjWq5TnhKTvAhWSrJ4KHYS8D6UQ4dUDCAc&uact=5'.format(
                query, query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    elif ctx.channel.is_nsfw() == True:
        result = googleSearchImages(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        await ctx.send("Results:")
        await asyncio.sleep(1)
        for x in range(0, results):
            if words(alphabet[x]) == False:
                await ctx.channel.send(alphabet[x])
                await asyncio.sleep(1)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?hl=en&tbm=isch&sxsrf=ALeKk01Eh6GNz2vJrxJ-7rB-HY2SE-4xJQ%3A1615321310276&source=hp&biw=1366&bih=657&ei=3thHYNbEDpLZ-gSE-b6oCg&q={}&oq={}&gs_lcp=CgNpbWcQAzIFCAAQsQMyBQgAELEDMgUIABCxAzICCAAyBQgAELEDMgIIADIFCAAQsQMyBQgAELEDMgIIADIFCAAQsQM6BwgjEOoCECc6BAgjECc6CAgAELEDEIMBUOaYC1jTmwtgzJ0LaAFwAHgAgAFiiAHcAZIBATOYAQCgAQGqAQtnd3Mtd2l6LWltZ7ABCg&sclient=img&ved=0ahUKEwjWq5TnhKTvAhWSrJ4KHYS8D6UQ4dUDCAc&uact=5'.format(
                query, query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    else:
        await ctx.send("You can only search NSFW things in an NSFW channel.")
示例#2
0
async def pls_google(ctx, text, results):  # noqa: C901
    if words(text) == False:
        result = googleSearch(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        await ctx.send("Results:")
        await asyncio.sleep(1)
        for x in range(0, results):
            if words(alphabet[x]) == False:
                await ctx.channel.send(alphabet[x])
                await asyncio.sleep(1)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?client=ubuntu&channel=fs&q={}&ie=utf-8&oe=utf-8'.format(
                query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    elif ctx.channel.is_nsfw() == True:
        result = googleSearch(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        await ctx.send("Results:")
        await asyncio.sleep(1)
        for x in range(0, results):
            if words(alphabet[x]) == False:
                await ctx.channel.send(alphabet[x])
                await asyncio.sleep(1)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?client=ubuntu&channel=fs&q={}&ie=utf-8&oe=utf-8'.format(
                query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    else:
        await ctx.send("You can only search NSFW things in an NSFW channel.")
示例#3
0
async def new_response(ctx, message):
    if words(message) == False:
        update_encouragements(message)
        await ctx.send(f'New encouraging message added: {message}')
        await responses_list(ctx)
    else:
        await ctx.add_reaction('<:no:828741445069963274>')
示例#4
0
async def pls_define(ctx, word):  # noqa: C901
    if words(word) == False:
        dictionary = PyDictionary()
        try:
            defined = dictionary.meaning(f"{word}")
            if defined.get('Noun', 99) != 99:
                bye1 = defined['Noun']
                await ctx.send("Noun meaning(s):")
                for i in range(0, len(bye1)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye1[i]}")
            if defined.get('Verb', 99) != 99:
                bye2 = defined['Verb']
                await ctx.send("Verb meaning(s):")
                for i in range(0, len(bye2)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye2[i]}")
            if defined.get('Pronoun', 99) != 99:
                bye3 = defined['Pronoun']
                await ctx.send("Pronoun meaning(s):")
                for i in range(0, len(bye3)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye3[i]}")
            if defined.get('Adjective', 99) != 99:
                bye4 = defined['Adjective']
                await ctx.send("Adjective meaning(s):")
                for i in range(0, len(bye4)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye4[i]}")
            if defined.get('Adverb', 99) != 99:
                bye5 = defined['Adverb']
                await ctx.send("Adverb meaning(s):")
                for i in range(0, len(bye5)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye5[i]}")
            if defined.get('Preposition', 99) != 99:
                bye6 = defined['Preposition']
                await ctx.send("Preposition meaning(s):")
                for i in range(0, len(bye6)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye6[i]}")
            if defined.get('Conjunction', 99) != 99:
                bye7 = defined['Conjunction']
                await ctx.channel.send("Conjunction meaning(s):")
                for i in range(0, len(bye7)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye7[i]}")
            if defined.get('Interjection', 99) != 99:
                bye8 = defined['Interjection']
                await ctx.channel.send("Interjection meaning(s):")
                for i in range(0, len(bye8)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye8[i]}")
            if defined.get('Numeral', 99) != 99:
                bye9 = defined['Numeral']
                await ctx.channel.send("Numeral meaning(s):")
                for i in range(0, len(bye9)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye9[i]}")
            if defined.get('Article', 99) != 99:
                bye10 = defined['Article']
                await ctx.send("Article meaning(s):")
                for i in range(0, len(bye10)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye10[i]}")
            if defined.get('Determiner', 99) != 99:
                bye11 = defined['Determiner']
                await ctx.send("Determiner meaning(s):")
                for i in range(0, len(bye11)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye11[i]}")
            else:
                pass
        except Exception:
            await ctx.send(f"`{word.capitalize()}` is not in this dictionary.")
    elif ctx.channel.is_nsfw() == True:
        dictionary = PyDictionary()
        try:
            defined = dictionary.meaning(f"{word}")
            if defined.get('Noun', 99) != 99:
                bye1 = defined['Noun']
                await ctx.send("Noun meaning(s):")
                for i in range(0, len(bye1)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye1[i]}")
            if defined.get('Verb', 99) != 99:
                bye2 = defined['Verb']
                await ctx.send("Verb meaning(s):")
                for i in range(0, len(bye2)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye2[i]}")
            if defined.get('Pronoun', 99) != 99:
                bye3 = defined['Pronoun']
                await ctx.send("Pronoun meaning(s):")
                for i in range(0, len(bye3)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye3[i]}")
            if defined.get('Adjective', 99) != 99:
                bye4 = defined['Adjective']
                await ctx.send("Adjective meaning(s):")
                for i in range(0, len(bye4)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye4[i]}")
            if defined.get('Adverb', 99) != 99:
                bye5 = defined['Adverb']
                await ctx.send("Adverb meaning(s):")
                for i in range(0, len(bye5)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye5[i]}")
            if defined.get('Preposition', 99) != 99:
                bye6 = defined['Preposition']
                await ctx.send("Preposition meaning(s):")
                for i in range(0, len(bye6)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye6[i]}")
            if defined.get('Conjunction', 99) != 99:
                bye7 = defined['Conjunction']
                await ctx.channel.send("Conjunction meaning(s):")
                for i in range(0, len(bye7)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye7[i]}")
            if defined.get('Interjection', 99) != 99:
                bye8 = defined['Interjection']
                await ctx.channel.send("Interjection meaning(s):")
                for i in range(0, len(bye8)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye8[i]}")
            if defined.get('Numeral', 99) != 99:
                bye9 = defined['Numeral']
                await ctx.channel.send("Numeral meaning(s):")
                for i in range(0, len(bye9)):
                    await asyncio.sleep(1)
                    await ctx.send(f"{i+1}. {bye9[i]}")
            if defined.get('Article', 99) != 99:
                bye10 = defined['Article']
                await ctx.send("Article meaning(s):")
                for i in range(0, len(bye10)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye10[i]}")
            if defined.get('Determiner', 99) != 99:
                bye11 = defined['Determiner']
                await ctx.send("Determiner meaning(s):")
                for i in range(0, len(bye11)):
                    await asyncio.sleep(1)
                    await ctx.channel.send(f"{i+1}. {bye11[i]}")
            else:
                pass
        except Exception:
            await ctx.send(f"`{word.capitalize()}` is not in this dictionary.")
    else:
        await ctx.send("You can only send NSFW things in NSFW channels.")
示例#5
0
async def pls_translate(ctx, text, output_lang, input_lang):
    if words(text) == False:
        if input_lang == None:
            try:
                output_lang2 = output_lang
                translator = Translator()
                translated = translator.translate(text, dest=output_lang2)
                await ctx.send(f"{translated.text}")
            except Exception as e:
                print(str(e))
                await ctx.send("ERROR")
                await ctx.send(
                    "Make sure that your output_lang is one of these:")
                await ctx.send(f"{LANGUAGES}")
        else:
            try:
                output_lang2 = output_lang
                input_lang2 = input_lang
                translator = Translator()
                translated = translator.translate(text,
                                                  src=input_lang2,
                                                  dest=output_lang2)
                await ctx.send(f"{translated.text}")
            except Exception as e:
                print(str(e))
                await ctx.send("ERROR")
                await ctx.send(
                    "Make sure that your output_lang or input_lang is one of these:"
                )
                await ctx.send(f"{LANGUAGES}")
    elif ctx.channel.is_nsfw() == True:
        if input_lang == None:
            try:
                output_lang2 = output_lang
                translator = Translator()
                translated = translator.translate(text, dest=output_lang2)
                await ctx.send(f"{translated.text}")
            except Exception as e:
                print(str(e))
                await ctx.send("ERROR")
                await ctx.send(
                    "Make sure that your output_lang is one of these:")
                await ctx.send(f"{LANGUAGES}")
        else:
            try:
                output_lang2 = output_lang
                input_lang2 = input_lang
                translator = Translator()
                translated = translator.translate(text,
                                                  src=input_lang2,
                                                  dest=output_lang2)
                await ctx.send(f"{translated.text}")
            except Exception as e:
                print(str(e))
                await ctx.send("ERROR")
                await ctx.send(
                    "Make sure that your output_lang or input_lang is one of these:"
                )
                await ctx.send(f"{LANGUAGES}")
    else:
        await ctx.send("You can only search NSFW things in an NSFW channel.")
示例#6
0
async def pls_google(ctx, text, results):  # noqa: C901
    if words(text) == False:
        result = googleSearch(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        embed = discord.Embed(colour=discord.Colour.orange())
        for x in range(0, results):
            if words(alphabet[x]) == False:
                response = requests.get(alphabet[x])
                soup = BeautifulSoup(response.text, features="lxml")
                metas = soup.find_all('meta')
                try:
                    title = str(soup.title.string)
                except:
                    title = "[]"
                description = str([
                    meta.attrs['content'] for meta in metas
                    if 'name' in meta.attrs
                    and meta.attrs['name'] == 'description'
                ])
                if title == "[]":
                    titleadd = False
                else:
                    titleadd = True
                if description == "[]":
                    descadd = False
                else:
                    description = description[2:]
                    description = description[:-2]
                    descadd = True
                if titleadd == True and descadd == True:
                    embed.add_field(name=f"{title}",
                                    value=f"[{description}]({alphabet[x]})",
                                    inline=False)
                elif titleadd == True and descadd == False:
                    embed.add_field(name=f"{title}",
                                    value=f"[No description]({alphabet[x]})",
                                    inline=False)
                elif titleadd == False and descadd == True:
                    embed.add_field(name="No title",
                                    value=f"[{description}]({alphabet[x]})",
                                    inline=False)
                else:
                    embed.add_field(name="No title",
                                    value=f"[No details]({alphabet[x]})",
                                    inline=False)
                # await ctx.channel.send(alphabet[x])
                # await asyncio.sleep(1)
        await ctx.send(embed=embed)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?client=ubuntu&channel=fs&q={}&ie=utf-8&oe=utf-8'.format(
                query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    elif ctx.channel.is_nsfw() == True:
        result = googleSearch(text)
        results = int(results)
        try:
            a, b, c, d, e, f, g, h, i, j = result
            alphabet = [a, b, c, d, e, f, g, h, i, j]
        except:
            a, b, c, d, e, f, g, h, i = result
            alphabet = [a, b, c, d, e, f, g, h, i]
        if results > 10:
            await ctx.send("Results must be between 1 and 10")
            return False
        embed = discord.Embed(colour=discord.Colour.orange())
        for x in range(0, results):
            if words(alphabet[x]) == False:
                response = requests.get(alphabet[x])
                soup = BeautifulSoup(response.text, features="lxml")
                metas = soup.find_all('meta')
                try:
                    title = str(soup.title.string)
                except:
                    title = "[]"
                description = str([
                    meta.attrs['content'] for meta in metas
                    if 'name' in meta.attrs
                    and meta.attrs['name'] == 'description'
                ])
                if title == "[]":
                    titleadd = False
                else:
                    titleadd = True
                if description == "[]":
                    descadd = False
                else:
                    description = description[2:]
                    description = description[:-2]
                    descadd = True
                if titleadd == True and descadd == True:
                    embed.add_field(name=f"{title}",
                                    value=f"[{description}]({alphabet[x]})",
                                    inline=False)
                elif titleadd == True and descadd == False:
                    embed.add_field(name=f"{title}",
                                    value=f"[No description]({alphabet[x]})",
                                    inline=False)
                elif titleadd == False and descadd == True:
                    embed.add_field(name="No title",
                                    value=f"[{description}]({alphabet[x]})",
                                    inline=False)
                else:
                    embed.add_field(name="No title",
                                    value=f"[No details]({alphabet[x]})",
                                    inline=False)
                # await ctx.channel.send(alphabet[x])
                # await asyncio.sleep(1)
        await ctx.send(embed=embed)
        query = text.replace(" ", "+")
        if "http" not in query:
            url = 'https://www.google.com/search?client=ubuntu&channel=fs&q={}&ie=utf-8&oe=utf-8'.format(
                query)
        else:
            url = query
        if words(url) == False:
            await ctx.channel.send(f"URL: {url}")
    else:
        await ctx.send("You can only search NSFW things in an NSFW channel.")