コード例 #1
0
def quotes_jessica(a):
	if str(a) == "Inspire" or str(a) == "inspire":
		y = ['life','happiness','success','love','family','dedication','work','hard work','friends','lucky']
		z = random.choice(y)
		print( wikiquote.quotes(z,max_quotes = 1) )
		pyt.say( wikiquote.quotes(z,max_quotes = 1) )

	elif str(a) == "quotes" or str(a) == "Quotes":
		pyt.say("Search quote about:")
		y = input(">>>")
		print( wikiquote.quotes(y,max_quotes = 1) )
		pyt.say( wikiquote.quotes(y,max_quotes = 1) )
	
	
	elif str(a) == "Quote" or str(a) == "quote" :	
		print( wikiquote.quote_of_the_day())
		pyt.say( wikiquote.quote_of_the_day() )

	#elif str(a) == "Random" or str(a) == "random":
	#	y = ['life','happiness','success','love','family','dedication','work','hard work','friends','lucky']
	#	z = random.choice(y)
	#	print( wikiquote.quotes(z,max_quotes = 1) )
	#	pyt.say( wikiquote.quotes(z,max_quotes = 1) )
	else:
		
		pyt.say("Quotes not found")
コード例 #2
0
def home(request):
    str = wikiquote.quote_of_the_day()
    quote = str[0]
    author = str[1]
    html = "<html><center><h1>Quote of the day</h1></center><br><h2>%s</h2><br><div align='right'><h3>Author : %s</h3></div></html>" % (
        quote, author)
    return HttpResponse(html)
コード例 #3
0
ファイル: test_qotd.py プロジェクト: federicotdn/wikiquote
def test_qotd_author(lang):
    if lang == "pt":
        pytest.skip()

    _, author = wikiquote.quote_of_the_day(lang=lang)
    assert isinstance(author, str)
    assert len(author) > 0
コード例 #4
0
def do_quote():
    while True:
        quote_list = []
        print(
            "\n\nHello wise internet user, so you want to brew some good quotes!"
            "Choose the options we can serve u now:\n"
            "1.  Quote of the Day\n"
            "2.  Search the keyword you wish to see quotes on ( a movie, an author, anything)\n"
            "3.  Show some random titles to search quotes on\n"
            "4.  Just show some random quotes ( in case u r in a hurry)\n")

        choice = int(input("Enter your Choice: "))
        print()
        if choice == 1:
            qOtD = []
            qOtD = list(wikiquote.quote_of_the_day())
            print("\n{} \n \t\t\t --{}".format(qOtD[0], qOtD[1]))
            break

        elif choice == 2:
            search_result = []
            srch_txt = input("Enter the keyword you wish to search: ")
            search_result = list(wikiquote.search(srch_txt))
            if search_result:
                print("\nEnter the item number you wish to see a quote on: \n")
                for x, item in enumerate(search_result, 1):
                    print("{}.    {}".format(x, item))
                srch_choice = int(input())
                srch_strng = search_result[srch_choice - 1]
                quote_list = list(wikiquote.quotes(srch_strng, max_quotes=5))
                print()
                for i, item in enumerate(quote_list, 1):
                    print("{}.   {}\n".format(i, item))
                break

            else:
                print("no quotes on that! try again.....")

        elif choice == 3:
            rand_ttls = list(wikiquote.random_titles(max_titles=5))
            print("\nEnter the item number you wish to see a quote on: \n")
            for i, item in enumerate(rand_ttls, 1):
                print("{}.  {}".format(i, item))
            srch_choice = int(input())
            srch_strng = rand_ttls[srch_choice - 1]
            quote_list = list(wikiquote.quotes(srch_strng, max_quotes=5))
            for m, item in enumerate(quote_list, 1):
                print("{}.  {}\n".format(m, item))
            break

        elif choice == 4:
            rand_ttls = list(wikiquote.random_titles(max_titles=5))
            rnd_str = random.choice(rand_ttls)
            try:
                print(random.choice(wikiquote.quotes(rnd_str)))
                break
            except UnboundLocalError:
                print(
                    "[!] Sorry, some technical glitch occured, please try again!"
                )
