slapme.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 "slapme.h"
00030 
00034 Slapme::Slapme(BotKernel*b)
00035 {
00036         this->author = "eponyme";
00037         this->description = "slaps users";
00038         this->version = VERSION;
00039         this->name = "slapme";
00040    this->bindFunction("slapme",IN_COMMAND_HANDLER,"slapme",0,10);
00041 }
00042 
00043 extern "C"
00044 {
00045         Plugin *contruct_slapme(BotKernel*b)
00046         {
00047                 return new Slapme(b);
00048         }
00049         void destroy_slapme(Plugin*p)
00050         {
00051                 delete p;
00052         }
00053    bool slapUser(Message*m,Plugin*p,BotKernel*b)
00054    {
00055       b->send( IRCProtocol::sendAction(m->getSource(),"slaps "+m->getNickSender()+" : "+Tools::vectorToString(m->getSplit()," ",5)) ) ;
00056       return true;
00057    }
00058         bool slapme (Message*m,Plugin*p,BotKernel*b)
00059         {
00060       unsigned int seconds;
00061       if (m->isPublic() && (m->nbParts()>5) ) {   
00062          seconds = Tools::strtimeToSeconds(m->getPart(4)) ;
00063          if(b->addCountDown(p,slapUser,m,seconds,5)==NULL) {
00064             b->send(IRCProtocol::sendNotice(m->getNickSender(),"Error, too many count downs are running"));
00065          }
00066          else {
00067             b->send( IRCProtocol::sendNotice(m->getNickSender(),"slap in "+Tools::intToStr(seconds)+" seconds added."  ) );
00068          }
00069       }
00070                 return true;
00071         }
00072 }

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