slapme.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
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 }