Automatically sending diary prompts to my mum

Automatically sending diary prompts to my mum

For Christmas I was bought The Daily Stoic Journal by my lovely mum. This provides stoic writing prompts for a diary. Things like “What is my purpose in life?” or “How can I keep my mind clear from pollution?”. I don’t consider myself a stoic but the prompts should definitely help keep me focused in the new year.

My mum mentioned that she would also like to use the prompts but couldn’t justify buying two copies of the book. I decided now was the time to learn to send automated whatsapp messages. It was surprisingly simple.

First I downloaded pycharm. This is just a really nice free piece of software for writing python. Then I installed the python module, pywhatkit.

After some fiddling around the messages were being sent! This is the code:

def main():
    import pywhatkit
    from datetime import date

    d0 = date(2023, 1, 1)
    d1 = date.today()
    delta = d1 - d0

    # opening the file in read mode
    my_file = open('Pathtofile.txt', "r")

    # reading the file
    data = my_file.read()

    # replacing end splitting the text
    # when newline ('\n') is seen.
    stoic_list = data.split("\n")
    my_file.close()

    pywhatkit.sendwhatmsg_instantly('+XX XXXX XXXXXX', "Stoic diary prompt: " + stoic_list[delta.days], 10, True, 3)


if __name__ == '__main__':
    main()

This python script is run by using the Windows job scheduler (you have to set up a batch script to run the python but that is only two lines of extra work). By using the GUI for the job scheduler everything is very intuitive and self-explanatory.

Unfortunately, I couldn’t find any online version of the journal and so had to spend an hour typing the prompts manually. I just listened to some music and blasted through it.

Happy new year everyone! :-)