-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathAutomated_wisher.py
173 lines (117 loc) · 3.71 KB
/
Automated_wisher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#Automatic Birthday wisher on facebook User Interactive
from fbchat import Client
from fbchat.models import *
import datetime
from tkinter import *
from tkinter import messagebox
import tkinter as tk
import datetime
import sqlite3
from sqlite3 import Error
db_file = "Database.db"
def create_connection(db_file):
""" create a database connection to a SQLite database """
conn = None
try:
conn = sqlite3.connect(db_file)
except Error as e:
print(e)
return conn
def insert_birthday(names, day):
""" function to insert new birthdays in the database """
conn = create_connection(db_file)
with conn:
birthday = (names, day)
sql = ''' INSERT INTO birthdays(name, birthday)VALUES(?,?)'''
cur = conn.cursor()
cur.execute(sql, birthday)
return cur.lastrowid
def select_name(date=k):
"""Get name for the date given"""
conn = create_connection(db_file)
with conn:
cur = conn.cursor()
cur.execute("SELECT name FROM birthdays WHERE birthday=?",(date,))
rows = cur.fetchall()
for row in rows:
print(row[0])
return rows
def user_details():
global user
global pswrd
user = username.get()
pswrd= password.get()
print(user)
print(pswrd)
#Get Current Date
import datetime
now= datetime.datetime.now()
k=now.strftime("%d-%m")
print(k)
def friend_details():
global name
global dob
name=friend.get()
dob=friend_dob.get()
insert_birthday(name, dob)
print("Entry Added")
cont = select_name(k)
print(cont)
pattern = k
if k in cont:
print("Match Found")
client = Client('USERNAME','PASSWORD')
users = client.searchForUsers(name)
user = users[0]
print("User's ID: {}".format(user.uid))
client.sendMessage('Testing api',thread_id=user.uid,thread_type=ThreadType.USER)
print("Message sent")
else:
pass
#file.write()
#------Tkinter
def raise_frame(frame):
frame.tkraise()
win = Tk()
f1= Frame(win)
f2=Frame(win)
f=Frame(win)
for frame in(f,f1,f2):
frame.grid(row=0,column=0,sticky='news')
win.wm_title("AUTOMATED BIRTHDAY WISHER")
win.config(background="#708090")
win.geometry("520x310")
f=Frame(win,height = 350, width = 500)
f.grid(row=0,column=0,padx=95,pady=10)
photo0=PhotoImage(file='hbd2.gif')
lable = Label(f,image=photo0)
lable.grid(row=0,column=0,padx=10,pady=0)
#----Frame 1
lable = Label(f1,text="Username : ")
lable.grid(row=1,column=0,padx=0,pady=10)
username = Entry(f1,width=40)
username.grid(row=1,column=20,padx=10,pady=30)
lable = Label(f1,text="Password : ")
lable.grid(row=3,column=0,padx=10,pady=2)
password = Entry(f1,width=40)
password.grid(row=3,column=20,padx=10,pady=40)
submit = Button(f1,text="Submit",command=user_details)
submit.grid(row=5,column=20,padx=10,pady=50)
lable = Label(f2,text="FRIEND'S NAME : ")
lable.grid(row=3,column=0,padx=10,pady=2)
friend = Entry(f2,width=40)
friend.grid(row=3,column=20,padx=10,pady=40)
friend.get()
lable = Label(f2,text="FRIEND'S DOB : ")
lable.grid(row=4,column=0,padx=10,pady=2)
friend_dob = Entry(f2,width=40)
friend_dob.grid(row=4,column=20,padx=10,pady=40)
friend_dob.get()
submit1 = Button(f2,text="Submit",command=friend_details)
submit1.grid(row=5,column=20,padx=10,pady=50)
#----main window buttons
Button1 = Button(f,text="Enter Account Details",command=lambda :raise_frame(f1))
Button1.grid(row=1,column=0,padx=0,pady=40)
Button2 =Button(f,text="Add new Friend",command=lambda:raise_frame(f2))
Button2.grid(row=1,column=1,padx=0,pady=40)
win.mainloop()