Last active
March 15, 2023 02:34
-
-
Save gireeshkbogu/193e88f88663aa51f258ed527f18bad0 to your computer and use it in GitHub Desktop.
Annoying Flatmate Alerts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Author: Gireesh Bogu | |
| # Location: Barcelona | |
| # Time: Dec 21, 2016 | |
| # Aim-1 [Accomplished]: Sending Flat Rental And Utilities Bills To My Forgetful Flatmate Every First Day Of The Month :/ | |
| # Aim-2 [Pending]: Calculating bills from the bank account automatically (This is tricky because of two reasons: (1) probably bank information is hard to access and (2) bills timing on bank statemenet often do not match with the actual monthly bills) | |
| # Aim-3 [Pending]: Aim-1 is using gmail but it is nice to extend this to Facebook as she checks it more often than gmail ;) | |
| # Add the below usage code to crontab (open it using this command: crontab -e) | |
| # Usage: * 09 1 * * /fullpath/annoyingFlatmateAlerts.py (sends email at 9 A.M at every first day of the month) | |
| # Do not forget to make the script executable before you add to crontab: chmod +x annoyingFlatmateAlerts.py | |
| #!/usr/bin/env python | |
| # Helps sending emails | |
| import smtplib | |
| from email.MIMEMultipart import MIMEMultipart | |
| from email.MIMEText import MIMEText | |
| # Helps setting date and time for alerts | |
| import datetime | |
| # your and your flatmate emails | |
| fromaddr = "gireeshkbogu@gmail.com" | |
| toaddr = "annoying_flatmate@gmail.com" | |
| # Flat Rent alerts | |
| msg = MIMEMultipart() | |
| msg['From'] = fromaddr | |
| msg['To'] = toaddr | |
| msg['Subject'] = "FLAT RENT - 310 Euros" | |
| body = "IT'S TIME TO PAY MY DEAR FLATMATE :) :) :)" | |
| msg.attach(MIMEText(body, 'plain')) | |
| server = smtplib.SMTP('smtp.gmail.com', 587) | |
| server.starttls() | |
| server.login(fromaddr, "password") | |
| flat_rent = msg.as_string() | |
| # Flat Utilities alerts | |
| msg1 = MIMEMultipart() | |
| msg1['From'] = fromaddr | |
| msg1['To'] = toaddr | |
| msg1['Subject'] = "UTILITY BILLS - 67 Euros" | |
| body = "IT'S TIME TO PAY MY DEAR FLATMATE :) :) :)" | |
| msg1.attach(MIMEText(body, 'plain')) | |
| server = smtplib.SMTP('smtp.gmail.com', 587) | |
| server.starttls() | |
| server.login(fromaddr, "password") | |
| utility_bills = msg1.as_string() | |
| # Sending alerts | |
| server.sendmail(fromaddr, toaddr, flat_rent) | |
| server.sendmail(fromaddr, toaddr, utility_bills) | |
| server.quit() | |
| # acknowledgements: | |
| # http://naelshiab.com/tutorial-send-email-python/ [sending emails] | |
| # http://stackoverflow.com/questions/19874784/cron-job-to-run-every-1st-day-of-the-month | |
| # http://stackoverflow.com/questions/4460262/running-a-python-script-with-cron | |
| # * * * * * cmd_to_run (every minute, every hour, every day, every month, any day of week, and then the command) | |
| # https://pypi.python.org/pypi/fbchat/ | |
Author
Author
Facebook test version ...
Install fbchat before implementing this
Source: https://pypi.python.org/pypi/fbchat/
# Helps sending facebook messages
import fbchat
# My facebook ids
client = fbchat.Client("gireesh.bogu", "password")
# Sending a Message to a friends facebook id
friends = client.getUsers("gireeshkbogu") # return a list of names
friend = friends[0]
sent = client.send(friend.uid, "Bills time :) ")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just an example: Where I sent the alterts to my own email and facebook accounts 🥇