From dacd393fefeabafd1306533dd6c5a56e0ab347cc Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Sun, 27 Feb 2011 18:48:35 +0100 Subject: Initial commit --- plugins/antirejoin.cpp | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 plugins/antirejoin.cpp (limited to 'plugins/antirejoin.cpp') diff --git a/plugins/antirejoin.cpp b/plugins/antirejoin.cpp new file mode 100644 index 0000000..a26d70d --- /dev/null +++ b/plugins/antirejoin.cpp @@ -0,0 +1,88 @@ +/* TODO + * timeout per config + * anzahl der nötigen votes per config + * anzahl evtl relativ? in % der aktiven user? oder in % der gesamtuser? + */ + +/* + * say.cpp + * + * Copyright 2009 Florian + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + */ + + +#include +#include + +using namespace std; + +#include "../TConnectionInterface.h" +#include "../TPluginParentLight.h" +#include "../TUserList.h" +#include "../mytypes.h" +#include "../myfuncs.h" + +#include + +#define TIMEOUT 4 + +extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) +{ + *csize=sizeof(map *); *conndefault=0; *chandefault=PFLAGS_EXEC_ONEVENT; *sessdefault=0; +} + +extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, TConfigReadOnly& config, int reason) +{ + map *liste=*static_cast**>(context->data); + if (liste==NULL) + { + liste=new map; + *static_cast**>(context->data)=liste; + } + + if (reason&PFLAGS_EXEC_ONEVENT) + { + if (ucase(msg.command)=="KICK") + { + (*liste) [lcase(ntharg(msg.params,2))]=time(NULL); + } + if (ucase(msg.command)=="JOIN") + { + if (liste->find(lcase(msg.origin))!=liste->end()) + if (time(NULL) < (*liste)[lcase(msg.origin)] +TIMEOUT ) + { + parent->get_parent()->send("mode "+parent->get_name()+" +b "+msg.origin); + parent->get_parent()->send("kick "+parent->get_name()+" "+msg.origin+" :do not autorejoin"); + } + } + + map::iterator it, it2; + for (it=liste->begin(); it!=liste->end();) + { + if (time(NULL) > it->second +TIMEOUT) + { + cout << "erasing entry for " << it->first << "..." << endl; + it2=it; + it++; + liste->erase(it2); + } + else + it++; + } + } +} -- cgit v1.2.1