I hope this goes here, It was mostly PHP so I wasn't sure if it showed go in Perl... (Sorry) Anyways, back on topic.
So I'm used to PHP and think it's easier (it's my primary programming language ) So what you will need: A site with PHP, A Bot.
So I was thinking how could I make it so I can use PHP with my bot. And I remembered:
Code:
<br />$variable = get "http://bleh.net/bleh.txt";<br />
And thought if I pass variables through it, I can get PHP to do what I want instead of Perl. So I thought it would be easier for me (personally) to get PHP to do everything. And I could also probaly add some SQL type things with it. so for on im I changed it to:
It makes it easier for me to think and I don't have to restart the bot everytime I change something So bot.php looks something like:
Code:
<?php<br />// whats said and the replys<br />$said[1] = ":'(";<br />$reply[1] = "What's wrong?||:'(";<br />$said[2] = "hi|hey|hola|hello";<br />$reply[2] = "hello||hi||hey||sup {name}||hello {name}";<br />$tot = count($said);<br /><br />// if there are no possible replys<br />$n[1] = "I don't understand";<br />$n[2] = "What?!?!?!?";<br />$tn = count($n);<br />$say = stripslashes($msg);<br />function talk_it($man,$say){<br /> global $tot;<br /> global $said;<br /> global $n;<br /> global $t;<br /> global $reply;<br /> global $rt;<br /> global $tn;<br /> for($x=1;$x<$tot;$x++){<br /> if(preg_match("/(.*?)([$said[$x]])(.*?)/i", $say)){<br /> $t = $x;<br /> }<br /> }<br /> $*lazy* = explode("||",$reply[$t]);<br /> $rt = count($*lazy*);<br /> $cr = rand(0,$rt-1);<br /> $message = $*lazy*[$cr];<br /> $message = str_replace("{name}","$man",$message);<br /> if($message==""){<br /> $rd = rand(1,$tn);<br /> $message = $n[$rd];<br /> }<br /> return $message;<br />}<br />$message = talk_it($man,$say);<br />echo "$message";<br />echo "<!--- $man: $say --->";<br />?><br />
So what this does is create an array of things that I want to reply them with. If I wanted to I could problay log it into a database and problay make it so it can do more. I can add more and everything. Or instead of an array, I could have a database storing the replys to things.
I also wanted to make it so my bot could send me messages via e-mail. Or if the person talking to the bot wanted to send me an e-mail. So I created this php script: