collapse collapse
* User Info
 
 
Welcome, Guest. Please login or register.
* Search

* Board Stats
  • stats Total Members: 989
  • stats Total Posts: 18366
  • stats Total Topics: 2501
  • stats Total Categories: 7
  • stats Total Boards: 35
  • stats Most Online: 1144

Author Topic: Trivia Module  (Read 36250 times)

0 Members and 1 Guest are viewing this topic.

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Trivia Module
« 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/

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


Offline Temar

  • Contributor
  • *******
  • Posts: 1140
  • Karma: +0/-0
    • AoFiles
Re: Trivia Module
« Reply #1 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

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Trivia Module
« Reply #2 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

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Trivia Module
« Reply #3 on: February 27, 2009, 07:50:10 am »
Does anyone have the Trivia module working?

Wizhk

Offline Jiheld

  • BeBot User
  • **
  • Posts: 53
  • Karma: +0/-0
Re: Trivia Module
« Reply #4 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


Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Trivia Module
« Reply #5 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.

Offline Jiheld

  • BeBot User
  • **
  • Posts: 53
  • Karma: +0/-0
Re: Trivia Module
« Reply #6 on: March 02, 2009, 01:57:04 pm »
me too, you sure you have the .txt file in the right folder?

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Trivia Module
« Reply #7 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

Offline Jiheld

  • BeBot User
  • **
  • Posts: 53
  • Karma: +0/-0
Re: Trivia Module
« Reply #8 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;          
   }
}
?>

Offline Wizhk

  • BeBot Apprentice
  • ***
  • Posts: 85
  • Karma: +0/-0
Re: Trivia Module
« Reply #9 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

Offline Jiheld

  • BeBot User
  • **
  • Posts: 53
  • Karma: +0/-0
Re: Trivia Module
« Reply #10 on: March 04, 2009, 07:07:02 pm »
I putted mine in the txt folder.

Glad it works now.


Offline Huesos

  • BeBot User
  • **
  • Posts: 45
  • Karma: +0/-0
Re: Trivia Module
« Reply #11 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

Offline Vulkor

  • BeBot User
  • **
  • Posts: 20
  • Karma: +0/-0
Re: Trivia Module
« Reply #12 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  ?
« Last Edit: July 23, 2009, 12:12:14 am by Vulkor »

Offline Noevo

  • BeBot Rookie
  • *
  • Posts: 8
  • Karma: +0/-0
Re: Trivia Module
« Reply #13 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?

Offline Meathooks

  • BeBot Rookie
  • *
  • Posts: 3
  • Karma: +0/-0
Re: Trivia Module
« Reply #14 on: October 16, 2009, 04:52:34 am »
I heard that people were asking about this mod .... so here you go :)


 

* Recent Posts
Com bot module by bitnykk
[November 25, 2024, 05:36:11 pm ]


0.8.x updates for AO by bitnykk
[June 23, 2024, 03:19:47 pm ]


0.8.x updates for AoC by bitnykk
[June 23, 2024, 03:19:44 pm ]


[AoC] special char for items module by bitnykk
[February 09, 2024, 09:41:18 pm ]


BeBot still alive & kicking ! by bitnykk
[December 17, 2023, 12:58:44 am ]

* Who's Online
  • Dot Guests: 127
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.
* Forum Staff
bitnykk admin bitnykk
Administrator
Khalem admin Khalem
Administrator
WeZoN gmod WeZoN
Global Moderator
SimplePortal 2.3.7 © 2008-2024, SimplePortal