BeBot - An Anarchy Online and Age Of Conan chat automaton

Archive => Age of Conan Archive => BeBot Hyborian support => Topic started by: Wizhk on February 25, 2009, 06:37:23 am

Title: Trivia Module
Post by: Wizhk on February 25, 2009, 06:37:23 am
Can still not get the trivia module from this link to work.

http://bebot.link/0-5-x-customunofficial-modules/custom-revised-modules-by-eldar/ (http://bebot.link/0-5-x-customunofficial-modules/custom-revised-modules-by-eldar/)

I have the same issues as listed in that link.

trivia.txt placed in all sorts of extras folders. And still when I do !trivia ask in guild chat It says that I have no trivia questions..

Any Help.. Plz

Wizhk

Title: Re: Trivia Module
Post by: Temar on February 25, 2009, 06:48:01 am
         $handle = fopen("extras/trivia.txt", "r");

so basicly that file has goto be in a folder called extras which has goto be in the root folder of the bot
if linux make sure all lower case as that how it is in module and linux is case sensitive
Title: Re: Trivia Module
Post by: Wizhk on February 25, 2009, 10:45:04 am
Windows Vista 32 is my Operating system.

I have a folder in my bebot root directory named extras that has the trivia.txt in it.

Do you have this module working in AOC? And if so, can you link your copy of both files.

Thank You,

Wizhk
Title: Re: Trivia Module
Post by: Wizhk on February 27, 2009, 07:50:10 am
Does anyone have the Trivia module working?

Wizhk
Title: Re: Trivia Module
Post by: Jiheld on March 01, 2009, 10:44:19 am
I got it working,

You have to change the settings, !set trivia and put the entry on -1

Title: Re: Trivia Module
Post by: Wizhk on March 02, 2009, 02:33:29 am
OK so In Settings I now have.

null
-1
null

It still wont find the Trivia questions.
Title: Re: Trivia Module
Post by: Jiheld on March 02, 2009, 01:57:04 pm
me too, you sure you have the .txt file in the right folder?
Title: Re: Trivia Module
Post by: Wizhk on March 02, 2009, 10:22:10 pm
I have an extras folder in c:/ , c:/bebot , c:/bebot/custom , c:/custom/modules , and maybe a few other places.. lol.

They are all text files and I have added.txt to the name on them all and removed .txt from the name on them all.

Still nothing.

Can you copy and paste your trivia module php file. maybe I have a wrong one.

Wizhk
Title: Re: Trivia Module
Post by: Jiheld on March 04, 2009, 02:43:18 pm
Quote
<?php
/*
 * Trivia.php - Module template.
 *
 * Developed by Meathooks and Elesar of the Eldar Guild (http://eldarguild.org)
 *     a Age of Conan Guild on the Dagoth server
 *
 */
   
$trivia = new Trivia($bot);

class trivia Extends BaseActiveModule
{
   function __construct (&$bot)
   {
      parent::__construct(&$bot, get_class($this));

      $this -> register_command('gc', 'trivia', 'MEMBER');

      $this -> help['description'] = 'Trivia Questions and you have to guess the answers.';
      $this -> help['command']['trivia ask']="Displays a random trivia question for you to answer.";
      $this -> help['command']['trivia answer [yourguess]']="Sends your answer to the current trivia question.";
      $this -> help['command']['trivia giveup]']="Sends the answer to the current trivia question.";

      $this -> bot -> core("settings") -> create("Trivia", "Entry", "-1", "");
      $this -> bot -> core("settings") -> create("Trivia", "Question", "*NONE*", "");
      $this -> bot -> core("settings") -> create("Trivia", "Answer", "*NONE*", "");
   }

   function command_handler($name, $msg, $origin)
   {
      if ($msg == "trivia ask")
      {
         $msg = $this->get_trivia();
      }
      elseif ($msg == "trivia giveup")
      {
         $msg = $this->giveup_trivia();
      }
      else if (preg_match("/^trivia answer (.+)$/i", $msg, $info))
      {
         $msg = $this->answer_trivia($info[1], $name);
      }
      else
      {
         $msg = "##highlight##TRIVIA::##end## UNKNOWN COMMAND part of Trivia Module";
      }

      return ($msg);
   }
   
   function get_trivia()
   {
      $trivia_active = $this->bot->core("settings")->get("Trivia","Entry");

      if($trivia_active == -1)
      {
         $handle = fopen("txt/trivia.txt", "r");
         if ($handle)
         {
            while (!feof($handle))
            {
               $buffer = fgets($handle, 8192);

               $pos = strpos($buffer, "*");
               if ($pos !== false)
               {
                  $question = substr($buffer, 0, $pos);
                  $array_questions[] = $question;

                  $answer = substr($buffer, $pos + 1, strlen($buffer) - $pos);
                  $array_answers[] = $answer;
               }
            }
         }

         $trivia_array_max = count($array_questions);

         $trivia_active = rand(0, $trivia_array_max);
         $this->bot->core("settings")->save("Trivia", "Entry", $trivia_active);
         $this->bot->core("settings")->save("Trivia", "Question", $array_questions[$trivia_active]);
         $this->bot->core("settings")->save("Trivia", "Answer", $array_answers[$trivia_active]);
      }

      $question = $this->bot->core("settings")->get("Trivia","Question");

      if ($question != "" and $question != "**NONE**")
      {
         $strmsg = "##highlight##TRIVIA::##end## ##highlight##[Question]##end## " . $question;
         $strmsg .= "\nTo submit your guess for the trivia, type in:   ##highlight##!trivia answer YOURANSWER##end##";
      }
      else
      {
         $strmsg = "##highlight##TRIVIA::##end## No trivia questions were found, please have some added :)";
      }

      return $strmsg;
   }

   function answer_trivia($stranswer, $name)
   {
      $answer = trim($this->bot->core("settings")->get("Trivia","Answer"));

      if ($answer != "" and $answer != "**NONE**")
      {
         if (strcmp(strtolower($answer), strtolower($stranswer)) != 0)
         {
            $strmsg = "##highlight##TRIVIA::##end## " . $name . "'s guess for the trivia question was incorrect ($stranswer), please try again.";
         }
         else
         {
            $strmsg = "##highlight##TRIVIA::##end## " . $name . " answered the trivia question ##highlight##CORRECTLY##end##.  The answer was ##highlight##$answer##end##.  Good Job!  (type '!trivia ask' to ask another question)";
            $this->bot->core("settings")->save("Trivia", "Entry", -1);
            $this->bot->core("settings")->save("Trivia", "Question", "**NONE**");
            $this->bot->core("settings")->save("Trivia", "Answer", "**NONE**");
         }
      }
      else
      {
         $strmsg = "##highlight##TRIVIA::##end## No trivia questions active or found to answer, try !trivia ask";
      }

      return $strmsg;          
   }

   function giveup_trivia($stranswer, $name)
   {
      $answer = trim($this->bot->core("settings")->get("Trivia","Answer"));

      if ($answer != "" and $answer != "**NONE**")
      {
         $strmsg = "##highlight##TRIVIA::##end## You all gave up :( .. lol ... the answer to the trivia question is ##highlight##$answer##end##.";
         $this->bot->core("settings")->save("Trivia", "Entry", -1);
         $this->bot->core("settings")->save("Trivia", "Question", "**NONE**");
         $this->bot->core("settings")->save("Trivia", "Answer", "**NONE**");
      }
      else
      {
         $strmsg = "##highlight##TRIVIA::##end## No trivia questions active or found to answer, try !trivia ask";
      }

      return $strmsg;          
   }
}
?>
Title: Re: Trivia Module
Post by: Wizhk on March 04, 2009, 05:36:26 pm
Interesting.. your file doesn't point to the extras folder.

Copied and pasted, placed a new trivia.txt in the module folder, did the -1, and all is fine now.

Thanks alot.

Wizhk
Title: Re: Trivia Module
Post by: Jiheld on March 04, 2009, 07:07:02 pm
I putted mine in the txt folder.

Glad it works now.

Title: Re: Trivia Module
Post by: Huesos on July 10, 2009, 04:28:58 pm
anyone still have this module somewhere? Old links don't host it anymore for trivia for the bots
Title: Re: Trivia Module
Post by: Vulkor on July 23, 2009, 12:04:30 am
I've got the module, but I could never make the damn thing work. I even tried the one posted in this thread.  I put the TXT file Everywhere lol.  Still no luck

Where are you changing settings to Null -1  ?
Title: Re: Trivia Module
Post by: Noevo on September 24, 2009, 12:47:39 am
Anyone have the trivia.txt file for this, or at the leas the format of the file?
Title: Re: Trivia Module
Post by: Meathooks on October 16, 2009, 04:52:34 am
I heard that people were asking about this mod .... so here you go :)

Title: Re: Trivia Module
Post by: clashbot on October 23, 2009, 01:16:26 pm
couldn't get to work either, but constantly refuses any commands on trivia except for  !set trivia and !help trivia

it's not giving me any error message concerning the location of the trivia.txt, so think that is working ok
Title: Re: Trivia Module
Post by: Meathooks on October 23, 2009, 03:39:37 pm
does the mod reply with anything for "!trivia ask"??
Title: Re: Trivia Module
Post by: clashbot on October 23, 2009, 06:46:27 pm
no just "tell <bot> help"
almost like the command wasn't registered
Title: Re: Trivia Module
Post by: shadowrik on January 18, 2010, 02:06:36 am
Thanks meathooks that is sooo awesome that you provided those files....tyvm tyvm
SimplePortal 2.3.7 © 2008-2024, SimplePortal