magic8ball.cpp

Go to the documentation of this file.
00001 /*
00002 #########################################################################
00003 #
00004 #  This file is part of trustyRC.
00005 #
00006 #  trustyRC, fully modular IRC robot 
00007 #  Copyright (C) 2006-2008 Nicoleau Fabien 
00008 #
00009 #  trustyRC is free software: you can redistribute it and/or modify
00010 #  it under the terms of the GNU General Public License as published by
00011 #  the Free Software Foundation, either version 3 of the License, or
00012 #  (at your option) any later version.
00013 #
00014 #  trustyRC is distributed in the hope that it will be useful,
00015 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 #  GNU General Public License for more details.
00018 #
00019 #  You should have received a copy of the GNU General Public License
00020 #  along with trustyRC.  If not, see <http://www.gnu.org/licenses/>.
00021 #
00022 #########################################################################
00023 */
00024 
00029 #include "magic8ball.h"
00030 
00034 Magic8Ball::Magic8Ball(BotKernel*b)
00035 {
00036         this->author = "eponyme";
00037         this->description = "magic 8 ball game";
00038         this->version = VERSION;
00039         this->name = "magic8ball";
00040         this->bindFunction("8ball",IN_COMMAND_HANDLER,"ball",0,10);
00041 
00042    this->answers[0] = "As I see it, yes" ;
00043    this->answers[1] = "Ask again later" ;
00044    this->answers[2] = "Better not tell you now" ;
00045    this->answers[3] = "Cannot predict now" ;
00046    this->answers[4] = "Concentrate and ask again" ;
00047    this->answers[5] = "Don't count on it" ;
00048    this->answers[6] = "It is certain" ;
00049    this->answers[7] = "It is decidedly so" ;
00050    this->answers[8] = "Most likely" ;
00051    this->answers[9] = "My reply is no" ;
00052    this->answers[10] = "My sources say no" ;
00053    this->answers[11] = "Outlook good" ;
00054    this->answers[12] = "Outlook not so good" ;
00055    this->answers[13] = "Reply hazy, try again" ;
00056    this->answers[14] = "Signs point to yes" ;
00057    this->answers[15] = "Very doubtful" ;
00058    this->answers[16] = "Without a doubt" ;
00059    this->answers[17] = "Yes" ;
00060    this->answers[18] = "Yes - definitely" ;
00061    this->answers[19] = "You may rely on it" ;
00062 }
00063 
00068 string Magic8Ball::getRandomAnswer() {
00069    return this->answers[Tools::random(0,19)];
00070 }
00071 
00072 extern "C"
00073 {
00074         Plugin *contruct_magic8ball(BotKernel*b)
00075         {
00076                 return new Magic8Ball(b);
00077         }
00078         void destroy_magic8ball(Plugin*p)
00079         {
00080                 delete p;
00081         }
00082         bool ball (Message*m,Plugin*p,BotKernel*b)
00083         {
00084       Magic8Ball* mb = (Magic8Ball*) p;
00085       if (m->isPublic()&&(m->nbParts() >= 5)) {
00086          b->send( IRCProtocol::sendMsg(m->getSource(),mb->getRandomAnswer() ) );
00087       }
00088                 return true;
00089         }
00090 }

Generated on Sun Aug 16 15:28:28 2009 for trustyRC by  doxygen 1.5.8