Example #1
0
def display_todos():
    """
    Displays the existing todos.
    """
    todos = get_all_todos()
    if len(todos) == 0:
        print("No todos!")
        return
    lengths = [len(todo["text"]) for todo in todos]
    max_len = max(lengths)
    print()
    [quote] = config.find()
    if(quote["quote"]):
        print(get_random_quote())
    for index, todo in enumerate(todos):
        status_text = "Done" if todo["is_done"] else "PENDING"
        due_text = (
            "\tDue " + todo["due"].strftime("%d %b %y")
            if todo["due"] != None and not todo["is_done"]
            else ""
        )
        spaces = (max_len - len(todo["text"]) + 1) * " "
        display_text = (
            f"{index} - {todo['text']}" + spaces + "-" + status_text + due_text
        )
        print(display_text)
    print()
Example #2
0
def typing_test():
    q = get_random_quote()
    s = ''
    try:
        while s != q[0]:
            print q[0]
            s = raw_input().strip()
    except:
        exit(0)
    print '- %s' % q[1]
Example #3
0
def typing_test():
    q = get_random_quote()
    s = ''
    try:
        while s != q[0]:
            print q[0]
            s = raw_input().strip()
    except:
        exit(0)
    print '- %s' % q[1]
Example #4
0
def bot_loop():
    """Repeatedly pulls random quote and tweets it"""
    pic_file = 'quote-image.jpg'
    previous_quotes = list()
    print("*** Twitterbot running... ***")
    while True:

        # Creates new tweets and checks that we have not previously tweeted that quote
        quote, author = quotes.get_random_quote()
        while quote in previous_quotes:
            quote, author = quotes.get_random_quote()

        # If tweet has content
        if quote:
            # Creates random photo
            photo = photos.get_photo(quote, author, pic_file)

            # If photo is not None, share with photo. If not, share just text
            if photo:
                tweets.tweet_photo(quote, author, pic_file, photo["name"],
                                   photo["user"])
                # posts.share_photo(quote, author, pic_file, photo["name"], photo["user"])
                photos.delete_photo(pic_file)
            else:
                tweets.tweet(quote, author)
                # posts.share(quote, author)

        # Adds new tweet to our previous tweets
        previous_quotes.insert(0, quote)
        print("*** Quote shared: {}***".format(quote))
        if len(previous_quotes) > 5:
            previous_quotes.pop()
        now = datetime.datetime.now().strftime('%I:%M %p')
        print("*** Last tweet time: {}***".format(now))

        # Prepares time until next tweet
        hours = random.randint(3, 5)
        minutes = random.randint(1, 59)
        print("*** Sleeping for {} hours and {} minutes ***".format(
            hours, minutes))
        sleep((minutes + (hours * 60)) * 60)
Example #5
0
async def send_quote(dm_channel_id):
    await client.get_channel(dm_channel_id).send(
        embed=discord.Embed.from_dict({
            "title": quotes.get_random_quote(),
            "type": "rich",
            "color": 12370112,
            "image": {
                "url": ImageCollector.get_random_ronnie_image_url()
            },
            "footer": {
                "text": "~ Ronnie Coleman"
            }
        }))
Example #6
0
def get_spock_quote():
    quote = quotes.get_random_quote(quotes.SPOCK_QUOTES)
    # episode_credit = 'Start Trek, season 2, episode 1 ("Amok Time," 1968)'

    response = {
        "response_type": "in_channel",
        "text": ':spock-hand: Spock-check yourself!\n_"{}"_'.format(quote),
        # "attachments": [{
        #     "color": "3B8FCB",
        #     "fields": [{
        #         "title": "Episode Credit: ",
        #         "value": episode_credit,
        #         "short": True
        #     }]
        # }]
    }

    return jsonify(response)
Example #7
0
def quote(bot, update):
    print("let's send quote")
    bot.sendMessage(chat_id=update.message.chat_id, text=get_random_quote())
Example #8
0
def base_url():

    # Gets the random quote from the "quotes" module
    # Returns the quote as a jsonified dict

    return jsonify({'quote': quotes.get_random_quote()})