-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Telegram support added and minor improvements
- Loading branch information
1 parent
d359d90
commit c636d8c
Showing
8 changed files
with
171 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,37 @@ | ||
#!/usr/bin/python3 | ||
import sys | ||
import os | ||
import config | ||
|
||
command = "python" | ||
if config.currentOS is "Linux": | ||
command += "3 src/" | ||
else: | ||
command += " src\\" | ||
|
||
|
||
def prnthelp(): | ||
print("Welcome to the RomanceBreaker user guide\nPlease refer to the Github page for detailed setup instructions") | ||
print("\nList of commands:\nwhatsapp or -w ---> launches RomanceBreaker in WhatsApp mode\nmessenger or -m ---> launches RomanceBreaker in Messenger mode\nsms or -s ---> launches RomanceBreaker in SMS mode") | ||
print("\nList of commands:\nwhatsapp or -w ---> launches RomanceBreaker in WhatsApp mode\nmessenger or -m ---> launches RomanceBreaker in Messenger mode\nsms or -s ---> launches RomanceBreaker in SMS mode\ntelegram or -t ---> launches RomanceBreaker in Telegram mode") | ||
print("help or -h or man ---> Launches user guide\nupdate ---> Updates RomanceBreaker from the github repo") | ||
|
||
|
||
try: | ||
if str(sys.argv[1]) == "whatsapp" or str(sys.argv[1]) == "-w": | ||
print("WHATSAPP MODE") | ||
os.system("python whatsappRB.py") | ||
os.system("{}whatsappRB.py" .format(command)) | ||
elif str(sys.argv[1]) == "messenger" or str(sys.argv[1]) == "-m": | ||
print("MESSENGER MODE") | ||
os.system("python messengerRB.py") | ||
os.system("{}messengerRB.py" .format(command)) | ||
elif str(sys.argv[1]) == "sms" or str(sys.argv[1]) == "-s": | ||
print("SMS MODE") | ||
os.system("python smsRB.py") | ||
os.system("{}smsRB.py" .format(command)) | ||
elif str(sys.argv[1]) == "telegram" or str(sys.argv[1]) == "-t": | ||
print("TELEGRAM MODE") | ||
os.system("{}telegramRB.py" .format(command)) | ||
elif str(sys.argv[1]) == "help" or str(sys.argv[1]) == "-h" or str(sys.argv[1]) == "man": | ||
prnthelp() | ||
elif str(sys.argv[1]) == "update": | ||
os.system("git pull") | ||
except: | ||
print("Invalid arguments\nRun python romanceBreaker.py -h to look at the commands manual") | ||
print("Invalid arguments\nTry running {} romanceBreaker.py -h to show the list of commands" .format(command)) |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# -*- coding: utf-8 -*- | ||
import random | ||
|
||
def new(interval): | ||
hour = random.randint(int(interval[0][0:2]), int(interval[1][0:2])) | ||
if int(hour) == int(interval[1][0:2]): | ||
minute = random.randint(0, int(interval[1][3:5])) | ||
elif int(hour) == int(interval[0][0:2]): | ||
minute = random.randint(int(interval[1][3:5]), 59) | ||
else: | ||
minute = random.randint(0, 59) | ||
print("I'll send a message at {}:{}..." .format( | ||
hour.zfill(2), minute.zfill(2))) | ||
return hour, minute |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
import time | ||
import datetime | ||
import random | ||
import os,sys | ||
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
import config | ||
import randomTime | ||
|
||
#Getting username & pwd | ||
client = TelegramClient(config.telegram_username, | ||
config.tg_api_id, config.tg_api_hash) | ||
client.start(config.telegram_phone, config.telegram_password) | ||
|
||
#Getting recipient | ||
name = input("Username of your bae: ") | ||
friends = client.searchForUsers(name) | ||
bae = friends[0] | ||
|
||
|
||
def morningMessage(): | ||
#Sending message | ||
msg = random.choice(config.custom_morning_messages) | ||
global client | ||
global bae | ||
sent = client.send_message(bae, msg) | ||
if sent: | ||
print("Message '{}' sent successfully!\nWaiting for next scheduled time..." .format(msg)) | ||
else: | ||
print("There was an error trying to send the message") | ||
return | ||
|
||
|
||
randTimeHour, randTimeMinute = randomTime.new(config.custom_time_interval) | ||
|
||
while True: | ||
if int(datetime.datetime.today().hour) == int(randTimeHour) and int(datetime.datetime.today().minute) == int(randTimeMinute): | ||
morningMessage() | ||
randTimeHour, randTimeMinute = randomTime.new( | ||
config.custom_time_interval) | ||
time.sleep(60) # Wait one minute to check if it's #morningtime |
This file contains 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
c636d8c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closes #1 #2 #4