Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2be9be3

Browse files
Merge pull request avinashkranjan#2209 from whiteknight16/birthday
birthday wisher bot
2 parents 425518f + 3acf50d commit 2be9be3

File tree

8 files changed

+54
-0
lines changed

8 files changed

+54
-0
lines changed

‎Birthday Wisher Bot/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
This program will check the birthday.csv file to check if today is birthday of anyone. In case there is someone's birthday it will mail them a birthday wish based on random selection from one of three predefined templates.
2+
3+
In place of my_email enter your email id and in place of password enter the app password
4+
5+
In case using mail service other than gmail replace smtp

‎Birthday Wisher Bot/birthday.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
name,email,year,month,day
2+
fictional1,harshpandey89@gmail.com,2003,05,03

‎Birthday Wisher Bot/image.png

22.6 KB
Loading[フレーム]

‎Birthday Wisher Bot/letter_1.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear [NAME],
2+
3+
It's your birthday have a great day!
4+
5+
All my love,
6+
7+
Harsh

‎Birthday Wisher Bot/letter_2.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Dear [NAME],
2+
3+
Happy Birthday!
4+
5+
All the best for the year!
6+
7+
Harsh

‎Birthday Wisher Bot/letter_3.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Hey [NAME]
2+
3+
Happy birthday have a wonderful time today and eat lots of cake!
4+
5+
Lots of love
6+
7+
Harsh

‎Birthday Wisher Bot/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import smtplib
2+
from datetime import datetime as dt
3+
import random
4+
import pandas as pd
5+
my_mail="your email"
6+
password="your application password"
7+
8+
file=pd.read_csv("./birthday.csv")
9+
data=pd.DataFrame(file).set_index("name")
10+
date=dt.now()
11+
today=f"{date.month}-{date.day}"
12+
for index,row in data.iterrows():
13+
birth_day=(f"{row.month}-{row.day}")
14+
if(today==today):
15+
with open(f"./letter_{random.randint(1,3)}.txt",mode="r") as wish_file:
16+
contents=wish_file.read()
17+
output=contents.replace('[NAME]',row.name)
18+
with smtplib.SMTP("smtp.gmail.com",port=587) as connection:
19+
connection.starttls()
20+
connection.login(user=my_mail,password=password)
21+
connection.sendmail(from_addr=my_mail,to_addrs=row.email,msg=f"Subject:Happy Birthday\n\n{output}")
22+
connection.close()

‎Birthday Wisher Bot/requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
smtplib
2+
datetime
3+
random
4+
pandas

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /