if ($msg_parts[0] == 'urbandictionary' || $msg_parts[0] == 'urbandict' || $msg_parts[0] == 'udict') { $more_parts = explode(' ', $msg_parts[1], 2); $word_search = $more_parts[0]; $define_number = $more_parts[1]; if ($define_number == '') { $define_number = 1; } if ($word_search == '') { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "No word specified."); return; } require_once('SOAP\Client.php'); $soap = new SOAP_Client('http://api.urbandictionary.com/soap'); try { $result = $soap->call('lookup', array('key' => '8fec20f9c0eeda43ab08336af9552d83', 'term' => $word_search)); } catch (SoapFault $se) { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "There was an error in looking up your word."); } if ($result) { if ($define_number > sizeof($result)) { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "Invalid definition number."); return; } if ($define_number < 0) { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "Invalid definition number."); return; } $i = 1; foreach ($result as $word) { if ($i == $define_number) { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "Urbandictionary for '".$word_search."' (".$define_number." of ".sizeof($result)."): ".$word->definition.""); $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "Example: ".$word->example.""); return; } $i++; } } if (!$result) { $irc->message(SMARTIRC_TYPE_CHANNEL, $recip, "There are no entries found for ".$word_search."."); } }