General > General discussion

IGN Items Database

(1/3) > >>

Hyde:
My org uses IGN ... but I hate the IGN !items command with a passion and I was looking for a good way to get the 17.0 items in there.

I took your BeBot example and wrote a quick and dirty IGN version. Its not got anything fancy. I reformat the results a bit to spit out the top 2 (customizable) results so that you don't have to click to see the top results.

Code is as follows. Only been tested for an hour or so, but pretty simple and hard to cause problems with.

Feel free to split this out into a new topic if it pollutes the BeBot plugin thread too much.


--- Code: ---<?
/* items.php - Doctorhyde@RK2 - v20061217-1 */
/* IGN plugin for Vhab's central items database ... http://aodevs.com/index.php/topic,84.0.html*/
/* some code stolen from http://bebot.link/index.php/topic,380.0.html */

/* NOTE: Vhab, I change your output a bit (I only add, not remove) ... I'm not wanting you to */
/*    change your formatting, I like it, I would rather you kept it static so that I have a set */
/*    text format to count on :) */

/* if no search specified, give syntax */
if (!$word2) {
  $reply = "to search for an item, do '!items searchstring' or '!items # searchstring' where # is the QL to look for.";
} else {
  /* change this number to limit or expand the number of possible results */
  $maxresults = "10";
  /* change this if the website for results changes */
  $host = "http://items.vhabot.net/index.php?";
  /* change this at your peril */
  $arguments = "output=aoml&bot=IGN&search=";
  /* pull the command arguments out in IGN style */
  if (is_numeric($word2)) { $ql = "&ql=" . $word2; } else { $search = $word2 . "%20"; }
  $search .= $word3 . "%20" . $word4 . "%20" . $word5 . "%20" . $word6;
  if ($word7) {
    $morewords = explode(' ',$word7);
    foreach ($morewords as $extraword) {
      $search .= "%20" . $extraword;
    }
  }
  /* put the URL together */
  $url = $host . $arguments . $search . $ql . "&max=" . $maxresults;
  /* get the URL or give an error */
  $result = file_get_contents("http://items.vhabot.net/index.php?output=aoml&bot=IGN&search=" . $search . $ql);
  if (!empty($result)) {
    $resultmax = 2;
    /* make the results a bit more friendly */
    $result = str_replace("\">Click to View</a>","\n<font color=#222244>query=$url</font>\">Click to View</a>",$result);
    $reply .= "Item Search Results (up to $resultmax shown below, click for more):\n  " . $result . "\n";
    /* duplicate the ability of the IGN builtin !items function to display 1-3 of the results without forcing us to click */
    $results = explode("\n",$result);
    $resultreply = 0;
    foreach ($results as $testresult) {
      if ($resultreply == 0) {
        /* don't pay attention to anything until we get to the Results */
        if (strpos($testresult,"font color=#FFFFFF>Results</font>")) {
          $resultreply = 1;
        }
      } else {
        /* stop paying attention when we get done with the results or have more than 3 */
        if(strpos($testresult,">Click to View</a>") || $resultcount >= $resultmax) {
          $resultreply = 0;
        } else {
          /* ignore images */
          if(strpos($testresult,"itemref")) {
            $reply .= "    ... $testresult\n";
            $resultcount++;
          }
        }
      }
    }
  } else {
    $reply = "ERROR: Unable to query database via $url ... website may be down.";
  }
}
?>
--- End code ---

Vhab:
No offense but.. this is a BeBot forum.

Khalem:
Split and moved.

Hyde:

--- Quote from: Vhab on December 17, 2006, 12:47:14 pm ---No offense but.. this is a BeBot forum.

--- End quote ---

Sure, and I said split it if you want. You had a list of plugins on your items database page, I thought you might want to know of another one. :shrug:

Naturalistic:
What our prude helper was trying to say... :P (but much <3 Vhab)

This is a Bebot forums, if people see IGN stuff here, they will think that we support it (which we do not). So it's generally better to not post IGN modules/plugins etc here or they will ask here for help with it.



Navigation

[0] Message Index

[#] Next page

Go to full version