Skip to content

Instantly share code, notes, and snippets.

@Delta456
Created August 15, 2022 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Delta456/72c663b45d1ff0be20cc9fed33516c66 to your computer and use it in GitHub Desktop.
Save Delta456/72c663b45d1ff0be20cc9fed33516c66 to your computer and use it in GitHub Desktop.
School Python Project
import sys
import pickle
import time
import webbrowser
import pywhatkit
from datetime import datetime
import pyautogui as pg
now = datetime.now()
chour = now.strftime("%H")
def get_general_info(choice):
if choice == 1:
mobile_num = input('Enter Mobile No. of Receiver: ')
message = input('Enter your message which is to be sent: ')
hour = int(chour) + int(input('Enter after which hour you want to send: '))
minute = int(input('Enter minute: '))
return mobile_num, message, hour, minute
elif choice == 2:
mobile_num = input('Enter Mobile No. of Receiver: ')
message = input('Enter your message which is to be sent: ')
return mobile_num, message
elif choice == 3:
group_id = input('Enter Group ID: ')
message = input('Enter your message/img which is to be sent: ')
hour = int(chour) + int(input('Enter after which hour you want to send: '))
minute = int(input('Enter minute: '))
return group_id, message, hour, minute
elif choice == 4:
id = input('Enter Group ID/ Receiver Number: ')
img_path = input('Enter Video/IMG Path: ')
caption = input('Enter caption: ')
return id, img_path, caption
elif choice == 5:
id = input('Enter Group ID: ')
msg = input('Enter message to be sent: ')
return id, msg
def read_from_file(choice):
fp = open('info.dat', 'rb')
obj = pickle.load(fp)
if choice == 1:
pywhatkit.sendwhatmsg(obj[0], obj[1], obj[2], obj[3])
elif choice == 5:
webbrowser.open('https://web.whatsapp.com/accept?code=' + obj[0])
time.sleep(2)
width, height = pg.size()
time.sleep(20 - 2)
pg.click(width / 2, height - height / 10)
pg.typewrite(obj[1] + "\n")
elif choice == 3:
pywhatkit.sendwhatmsg_to_group(obj[0], obj[1], obj[2], obj[3])
elif choice == 2:
pywhatkit.sendwhatmsg_instantly(obj[0], obj[1])
elif choice == 4:
pywhatkit.sendwhats_image(obj[0], obj[1], obj[2])
fp.close()
def write_from_file(choice):
fp = open('info.dat', 'wb')
if choice == 1:
mob, msg, hour, minute = get_general_info(1)
pickle.dump([mob, msg, hour, minute], fp)
elif choice == 2:
mob, msg = get_general_info(2)
pickle.dump([mob, msg], fp)
elif choice == 3:
group, msg, hour, minute = get_general_info(3)
pickle.dump([group, msg, hour, minute], fp)
elif choice == 4:
id, img_path, caption = get_general_info(4)
pickle.dump([id, img_path, caption], fp)
elif choice == 5:
id, msg = get_general_info(5)
pickle.dump([id, msg], fp)
fp.close()
if __name__ == '__main__':
print('Whatsapp Messsage Sender via Binary Files\n')
while True:
print('Menu')
print('1. Send Time Locked Whatsapp Message ')
print('2. Send Instant Whatsapp Message')
print('3. Send Whatsapp Message to a Group')
print('4. Send GIF/Image Message')
print('5. Send Instant Whatsapp Message to a Group')
print('6. Exit')
choice = int(input('Enter your choice: '))
if choice == 1:
write_from_file(1)
read_from_file(1)
elif choice == 2:
write_from_file(2)
read_from_file(2)
elif choice == 3:
write_from_file(3)
read_from_file(3)
elif choice == 4:
write_from_file(4)
read_from_file(4)
elif choice == 5:
write_from_file(5)
read_from_file(5)
elif choice == 6:
break
else:
print('Invalid Choice, Enter your choice again!\n', file=sys.stderr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment