Kelso Posted March 4, 2007 Posted March 4, 2007 I know. You all probably look at the term "chat bots" and run and hide. What is more scary than a robot that pretends to be someone else? However, by warning people of this danger, we can overcome it: Here's the code for a basic jabber chatbot. You can see it (sometimes) by chatting with fatlotus@gmail.com. Right now, all it does is send things back in a "elmer fudd" language, but this could be far more powerful: <?php error_reporting (E_ALL & ~E_NOTICE); # Jabber Bot Test Script require ('class.jabber.php'); set_time_limit (0); define ("INTRO","I am the Elmar-bot. I am not a human. Give me a word or phrase, and I will return what Elmar Fudd would have said. Just begin in with the word elmar and I will do the rest."); $jabber = new Jabber(); $jabber->server = 'ssl://talk.google.com'; $jabber->host = 'gmail.com'; $jabber->port = 5223; $jabber->username = 'fatlotus'; $jabber->password = 'PASSWORD REMOVED'; $jabber->resource = 'Evil Bot of Doom v.1.0'; $jabber->use_ssl = true; $jabber->enable_logging = true; $jabber->log_filename = 'Log.txt'; $jabber->Connect() or die ('Error Connecting'."\n"); $jabber->SendAuth() or die ('Couldn\'t login.'."\n"); $jabber->SendPresence (NULL,NULL,"In Bot Mode"); $jabber->SendMessage ("doggiearcher@gmail.com","chat",NULL, array("body" => "Hi Kelso!")); $jabber->CruiseControl(); $jabber->Disconnect(); function Handler_message_normal($message) { Handler_message_chat($message); } function Handler_message_chat($message) { global $jabber; $from = $jabber->GetInfoFromMessageFrom($message); $body = $jabber->GetInfoFromMessageBody($message); if ($jabber->StripJID($from) == "fatlotus@gmail.com") return; if ($body == "go2sleep" && preg_match("/^adminaccount@gmail.com/i", $from)) { $jabber->SendMessage ($from, "chat", NULL, array ("body" => 'Good Bye!')); $jabber->Disconnect(); exit; } elseif (preg_match("/^elmar /i", $body)) { $phrase = preg_replace("/^elmar /i", "", $body); $translated = str_replace("r", "w", $phrase); $translated = str_replace("R", "W", $translated); $translated = str_replace("l","w",$translated); $translated = str_replace("L","W",$translated); $translated = eregi_replace ("(r)r+","\\1",$translated); $translated = eregi_replace ("(w)w+","\\1",$translated); $jabber->SendMessage($from, "chat", NULL, array("body" => $translated)); } else { $jabber->SendMessage($from, "chat", NULL, array("body" => INTRO)); } } function Handler_presence_available ($message) { global $jabber; $jid = $jabber->StripJID($jabber->GetInfoFromPresenceFrom($message)); $jabber->SendMessage($jid, "chat", NULL, array("body" => INTRO)); } ?> If you have any questions, feel free to contact me. Right now, I don't have time to finish this, but I will answer any questions!
hawleyal Posted November 13, 2009 Posted November 13, 2009 port = 5223; I couldn't get this outgoing ports to work. It seems like they're only allowing 80 (http), 443 (http+ssl), and 25 (smtp). Maybe others, I haven't tested them all. http://alexanderhawley.com/ruby/testports.rb How did you get this to work? Thanks. -AH
Wizard Posted November 14, 2009 Posted November 14, 2009 ...This post is over 2 years old. Don't reply to it.
Itesscap73 Posted November 21, 2009 Posted November 21, 2009 I wondered about that. I dont know why but that possiability crossed my mind. does this mean i have to leave the sign in as 2 parts? Or what can i do?
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now