PDA

View Full Version : Text Messaging



xdarkshadowx
01-02-2013, 12:42 AM
Note: If you are using someone else's bot that requires this set-up, make certain they are not using it to email themselves your password. Would be an unfortunate way to lose an account. Be careful!

So I decided that I wanted my bot to text me when it broke down. And then I decided I wanted it to text me if someone said my name in chat, or send me a PM. And then I decided I Wanted to be able to text back and talk to that person who PMed me or said my name, to 'prove' to them that I was indeed not away from my computer and quite the contrary, typing at my laptop.

Well, if you want to, I have included the steps below to do just what I did. Now, the only catch is, if you think of something else to do with this, I want to hear your great ideas. I mean, bug reports to your phone, and conversations are great anti-ban opportunities. But this concept has tons of possible applications, so let me know what you creative bunch come up with. Enjoy.


1. download the dev version of easyphp from http://www.easyphp.org/

2. make a folder on your desktop where you will keep all of your .php files

2.1 download and un-zip http://swiftmailer.org/ into the file you created in #2 (http://villavu.com/forum/usertag.php?do=list&action=hash&hash=2) .

2.2 go to your easyphp admin page, and by the text LOCAL FILES click the gray button + add an alias. And then set the folder made in step 2 as your alias.

3. Make a gmail account for this, you'll need the password and name in a minute.

4. go to C:\Program Files (x86)\EasyPHP-12.1\conf_files and edit the php.ini file
4.1 Remove the semicolon from ;extension=php_imap.dll
and from ;php_openssl
4.2 Then restart easyphp

Now, here's where you will undoubtedly edit the crap out of, but I'll give you some code snippets so you have a general idea of how to use this. you will need 2 types of files, a .php file that will do most of the work, and a simba file that will call it. Which you already knew, of course.


<?php

$hostname = '{imap.gmail.com:993/imap/ssl}INBOX';
$username = 'username@gmail.com';
$password = 'password';

$inbox = imap_open($hostname,$username,$password);


$emails = imap_search($inbox,"UNSEEN");
if($emails) {

rsort($emails);


foreach($emails as $email_number) {
$overview = imap_fetch_overview($inbox,$email_number,0);
//echo $overview[0]->subject."\n";
$message = imap_fetchbody($inbox,$email_number,1);

echo $message; // Prints the message in Text format.
}

}

/* close the connection */
imap_close($inbox);
?>
This will grab all the "UNSEEN" emails in your gmail and put the body text up. (NOTE: the body text from a text message will have an enter (#13#10) at the end of it, so be careful when comparing strings);

if you mess around with the
echo $overview[0]->subject."\n"; you can change the word subject to anything you want to get different parts of the message.


now for sending emails:


<?php
require_once 'swift/lib/swift_required.php';

$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('username') //don't use @gmail.com
->setPassword('password');

$mailer = Swift_Mailer::newInstance($transport);

$message = Swift_Message::newInstance('Title Of the Message Here')
->setFrom(array('username@gmail.com' => 'ABC'))
->setTo(array('phoneNumber@vtext.com'))
->setBody('The Message Here');

$result = $mailer->send($message);
?>

will send a message when the page is ran to the phone number, I only included the verizon email extension, just google for the others if you don't use verizon.

you're phone can only accept 160 digit messages, I haven't experimented around with what happens if you send a larger message *yet*. may error, or may send in pieces to your phone.

Note: to be able to run php files from easyPhP admin page you must have them saved with the .php extension! (just text files, this should bring back memories from html when you were a child).

SIMBA TIME

Now we are at the simba portion, everything above has been set up, and we want simba to call those pages. Well, you're in luck, simba has a built in function to run pages, just use getpage('url here'); and you're good, you get the URL by running the web page from easyPHP admin page (which you can open from the easyphp widget). and then clicking on the alias you added under LOCAL FILES. you'll get a list of files you can click on, and then once you open them copy the URL. and you can now access the PHP code from simba!!! YAY!!!! :D



I've included some examples of simba code (just reading it so far, I haven't actually made a function that uses it effectively, *yet*). The errors I ran into simba side mostly had to do with the enter at the end of each text. the rest runs pretty smoothly.


program new;
var
x , i: integer ;
sting: string;



begin
getpage('http://theOneThatSends.php'); // Sends, in theory.




repeat
sting := GetPage('http://theOneThatreads.php');

//These lines below I used as diagnostics to figure out which ascii characters were throwing me off. only necessary for error finding.
writeln(sting);
writeln(inttostr(length(sting)));
for i := 1 to length(sting) do
begin
writeln(sting[i]);
writeln(inttostr(ord(sting[i])));
end;
//writeln(booltostr(sting = 'hello' + #13#10));
//writeln(GetPage('http://127.0.0.1/MySite/read.php'));


//Should send a message back if the message recieved in the email is 'hello'
if(sting = 'hello' + #13#10then
begin
getpage('http://127.0.0.1/MySite/first.php'); // Sends
end
else begin
//Send error back here!!
end;

until(false);

end.





Well, if you have any questions, ask them below. If you have any suggestions, mention them. And if you have any great idea's I should add, also let me know below.

I wrote this tutorial because the SRL/villavu community has helped me a lot. A good portion of you are stuck up assholes, but you stuck up assholes generally answer my idiotic scripting questions. I owe quite a few of you a lot for all the help I've gotten. I hope you enjoyed this tutorial, if you have any other crazy idea's that would make botting better like this one feel free to let me know, I love a challenge.

xdarkshadowx
01-02-2013, 12:44 AM
Savin' this spot.

IsoMorphic
01-02-2013, 12:48 AM
So you finally wrote the tutorial! Fantastic!
On the administration page thing I keep getting cannot connect to my webpage at 127.0.0.1

Any ideas?

xdarkshadowx
01-02-2013, 12:50 AM
Mhmm! let me know if I forgot something. My friend helped me with this so it's possible I forgot a step. but it should be all their.

OH, does anyone know if their is part of simba that runs as the script terminates? like a onQuit() function? cause it would be nice to have it text me if the script dies..

IsoMorphic
01-02-2013, 12:55 AM
Mhmm! let me know if I forgot something. My friend helped me with this so it's possible I forgot a step. but it should be all their.

OH, does anyone know if their is part of simba that runs as the script terminates? like a onQuit() function? cause it would be nice to have it text me if the script dies..

Im not sure. ask around

Ian
01-02-2013, 01:13 AM
Mhmm! let me know if I forgot something. My friend helped me with this so it's possible I forgot a step. but it should be all their.

OH, does anyone know if their is part of simba that runs as the script terminates? like a onQuit() function? cause it would be nice to have it text me if the script dies..

AddonTerminate('YourProcedure');
I believe :)

xdarkshadowx
01-02-2013, 01:41 AM
So you finally wrote the tutorial! Fantastic!
On the administration page thing I keep getting cannot connect to my webpage at 127.0.0.1

Any ideas?

Save it as a .php, forgot to include that.

Benny
01-02-2013, 02:29 AM
Wow great guide!

Not all of us are stuck up!!

This is really clever. Well done.

xdarkshadowx
01-02-2013, 02:46 AM
Wow great guide!

Not all of us are stuck up!!

This is really clever. Well done.

Thanks! Glad you enjoyed it. :)

