From 74377ece178e661194a40fa79238b3089bb0d0f2 Mon Sep 17 00:00:00 2001 From: Florian Jung Date: Mon, 28 Feb 2011 18:48:58 +0100 Subject: Cleaned up unneeded files, some bugfixes ismaster/isuser now gets called with origin_raw --- plugins/finddoubles.cpp | 142 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 26 deletions(-) (limited to 'plugins/finddoubles.cpp') diff --git a/plugins/finddoubles.cpp b/plugins/finddoubles.cpp index f98a18f..642bd9c 100644 --- a/plugins/finddoubles.cpp +++ b/plugins/finddoubles.cpp @@ -26,30 +26,76 @@ using namespace std; #include #include - -using namespace std; +#include #include "../TConnectionInterface.h" #include "../TPluginParentLight.h" -#include "../TUserList.h" +//#include "../TUserList.h" +#include #include "../mytypes.h" #include "../myfuncs.h" +struct whoisinfo +{ + string who; + string host; + bool proc; +}; + +inline std::string tostring(int x) + { + std::ostringstream o; + if (!(o << x)) + throw; + return o.str(); + } + +vector::iterator whereinlist(vector* l, string s) +{ + for (vector::iterator i=l->begin();i!=l->end();i++) + if ( lcase( i->who ) == lcase(s) ) + return i; + + return l->end(); +} + extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) { - *csize=sizeof(char)+sizeof(string *)+sizeof(TUserList *)+sizeof(int); *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND; *sessdefault=PFLAGS_EXEC_ONDEMAND; + *csize=sizeof(char)+sizeof(string *)+sizeof(vector *)+sizeof(int); *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND; *sessdefault=PFLAGS_EXEC_ONDEMAND; } extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) { - int* whoiscnt=(int*) ( (TUserList**) ( (string**) ( (char*) context->data +1) +1) +1); + int* whoiscnt=(int*) ( (vector **) ( (string**) ( (char*) context->data +1) +1) +1); if (reason&PFLAGS_EXEC_ONDEMAND) { if (ucase(msg.command)=="PRIVMSG") { if (*((char*)(context->data)) != 0) { - parent->say("sorry, try again later."); + if (lcase(trim(ntharg(msg.content,2)))=="abort") + { + parent->say ("aborted for channel "+** ((string**)((char*)context->data+1))); + + string ** cptrdest= (string**) ((char*) context->data + 1); + if (*cptrdest) + delete (*cptrdest); + *cptrdest=NULL; + + vector **lptr= (vector **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector; + if (*lptr) + delete (*lptr); + *lptr=NULL; + + *((char*)(context->data))=0; + + context->flags=PFLAGS_EXEC_ONDEMAND; + } + else + { + parent->say("sorry, try again later."); + } } else { @@ -71,16 +117,11 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig *cptrdest=chanptr; - TUserList** lptr= (TUserList**) ((string**)(((char*) context->data+1))+1); - - *lptr=new TUserList; - cout << "lptr=" << lptr <<"/" << *lptr << endl; + vector **lptr= (vector **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector; *whoiscnt=0; -// parent->say ("exiting commandmode"); - //((string**)((char*)context->data+1))=chanptr; - //*((string*) ((char*)context->data + 1))=chanptr; } } } @@ -88,8 +129,9 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig if (reason&PFLAGS_EXEC_ONANYEVENT) { - TUserList** lptr= (TUserList**) ((string**)(((char*) context->data+1))+1); - TUserList* liste=*lptr; + vector** lptr= (vector**) ((string**)(((char*) context->data+1))+1); + vector* liste=*lptr; + string name; name= ** ((string**)((char*)context->data+1)); int numcmd=atoi(msg.command.c_str()); @@ -103,7 +145,14 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig { if ((temp[0]=='+') || (temp[0]=='@')) temp=temp.substr(1); - liste->addtolist(temp); + //liste->addtolist(temp); + + whoisinfo structtemp; + structtemp.who=temp; + structtemp.host=""; + structtemp.proc=false; + liste->push_back(structtemp); + parent->get_parent()->send("whois "+temp+NEWLINE); (*whoiscnt)++; } @@ -111,16 +160,20 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig } if (numcmd==366) { - parent->say ("fertig empfangen..."); +// parent->say ("fertig empfangen..."); *((char*)(context->data)) = 2; } if (numcmd==311) { // parent->say ("whoisantwort für "+ntharg(msg.params,2)+": "+ntharg(msg.params,4)); - if (liste->isinlist(ntharg(msg.params,2))) + + vector::iterator pos; + + if ((pos=whereinlist(liste, ntharg(msg.params,2)))!=liste->end()) { - liste->edit (ntharg(msg.params,2),ntharg(msg.params,4)); + pos->host=ntharg(msg.params,4); + // liste->edit (ntharg(msg.params,2),ntharg(msg.params,4)); (*whoiscnt)--; } } @@ -129,20 +182,57 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig if ((*whoiscnt==0)&&(*((char*)(context->data))==2)) { - parent->say ("fertig! YAY!"); - *((char*)(context->data))=0; + int sz=liste->size(); + int cnt; + + string saytemp; + bool shared=false; -/* list nicks = liste->give_list(); - list add = liste->give_additional(); + for (int i=0; i1) + { + parent->say(tostring(cnt)+" people are sharing the hostmask "+(*liste)[i].host+": "+saytemp); + shared=true; + } + } - list::iterator it1,it2; - it1=nicks.begin(); - it2=add.begin();*/ + if (!shared) + parent->say("there were no people sharing a hostmask in " + (** ((string**)((char*)context->data+1)))+"."); + + + string ** cptrdest= (string**) ((char*) context->data + 1); + if (*cptrdest) + delete (*cptrdest); + *cptrdest=NULL; + vector **lptr= (vector **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector; + if (*lptr) + delete (*lptr); + *lptr=NULL; + + *((char*)(context->data))=0; + context->flags=PFLAGS_EXEC_ONDEMAND; } } } + -- cgit v1.2.1