Created
July 29, 2016 19:05
-
-
Save Nasawa/61bf0a536133e8872402f09779603c92 to your computer and use it in GitHub Desktop.
Ruby program to send SMS e-mails
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
class SMS | |
require 'pony' | |
puts "Alright. This program will send people text messages throughout the day.\n" | |
puts "This is meant as a reminder, and I do not condone any malicious purposes.\n" | |
puts "If you have a negative impact on somebody's phone bill, I hope you go to court.\n" | |
puts "\nThat being said, I hope this is a useful tool for you!\n" | |
puts "Just follow these instructions and input valid information, and everything should work out.\n" | |
puts "Keep in mind that the messages are sent randomly, in no predictable order.\n" | |
puts "Also, for best results, start this program before the intended start time of the messages.\n" | |
puts "Feel free to email me at developer@anigeek.com with questions or comments!\n" | |
puts "Enter target phone's email address (ex. 5555555555@vtext.com)\n" | |
$pnum = gets.chomp() | |
puts "Enter your gmail address (ex. bob@gmail.com)\n" | |
$email = gets.chomp() | |
puts "Enter your gmail password (this will not be stored)\n" | |
$pass = gets.chomp() | |
puts "Loop tomorrow? 1 for yes, 0 for no.\n" | |
temp = gets | |
$loop = false | |
if temp.to_i == 1 | |
$loop = true | |
end | |
puts "Input messages seperated by pressing 'Enter'. Input 'exit' to stop.\n" | |
text = Array.new | |
z = 0 | |
while gets.chomp() != "exit" | |
text[z] = gets | |
z = z + 1 | |
end | |
puts "How many messages should be sent?" | |
$num = gets.to_i | |
puts "Start time? (24 hour clock)\n" | |
start = gets.to_i | |
puts "End time? (24 hour clock)\n" | |
finish = gets.to_i | |
puts "Last thing! Would you like to include a message to be sent at the start of the period?\n" | |
puts "If not, leave this field blank. If so, fill it out, and we'll send it. 'Good Morning' is always a good idea!" | |
$wakeup = gets.chomp() | |
def mail(body) | |
Pony.mail(:to => $pnum, :via => :smtp, :via_options => { | |
#2514069814@vtext.com #http://en.wikipedia.org/wiki/List_of_SMS_gateways to find out what to change it to | |
:address => 'smtp.gmail.com', | |
:port => '587', | |
:enable_starttls_auto => true, | |
:user_name => $email, #gmail Username ex. 'bob@gmail.com' | |
:password => $pass, | |
:authentication => :plain, | |
:domain => "HELO", | |
}, | |
:body => body) | |
puts body | |
end | |
smser = SMS.new | |
def loopy(text, smser, start, finish) | |
time = Time.new | |
puts time | |
if time.hour == finish | |
sleep((finish - start).abs * 3600) | |
end | |
if time.hour() == start && $wakeup == "" | |
smser.mail($wakeup) | |
end | |
limit = (finish - start % 24) * 3600 | |
if time.hour >= start && time.hour < finish | |
(0..$num).each do |i| | |
smser.mail(text[rand(text.length - 1)]) | |
z = rand(limit / ($num - i)) | |
limit = limit - z | |
sleep(z) | |
end | |
sleep(limit) | |
end | |
while time.hour != start | |
if time.hour == start - 1 | |
sleep((60 - time.min)*60) | |
else | |
sleep(3600) | |
end | |
end | |
end | |
begin | |
smser.loopy(text, smser, start, finish) | |
end while $loop | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment