forked from lorcalhost/RomanceBreaker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRomanceBreaker.py
62 lines (54 loc) · 2.06 KB
/
RomanceBreaker.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
# -*- coding: utf-8 -*-
import time
import datetime
import fbchat
import random
from fbchat.models import *
from getpass import getpass
#Add your own custom messages by putting your message between "s and using the same format below
customMsgs = ["Good morning beautiful", "I'm too lazy", "To write messages on my own", "Custom message #4"]
#Put your own custom time interval here, make sure the hour is always two digits
customTimeInterval = ["04:20", "16:20"]
randTimeHour = 0
randTimeMinute = 0
#Getting username & pwd
username = input("Username: ")
passwrd = getpass()
client = fbchat.Client(username, passwrd)
#Getting recipient
name = input("Username of your bae: ")
friends = client.searchForUsers(name)
bae = friends[0]
def morningMessage():
#Sending message
msg = random.choice(customMsgs)
global client
global bae
sent = client.send(Message(msg), thread_id=bae.uid, thread_type=ThreadType.USER)
if sent:
print("Message '" + msg + "' sent successfully!\nWaiting for next scheduled time...")
else:
global username
global passwrd
client = fbchat.Client(username, passwrd)
morningMessage()
return
def newRandTime():
global customTimeInterval
global randTimeHour
global randTimeMinute
randTimeHour = random.randint(int(customTimeInterval[0][0:2]), int(customTimeInterval[1][0:2]))
if int(randTimeHour) == int(customTimeInterval[1][0:2]):
randTimeMinute = random.randint(0, int(customTimeInterval[1][3:5]))
elif int(randTimeHour) == int(customTimeInterval[0][0:2]):
randTimeMinute = random.randint(int(customTimeInterval[1][3:5]), 59)
else:
randTimeMinute = random.randint(0, 59)
print("I'll send a message at " + str(randTimeHour).zfill(2) + ":" + str(randTimeMinute).zfill(2) + "...")
return
newRandTime()
while True:
if int(datetime.datetime.today().hour) == int(randTimeHour) and int(datetime.datetime.today().minute) == int(randTimeMinute):
morningMessage()
newRandTime()
time.sleep(60) #Wait one minute to check if it's #morningtime