spaderdabomb
05-10-2015, 10:44 PM
Awesome thread!

Just set this up as of 05-10-2015, so whoever wants to implement this should at least know everything is still working.

I had a few struggles in understanding this tutorial, but I think it was just due to my lack of experience when it comes to EasyPhp. The main thing that took me a while is once you set up your folder under the administrator page as a local folder, you can click on the name of your folder under local files to run any .php script you created. If you're struggling, just read EasyPHP - a quick starter guide.

Thanks!

xdarkshadowx
07-16-2015, 07:09 PM
Yeah I apologize. I have no php experience so I was relying on code snippets and random walkthroughs, luckily I had a friend who knew enough php to fix my idiotic mistakes.

I'm glad it's still functional. I hope it serves you well!

spaderdabomb
02-23-2016, 02:58 AM
So I just came back to this tutorial because I was trying to use this again. I could have sworn I didn't change anything and it suddenly wasn't working.

Turns out gmail has done a major overhaul of their security in the last year, so if you were using gmail to send your mails, then this tutorial would have stopped working. I would add this to your tutorial otherwise people will probably get very discouraged. You now have to go to https://myaccount.google.com/, while logged into your google account, click on settings, then change the "allow less secure apps" from off to on. This will allow swiftmailer to access your gmail account. Otherwise gmail blocks you.

Cheers.

rune3132
02-23-2016, 09:29 PM
Was going to set this up for my own cute little bot and would 100% have gotten stuck at this. Thanks a lot man. Btw, do you know if it would still work if I just follow this guide?

spaderdabomb
02-24-2016, 12:40 AM
Was going to set this up for my own cute little bot and would 100% have gotten stuck at this. Thanks a lot man. Btw, do you know if it would still work if I just follow this guide?

Yeah it still works. I remember when I first set it up I got a little stuck getting to the easyphp admin page. You can get to it by clicking on window's hidden icons (usually next to time/date in bottom right corner), right clicking easyphp icon and opening admin page from there.

Feel free to pm me if you get stuck.

Le_don
04-28-2016, 12:48 PM
This is awesome. Thanks a bunch.

tls
04-28-2016, 08:48 PM
Should utilize some api like http://textbelt.com/

Efurious
04-29-2016, 07:36 AM
Not going to implement it myself, as I have remote access available at almost all times. But I have to say, that it's a brilliant idea and I admire your creativity :p

xdarkshadowx
05-14-2016, 06:41 AM
Thanks for figuring that out! I'll try to run through this whole thing and give it a much needed facelift. Good to hear it still works though!

I would love to see what creative uses you guys have used this for, if any of you feel like sharing.