コード例 #5
0
def quote(bot: DeltaBot, payload: str, message: Message,
          replies: Replies) -> None:
    """Get Wikiquote quotes.

    Search in Wikiquote or get the quote of the day if no text is given.
    Example: `/quote Richard Stallman`
    """
    locale = _get_locale(bot, message.get_sender_contact().addr)
    if locale in wq.supported_languages():
        lang = locale
    else:
        lang = None
    if payload:
        authors = wq.search(payload, lang=lang)
        if authors:
            if payload.lower() == authors[0].lower():
                author = authors[0]
            else:
                author = choice(authors)
            text = f'"{choice(wq.quotes(author, max_quotes=200, lang=lang))}"\n\n― {author}'
        else:
            text = f"No quote found for: {payload}"
    else:
        _quote, author = wq.quote_of_the_day(lang=lang)
        text = f'"{_quote}"\n\n― {author}'

    replies.add(text=text)
コード例 #6
0
ファイル: test_qotd.py プロジェクト: federicotdn/wikiquote
def test_qotd_quote(lang):
    if lang == "pt":
        pytest.skip()

    quote, _ = wikiquote.quote_of_the_day(lang=lang)
    assert isinstance(quote, str)
    assert len(quote) > 0
コード例 #7
0
def print_quote():
    (quote, author) = wikiquote.quote_of_the_day()
    qotd = 'Quote of the day'
    dash = '-' * len(qotd)
    print(f'{qotd}\n{dash}')
    print(f'"{quote}"\n\t({author})')
    print(dash)
コード例 #8
0
def qotd(bot, update, args):
    lang, terms = lang_and_terms(args)
    try:
        quote, author = wikiquote.quote_of_the_day(lang=lang)
        reply = '"' + quote + '" - ' + author
        update.message.reply_text(reply)
    except:
        update.message.reply_text('An error occured when fetching the quote of the day.')   
コード例 #9
0
    def test_quotd_all_langs(self):
        logger.info('\n========= QOTD =========\n')
        for lang in wikiquote.supported_languages():
            logger.info(lang.upper() + ':')
            quote, author = wikiquote.quote_of_the_day(lang=lang)
            logger.info('- quote: ' + quote)
            logger.info('- author: ' + author)

            self.assertTrue(len(quote) > 0 and len(author) > 0)
コード例 #10
0
ファイル: hangman.py プロジェクト: Vik1ang/COMP1531
def generate_word():
    word_list = wikiquote.quote_of_the_day(lang='en')[0]
    word_list = word_list.split()
    possible_list = []
    for single_word in word_list:
        if single_word.isalpha() and len(single_word) >= 4:
            single_word.lower()
            possible_list.append(single_word)
    if possible_list == []:
        possible_list.append('hello')
    return possible_list[random.randint(0, len(possible_list)-1)]
コード例 #11
0
ファイル: get_quote.py プロジェクト: cnovel/TheDailyCommute
def get_quote_of_the_day(lang: str = 'fr') -> Quote:
    """
    Get the quote of the day from Wikiquote
    :param lang: Language parameters, can be 'en', 'fr', 'it', 'de' or 'es'
    :return: Quote, can be empty
    """
    try:
        qotd = wikiquote.quote_of_the_day(lang)
        return Quote(qotd[0], qotd[1])
    except wikiquote.qotd.utils.UnsupportedLanguageException as lang_except:
        logging.exception(lang_except)
        return Quote('', '')
コード例 #12
0
 def quote_cmd(cls, ctx):
     chat = cls.bot.get_chat(ctx.msg)
     if ctx.text:
         pages = wq.search(ctx.text, lang=cls.LANG)
         if pages:
             author = pages[0]
             quote = '"%s"\n\n― %s' % (random.choice(
                 wq.quotes(author, max_quotes=100, lang=cls.LANG)), author)
         else:
             quote = _('No quote found for: {}').format(ctx.text)
         chat.send_text(quote)
     else:
         quote, author = wq.quote_of_the_day(lang=cls.LANG)
         quote = '"{}"\n\n― {}'.format(quote, author)
         chat.send_text(quote)
コード例 #13
0
def lambda_handler(event, context):

    try:
        action = event['action']
    except:
        raise RuntimeError("Missing parameter: action")

    if action not in VALID_ACTIONS:
        raise RuntimeError(f"Invalid action: {action}")

    aws_regions = get_regions(ec2client)

    threads = []

    for region in aws_regions:
        thread = Thread(target=process_instances, args=(region, action))
        threads += [thread]
        thread.start()

    for thread in threads:
        thread.join()

    return wikiquote.quote_of_the_day()[0]
コード例 #14
0
ファイル: chat.py プロジェクト: PythonBuddies/main_bot
    async def quote(self, choice):
        """Generating a random quote or get the quote of the day.

        **Dependencies**: pip install wikiquote

        Keyword arguments:
        choice -- either 'QOTD' (Quote of the day) or 'R' (Random)

        """

        if choice.upper() == 'QOTD':
            quote = wikiquote.quote_of_the_day()
            await self.bot.say("'{}' -- {}".format(quote[0], quote[1]))
        elif choice.upper() == 'R':
            while True:
                authors = wikiquote.random_titles(max_titles=5)
                random_author = random.choice(authors)
                if random_author.isdigit():
                    continue
                random_quote = random.choice(wikiquote.quotes(random_author))
                await self.bot.say("'{}' -- {}"
                                   .format(random_quote,
                                           random_author))
                break
コード例 #15
0
            speak('Just wait.')
            temp=que.split(' ')
            city=temp[2]
            result1=client.query(que)
            ans1=next(result1.results).text
            que=que.replace(que,'')
            speak(f"Temperature of {city} is {ans1}")

        elif 'joke' in que:
            que=que.replace(que,'')
            joke=pyjokes.get_joke(language='en',category='neutral')
            speak(joke)

        elif 'quote of the day' in que:
            que=que.replace(que,'')
            quot=wikiquote.quote_of_the_day(lang='en')
            speak(quot[0])
            speak(f'By:  {quot[1]}')

        elif 'quote' in que:
            que=que.replace(que,'')
            tit=wikiquote.random_titles(max_titles=5)
            quote=wikiquote.quotes(tit[0],max_quotes=1)
            speak(quote)

        elif 'shutdown' in que:
            que=que.replace(que,'')
            speak('Do you really want to shutdown your PC')
            speak('Yes: Shutdown\nNo: Terminate shutdown')
            y_n=str(Listen())
            
コード例 #16
0
ファイル: randomquote.py プロジェクト: situx/tuxbot
def quoteofday(bot,trigger):
    """Retrieves a quote of day"""
    quoteofday=wikiquote.quote_of_the_day()
    bot.say(quoteofday[0])
    bot.say(quoteofday[1])    
コード例 #17
0
ファイル: main.py プロジェクト: derekjhunt/discord-ralphbot
async def qotd(ctx):
    response = wikiquote.quote_of_the_day()
    await ctx.send(response)
コード例 #18
0
ファイル: test_qotd.py プロジェクト: y-jew/wikiquote
 def test_qotd_quote(self):
     for lang in wikiquote.supported_languages():
         quote, author = wikiquote.quote_of_the_day(lang=lang)
         self.assertIsInstance(quote, str)
         self.assertTrue(len(quote) > 0)
コード例 #19
0
    except ValueError:
        print("please check your connection")
    except Exception as e:
        print(e)
        print("Say that again please...")
        return 'None'
    return query


if __name__=="__main__":
    wish()
    speak("do you need a quote of the day?")
    user_wish=takeCommand().lower()

    if 'yes' or 'sure' or 'ok' in user_wish:
        print(wikiquote.quote_of_the_day())
        speak(wikiquote.quote_of_the_day())
    else:
        speak("at ur convinience")

    speak("AT your service sir,  how can i help you")

    while True:
        query=takeCommand().lower()


        if 'what is your name' in query:
            print("I am Anu")
            speak("I am Anu")

        elif 'who are you' in query:
コード例 #20
0
ファイル: test_qotd.py プロジェクト: y-jew/wikiquote
 def test_qotd_qotd(self):
     self.assertEqual(wikiquote.quote_of_the_day(), wikiquote.qotd())
コード例 #21
0
ファイル: test_qotd.py プロジェクト: federicotdn/wikiquote
def test_qotd_qotd():
    assert wikiquote.quote_of_the_day() == wikiquote.qotd()
コード例 #22
0
ファイル: test_qotd.py プロジェクト: javaspace71/wikiquote
 def test_qotd_author(self):
     for lang in wikiquote.langs.SUPPORTED_LANGUAGES:
         quote, author = wikiquote.quote_of_the_day()
         self.assertIsInstance(author, str)
         self.assertTrue(len(author) > 0)
コード例 #23
0
ファイル: manual_checks.py プロジェクト: y-jew/wikiquote
# manual_checks.py
# A short script to manually test wikiquote's functionality

MAX_QUOTE_LEN = 70

articles = ['Barack Obama', 'Albert Einstein', 'Ada Lovelace', 'Leonard Cohen']

for lang in wikiquote.supported_languages():
    print('\n----------------------------------------------------')
    print('\nLanguage: {}'.format(lang))
    print('\n----------------------------------------------------\n')

    print('QOTD:')
    try:
        qotd, author = wikiquote.quote_of_the_day(lang=lang)
        print(qotd)
        print('   by: {}'.format(author))
    except Exception as e:
        print(e)

    for article in articles:
        print('\nArticle: {}'.format(article))
        try:
            results = wikiquote.search(article, lang=lang)

            if results:
                print('Results:')
                for result in results:
                    print(' - {}'.format(result))
                print()
コード例 #24
0
def getquote(type: str, userid: str):
    if type == "qotd":
        (qt, autor) = wikiquote.quote_of_the_day()
        Suggestions = []
        for i in wikiquote.random_titles(max_titles=10):
            Suggestions.append({
                "label": i,
                "value": i,
                "emoji": {
                    "name": "qauthor",
                    "id": "847687409034330132"
                }
            })
        return {
            "embeds": [{
                "color": 3092791,
                "title": "Quote of the Day:",
                "description": f"{qt}\n- {autor}",
                "thumbnail": {
                    "url":
                    "https://cdn.discordapp.com/attachments/789798190353743874/796948926590615572/oie_transparent_1.png"
                },
                "footer": {
                    "text":
                    "Quotes from Wikiquote",
                    "icon_url":
                    "https://cdn.discordapp.com/attachments/789798190353743874/794948919594450944/QqJDyLtUbgAAAAASUVORK5CYII.png"
                }
            }],
            "components": [{
                "type":
                1,
                "components": [{
                    "type":
                    3,
                    "custom_id":
                    json.dumps({
                        "sfn": "quote",
                        "subc": "sgtns",
                        "userid": userid
                    }),
                    "placeholder":
                    "🔎 Try searching",
                    "options":
                    Suggestions
                }]
            }, {
                "type":
                1,
                "components": [{
                    "type":
                    2,
                    "style":
                    1,
                    "emoji": {
                        "name": "qauthor",
                        "id": "847687409034330132"
                    },
                    "label":
                    "Search Quote from Author",
                    "custom_id":
                    json.dumps({
                        "bfn": "quote",
                        "subc": "are",
                        "userid": userid
                    })
                }]
            }]
        }
    else:
        res = requests.get("http://api.quotable.io/random").json()
        qt = res["content"]
        autor = res["author"]
        Suggestions = findtitles(query=autor)
        if Suggestions == []:
            Suggestions = wikiquote.random_titles(max_titles=10)
        if autor in Suggestions:
            Suggestions.remove(autor)
        Options = []
        shuffle(Suggestions)
        for i in Suggestions:
            if len(Options) < 26:
                Options.append({
                    "label": i,
                    "value": i,
                    "emoji": {
                        "name": "qauthor",
                        "id": "847687409034330132"
                    }
                })
            else:
                break
        return {
            "embeds": [{
                "color": 3092791,
                "title": "Random Quote:",
                "description": f"{qt}\n- {autor}",
                "thumbnail": {
                    "url":
                    "https://cdn.discordapp.com/attachments/789798190353743874/796948926590615572/oie_transparent_1.png"
                },
                "footer": {
                    "text":
                    "Powered by Quotable API",
                    "icon_url":
                    "https://cdn.discordapp.com/attachments/839610105858752522/839610124271484938/download.jpeg"
                }
            }],
            "components": [{
                "type":
                1,
                "components": [{
                    "type":
                    3,
                    "custom_id":
                    json.dumps({
                        "sfn": "quote",
                        "subc": "sgtns",
                        "userid": userid
                    }),
                    "placeholder":
                    "🔎 Try searching",
                    "options":
                    Options
                }]
            }, {
                "type":
                1,
                "components": [{
                    "type":
                    2,
                    "style":
                    1,
                    "emoji": {
                        "name": "quote",
                        "id": "847687355481718794"
                    },
                    "label":
                    "Another One!",
                    "custom_id":
                    json.dumps({
                        "bfn": "quote",
                        "subc": "getran",
                        "userid": userid
                    })
                }, {
                    "type":
                    2,
                    "style":
                    2,
                    "label":
                    "Search Quote from Author",
                    "emoji": {
                        "name": "qauthor",
                        "id": "847687409034330132"
                    },
                    "custom_id":
                    json.dumps({
                        "bfn": "quote",
                        "subc": "are",
                        "userid": userid
                    })
                }]
            }]
        }
コード例 #25
0
ファイル: quotes.py プロジェクト: tsanghan/Alexa-wisdomQuotes
def today_quotes():
    tquotes = wikiquote.quote_of_the_day()
    tquote_msg = 'From quote of the day, {}'.format(tquotes)
    return question(tquote_msg)
コード例 #26
0
ファイル: test_qotd.py プロジェクト: Wkryst/python-wikiquotes
 def test_qotd_author(self):
     for lang in wikiquote.langs.SUPPORTED_LANGUAGES:
         quote, author = wikiquote.quote_of_the_day()
         self.assertIsInstance(author, str)
         self.assertTrue(len(author) > 0)
コード例 #27
0
ファイル: test_qotd.py プロジェクト: Wkryst/python-wikiquotes
 def test_qotd_quote(self):
     for lang in wikiquote.langs.SUPPORTED_LANGUAGES:
         quote, author = wikiquote.quote_of_the_day(lang=lang)
         self.assertIsInstance(quote, str)
         self.assertTrue(len(quote) > 0)
コード例 #28
0
 def get_quotes():
     daily_quote = wikiquote.quote_of_the_day()
     return f"{daily_quote[0]}\n~{daily_quote[1]}"
コード例 #29
0
ファイル: test_qotd.py プロジェクト: y-jew/wikiquote
 def test_qotd_author(self):
     for lang in wikiquote.supported_languages():
         quote, author = wikiquote.quote_of_the_day()
         self.assertIsInstance(author, str)
         self.assertTrue(len(author) > 0)
コード例 #30
0
ファイル: test_qotd.py プロジェクト: federicotdn/wikiquote
def test_unsupported_lang():
    with pytest.raises(wikiquote.UnsupportedLanguageException):
        wikiquote.quote_of_the_day(lang="foobar")
コード例 #31
0
 async def qotd(self):
     qotd = wikiquote.quote_of_the_day()
     await self.bot.say(qotd[0])
     await self.bot.say("- " + qotd[1])
コード例 #32
0
        r.adjust_for_ambient_noise(source)
        print('we are listening...')
        audio = r.listen(source)
        print('speech done...')
        p = r.recognize_google(audio)
    #p = p.lower()

    # print(p)
    # os.system(p)

    if ((("run" in p) or ("execute" in p) or ("use" in p) or ("open" in p) or
         ("start" in p) or ("launch" in p))
            and ("chrome" in p or "browser" in p)):
        os.system("start chrome")
    elif ("quote" in p or "quotes" in p):
        pyttsx3.speak(wikiquote.quote_of_the_day())
        print(wikiquote.quote_of_the_day())
    elif ((("run" in p) or ("execute" in p) or ("use" in p) or ("open" in p) or
           ("start" in p) or ("launch" in p)) and ("media player" in p)):
        os.system("wmplayer")
    elif ((("see" in p) or ("tell" in p) or ("look" in p) or ("speak" in p) or
           ("find" in p)) and ("day" in p)):
        x = datetime.datetime.now()
        pyttsx3.speak("Today is " + x.strftime("%A"))
    elif ("empty recycle bin" in p):
        winshell.recycle_bin().empty(confirm=False,
                                     show_progress=False,
                                     sound=True)
        pyttsx3.speak("Now your recycle bin is recycled.")
    elif ((("see" in p) or ("tell" in p) or ("look" in p) or ("speak" in p) or
           ("find" in p)) and ("month" in p)):
コード例 #33
0
ファイル: test_qotd.py プロジェクト: javaspace71/wikiquote
 def test_qotd_quote(self):
     for lang in wikiquote.langs.SUPPORTED_LANGUAGES:
         quote, author = wikiquote.quote_of_the_day(lang=lang)
         self.assertIsInstance(quote, str)
         self.assertTrue(len(quote) > 0)
コード例 #34
0
def quotaton():
    speak(wikiquote.quote_of_the_day())
    print(wikiquote.quote_of_the_day())
コード例 #35
0
ファイル: quotes.py プロジェクト: tsanghan/Alexa-wisdomQuotes
def today_quotes():
    tquotes = wikiquote.quote_of_the_day()
    tquote_msg = 'From quote of the day, {}'.format(tquotes)
    return question(tquote_msg)
コード例 #36
0
ファイル: test_qotd.py プロジェクト: etkaDT/python-wikiquotes
 def test_qotd_quote(self):
     quote, author = wikiquote.quote_of_the_day()
     self.assertIsInstance(quote, str)
     self.assertTrue(len(quote) > 0)