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 --- TConnection.cpp | 12 +++ TODO | 21 +++- TPluginParent.cpp | 6 +- conftest.cpp | 15 --- etc/autoload.conf | 3 - main.cpp | 40 -------- myfuncs.cpp | 7 ++ myfuncs.h | 1 + parseline.cpp | 89 ----------------- plugins/Makefile | 2 + plugins/alt/autoghost.cpp | 28 ------ plugins/alt/bar.cpp | 46 --------- plugins/alt/display.cpp | 23 ----- plugins/alt/display2.cpp | 23 ----- plugins/alt/foo.cpp | 66 ------------- plugins/alt/ircsend.cpp | 23 ----- plugins/alt/pong.cpp | 43 -------- plugins/alt/say.cpp | 45 --------- plugins/alt/send.cpp | 23 ----- plugins/alt/test.cpp | 22 ----- plugins/finddoubles.cpp | 142 ++++++++++++++++++++++----- plugins/finddoubles2 | Bin 34249 -> 0 bytes plugins/finddoubles2.cpp | 238 --------------------------------------------- plugins/greet.cpp | 31 ------ plugins/ops.cpp.additional | 1 - plugins/pass.cpp | 2 +- plugins/quit.cpp | 2 +- plugins/rejoin.cpp.stabil | 154 ----------------------------- test.conf | 6 -- todo.txt | 6 -- 30 files changed, 164 insertions(+), 956 deletions(-) delete mode 100644 conftest.cpp delete mode 100644 etc/autoload.conf delete mode 100644 parseline.cpp delete mode 100644 plugins/alt/autoghost.cpp delete mode 100644 plugins/alt/bar.cpp delete mode 100644 plugins/alt/display.cpp delete mode 100644 plugins/alt/display2.cpp delete mode 100644 plugins/alt/foo.cpp delete mode 100644 plugins/alt/ircsend.cpp delete mode 100644 plugins/alt/pong.cpp delete mode 100644 plugins/alt/say.cpp delete mode 100644 plugins/alt/send.cpp delete mode 100644 plugins/alt/test.cpp delete mode 100755 plugins/finddoubles2 delete mode 100644 plugins/finddoubles2.cpp delete mode 100644 plugins/greet.cpp delete mode 100644 plugins/ops.cpp.additional delete mode 100644 plugins/rejoin.cpp.stabil delete mode 100644 test.conf delete mode 100644 todo.txt diff --git a/TConnection.cpp b/TConnection.cpp index e73b088..eb1271b 100644 --- a/TConnection.cpp +++ b/TConnection.cpp @@ -652,6 +652,12 @@ void TConnection::deluser(string nick) bool TConnection::isuser(string nick) { + if (nick.find('!')==string::npos) + { + cout << "WARNING: called isuser() with stripped nick instead of raw_nick. returning false" << endl; + return false; + } + if ((users_li.isinlist(cut_nick(nick))) && (users_li.get_info(cut_nick(nick))!=nick)) //still logged in, but wrong hostmask? { cout << "removing '"<do("KICK", arg1, ...) auf returnval: -1=no such hook, -2 .. -inf = error, 0..inf=ok diff --git a/TPluginParent.cpp b/TPluginParent.cpp index a19f15b..81f4247 100644 --- a/TPluginParent.cpp +++ b/TPluginParent.cpp @@ -16,6 +16,7 @@ using namespace std; #include "TPluginParent.h" #include "TConnection.h" +#include "myfuncs.h" extern list plugins; @@ -35,9 +36,10 @@ void TPluginParent::hiddenaddplugincontext(int flags,int csize) } catch (...) { - cout << "PANIC: unable to create context data!" << endl; //todo: reaktion - cout << "HINT: this should N E V E R happen! you don't have even "< -#include "TConfig.h" - -using namespace std; - -int main() -{ - TConfig config; - - config.loadconfig("test.conf"); - - cout << config.get_valid_string("foo.bar.baz.str","default") << endl; - cout << config.get_valid_integer ("foo.bar.baz.int",1337) << endl; - cout << config.get_valid_boolean("foo.bar.baz.bool",false) << endl; -} diff --git a/etc/autoload.conf b/etc/autoload.conf deleted file mode 100644 index 3a4821a..0000000 --- a/etc/autoload.conf +++ /dev/null @@ -1,3 +0,0 @@ -send -postconnect - diff --git a/main.cpp b/main.cpp index a1fb2ba..06cbd2f 100644 --- a/main.cpp +++ b/main.cpp @@ -1,43 +1,3 @@ -/* T O D O: - * !votekick und !kick müssen best. kickfunktion aufrufen. die kann dann kickban und nach 3 sec unban oder sowas machen. - * !votekick kann usertest fragen, ob user wahlberechtigt ist. beides per messagebus - * - * ein plugin soll auf verschiedene commands ansprechen (z.B. !kick, !kickban etc) - * - * bei channels, bzw überall: die neue schöne parsemode funktion nutzen =) - * z.B. bei chanmodes: kann man durch parsen der mode-message lösen, dann sparen wir uns das MODE-senden - * - * neuladen von listen + conf via plugins (ermöglicht !useradd etc plugins) - * von listen nicht! nur listenfunktionen wie add/del etc anbieten! - * bot forken lassen (damit nohup wegfallen kann) - * user per nickserv identifizieren. user müssen passwort haben, "" gilt als deaktiviert - * !login ohne params guckt, ob identified, wenn ja, rechte geben - * !login passwort gibt immer rechte - * rechte nehmen bei nick, quit etc, bzw ggf. an den neuen nick weitergeben - * zurückgestellt, da nickserv auf freenode mieft. - * configfile verwenden! (sowohl im bot als auch in plugins!) - * - * - * - * verbinden modularisieren: der bot stellt NUR die verbindung zum server her. der rest (USER, NICK etc) wird über plugins erledigt - * message-system zwischen plugins. - * ansatz1: - * alle plugins haben zeiger auf ein einziges message-bus-objekt - * es kann neue nachrichten aufnehmen und bestehende nachrichten lesen. ggf auch ändern? (todo) - * die nachrichten sehen aus wie folgt: - * betreff, empfänger, daten. betreff ist ein enum, daten ein pointer. empfänger ist entweder ein pointer auf ein TPluginParent, oder NULL für alle. - * wenn eine connection eine nachricht erhält, muss sie diese an alle kinder (channels, sessions) weitergeben. - * plugins (bzw einzelne kontexte) können keine, bestimmte oder alle nachrichten empfangen lassen - * realisiert in DrunkenMan4. nicht wirklich benutzbar! - * !quit für master (=gesamten bot beenden) - * evtl. bannlisten??? (mode #channel +b) - * - * evtl sections in der configfile, oder andere kommentarzeichen ( # ist für channel!) - * oder irgendeine mögl., um #DrunkenMan.autorejoin=false zu setzen - * lösung: # muss am zeilenanfang oder nach einem leerzeichen stehen - * #channelname direkt ist eh sinnlos, muss freenode.net.#DrunkenMan sein. und dann passts ja =) - */ - #include #include #include diff --git a/myfuncs.cpp b/myfuncs.cpp index 4e28976..cbe8c2f 100644 --- a/myfuncs.cpp +++ b/myfuncs.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "myfuncs.h" @@ -226,3 +227,9 @@ int numchanperm (string m) return 0; } } + +void panic() +{ + cout << endl << "DrunkenMan panicked and commited suicide." << endl; + exit(1); +} diff --git a/myfuncs.h b/myfuncs.h index d5f2500..fbd3985 100644 --- a/myfuncs.h +++ b/myfuncs.h @@ -29,4 +29,5 @@ struct ircmode_t list parsemodes (string params); int numchanperm (string m); +void panic(); #endif diff --git a/parseline.cpp b/parseline.cpp deleted file mode 100644 index f993325..0000000 --- a/parseline.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// parseline.cpp -// -// Copyright 2010 Unknown -// -// 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 -#include "mytypes.h" - - -ircmessage parseline (string line) -{ - ircmessage temp; - int foundpos; - int pos; - - pos=0; - if (line.substr(0,1)==":") - { - foundpos=line.find (' ',0); - temp.origin=line.substr(1,foundpos-1); - pos=foundpos+1; - } - - foundpos=line.find(' ',pos); - if (foundpos==string::npos) - { - temp.command=line; - } - else - { - temp.command=line.substr(pos,foundpos-pos); - pos=foundpos+1; - if (line.substr(pos,1)==":") - { - temp.content=line.substr(pos+1); - } - else - { - foundpos=line.find(" :",pos); - if (foundpos!=string::npos) - { - temp.params=line.substr(pos,foundpos-pos); - temp.content=line.substr(foundpos+2); - } - else - { - temp.params=line.substr(pos); - } - } - } - //temp.origin=cut_nick(temp.origin); - - - return temp; -} - - -int main(int argc, char** argv) -{ - char foo[1000]; - string l; - ircmessage m; - cin.getline(foo, sizeof(foo)); - l=foo; -// cout << l; - m=parseline(l); - cout << "origin: " << m.origin << endl; - cout << "command: " << m.command << endl; - cout << "content: " << m.content << endl; - cout << "params: " << m.params << endl; - - return 0; -} diff --git a/plugins/Makefile b/plugins/Makefile index c881e08..7b16ded 100644 --- a/plugins/Makefile +++ b/plugins/Makefile @@ -4,6 +4,8 @@ all: %.so: %.cpp $(CXX) $(CXXFLAGS) -shared -o $@ $^ ../myfuncs.cpp +ops.so: ../TUserList.o + clean: rm *.so *.o diff --git a/plugins/alt/autoghost.cpp b/plugins/alt/autoghost.cpp deleted file mode 100644 index 5e57d57..0000000 --- a/plugins/alt/autoghost.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TPluginParentLight.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=PFLAGS_EXEC_ONANYEVENT | PFLAGS_EXEC_ONCREATE; *chandefault=0; *sessdefault=0; -} - -extern "C" void autoghost (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - //if (reason&PFLAGS_EXEC_ONANYEVENT) - // cout << msg.origin << ": " << msg.command << " " << msg.params << ": " << msg.content << endl; - cout << "connect YAY!" << reason << endl; - - if (reason&PFLAGS_EXEC_ONCREATE) - { - if (lcase(parent->get_ournick())!="drunkenman") - { - cout << "hey!" << endl; - } - } -} diff --git a/plugins/alt/bar.cpp b/plugins/alt/bar.cpp deleted file mode 100644 index b89e5ad..0000000 --- a/plugins/alt/bar.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * foo.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 "../TPluginParentLight.h" -#include "../mytypes.h" - -extern "C" int init() -{ - return 0; //wir brauchen keinen kontext! -} - -extern "C" void bar (plugincontext* context, ircmessage msg, TPluginParentLight* parent) -{ - cout << "context is "<pluginsend ("hier bin ich!"); - bool temp; - temp=parent->ismaster("flo|linux"); - if (temp) parent->pluginsend ("hallo meister"); - - parent->pluginsend ("und du bist " + parent->get_name() + "..?"); -} diff --git a/plugins/alt/display.cpp b/plugins/alt/display.cpp deleted file mode 100644 index 7bdc477..0000000 --- a/plugins/alt/display.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TPluginParentLight.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=PFLAGS_EXEC_ONANYEVENT | PFLAGS_EXEC_ONCREATE; *chandefault=0; *sessdefault=0; -} - -extern "C" void display (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - //if (ucase(msg.command)=="PRIVMSG") - if (reason&PFLAGS_EXEC_ONANYEVENT) - cout << msg.origin << ": " << msg.command << " " << msg.params << ": " << msg.content << endl; - - if (reason&PFLAGS_EXEC_ONCREATE) - cout << endl << "!!!!!!!!!!!!!!connected.!!!!!!!!!!!!!!" << endl << endl; -} diff --git a/plugins/alt/display2.cpp b/plugins/alt/display2.cpp deleted file mode 100644 index 257d821..0000000 --- a/plugins/alt/display2.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TPluginParentLight.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=PFLAGS_EXEC_ONANYEVENT | PFLAGS_EXEC_ONCREATE; *chandefault=0; *sessdefault=0; -} - -extern "C" void display2 (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - //if (ucase(msg.command)=="PRIVMSG") - if (reason&PFLAGS_EXEC_ONANYEVENT) - cout << msg.origin << ": " << msg.command << " " << msg.params << ": " << msg.content << endl; - - if (reason&PFLAGS_EXEC_ONCREATE) - cout << endl << "!!!!!!!!!!!!!!connected.!!!!!!!!!!!!!!" << endl << endl; -} diff --git a/plugins/alt/foo.cpp b/plugins/alt/foo.cpp deleted file mode 100644 index a62a6b6..0000000 --- a/plugins/alt/foo.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * foo.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 "../TPluginParent.h" - -//typedef void (*pluginfunc)(void* context, ircmessage msg); -//typedef int (*plugininitfunc)(); - -struct plugincontext -{ - int flags; //when it is executed, etc - bool exec_now; - void* data; //pointer to an area in the RAM where the plugin can write to - void* functions[10]; //array of pointers to various functions: - // say: (in case of chans: PRIVMSG chan; in case of nicks: PRIVMSG nick) - // send: send plain text to connection -}; - -struct ircmessage -{ - string origin; - string command; - string content; - string params; - - bool operator! () { return ((origin=="")&&(command=="")&&(content=="")&&(params=="")); } - operator bool () { return ((origin!="")||(command!="")||(content!="")||(params!="")); } -}; - - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - - return 0; //wir brauchen keinen kontext! -} - -extern "C" void foo (plugincontext* context, ircmessage msg, TPluginParent* parent) -{ - cout << "context is "<pluginsend ("hier bin ich!"); -} diff --git a/plugins/alt/ircsend.cpp b/plugins/alt/ircsend.cpp deleted file mode 100644 index 15a4dfd..0000000 --- a/plugins/alt/ircsend.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -#include "../TUserList.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND; *sessdefault=PFLAGS_EXEC_ONDEMAND; -} - -extern "C" void ircsend (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - if (reason&PFLAGS_EXEC_ONDEMAND) - if (ucase(msg.command)=="PRIVMSG") - if (parent->get_parent()->ismaster(msg.origin)) - parent->get_parent()->send (msg.content.substr(9)+NEWLINE); -} diff --git a/plugins/alt/pong.cpp b/plugins/alt/pong.cpp deleted file mode 100644 index de28d6b..0000000 --- a/plugins/alt/pong.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * foo.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 "../TPluginParentLight.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -int x; - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=PFLAGS_EXEC_ONANYEVENT; *chandefault=0; *sessdefault=0;//return 0; //wir brauchen keinen kontext! -} - -extern "C" void pong (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - if (ucase(msg.command)=="PING") - parent->pluginsend("PONG :" + msg.content); -} diff --git a/plugins/alt/say.cpp b/plugins/alt/say.cpp deleted file mode 100644 index ceb136c..0000000 --- a/plugins/alt/say.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * foo.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 "../TPluginParentLight.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND | PFLAGS_EXEC_ONCREATE; *sessdefault=PFLAGS_EXEC_ONDEMAND | PFLAGS_EXEC_ONCREATE; -} - -extern "C" void say (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - //if (ucase(msg.command)=="PRIVMSG") - if (reason&PFLAGS_EXEC_ONDEMAND) - parent->pluginsay (msg.origin+"> "+msg.content+"!"); - - if (reason&PFLAGS_EXEC_ONCREATE) - parent->pluginsay ("welcome!"); -} diff --git a/plugins/alt/send.cpp b/plugins/alt/send.cpp deleted file mode 100644 index 6704d93..0000000 --- a/plugins/alt/send.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -#include "../TUserList.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND; *sessdefault=PFLAGS_EXEC_ONDEMAND; -} - -extern "C" void ircsend (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - if (reason&PFLAGS_EXEC_ONDEMAND) - if (ucase(msg.command)=="PRIVMSG") - if (parent->get_parent()->ismaster(msg.origin)) - parent->say ("."+msg.content.substr(5)+"."); -} diff --git a/plugins/alt/test.cpp b/plugins/alt/test.cpp deleted file mode 100644 index de77b64..0000000 --- a/plugins/alt/test.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -#include "../TUserList.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=0; *chandefault=PFLAGS_EXEC_ONEVENT; *sessdefault=0; -} - -extern "C" void test (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - if (reason&PFLAGS_EXEC_ONEVENT) - if (parent->get_parent()->ismaster(msg.origin)) - parent->say (ucase("hallo meister!")); -} 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; } } } + diff --git a/plugins/finddoubles2 b/plugins/finddoubles2 deleted file mode 100755 index 3b37fa3..0000000 Binary files a/plugins/finddoubles2 and /dev/null differ diff --git a/plugins/finddoubles2.cpp b/plugins/finddoubles2.cpp deleted file mode 100644 index 642bd9c..0000000 --- a/plugins/finddoubles2.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * 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 - -using namespace std; - -#include -#include -#include - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.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(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*) ( (vector **) ( (string**) ( (char*) context->data +1) +1) +1); - if (reason&PFLAGS_EXEC_ONDEMAND) - { - if (ucase(msg.command)=="PRIVMSG") - { - if (*((char*)(context->data)) != 0) - { - 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 - { - string chan=ntharg(msg.content,2); - if (trim(chan)=="") - { - parent->say("you have to specify a channel name!"); - } - else - { -// parent->say ("/names "+chan+"..."); - parent->get_parent()->send("names "+chan+NEWLINE); - context->flags|=PFLAGS_EXEC_ONANYEVENT; - *((char*)(context->data)) = 1; - string* chanptr=new string(chan); - - string** cptrdest; - cptrdest= (string**) ((char*) context->data + 1); - - *cptrdest=chanptr; - - vector **lptr= (vector **) ((string**)(((char*) context->data+1))+1); - - *lptr=new vector; - - *whoiscnt=0; - } - } - } - } - - if (reason&PFLAGS_EXEC_ONANYEVENT) - { - 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()); - if (numcmd==353) - { - if (lcase(msg.params.substr(msg.params.rfind(' ')+1))==lcase(name)) - { - string temp; - string temp2=msg.content; - while ((temp=split(temp2))!="") - { - if ((temp[0]=='+') || (temp[0]=='@')) - temp=temp.substr(1); - //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)++; - } - } - } - if (numcmd==366) - { -// parent->say ("fertig empfangen..."); - *((char*)(context->data)) = 2; - } - - if (numcmd==311) - { -// parent->say ("whoisantwort für "+ntharg(msg.params,2)+": "+ntharg(msg.params,4)); - - vector::iterator pos; - - if ((pos=whereinlist(liste, ntharg(msg.params,2)))!=liste->end()) - { - pos->host=ntharg(msg.params,4); - // liste->edit (ntharg(msg.params,2),ntharg(msg.params,4)); - (*whoiscnt)--; - } - } - - //cout << "DEBUG: " << *whoiscnt << "," << *((char*)(context->data)) << endl; - - if ((*whoiscnt==0)&&(*((char*)(context->data))==2)) - { - int sz=liste->size(); - int cnt; - - string saytemp; - bool shared=false; - - for (int i=0; i1) - { - parent->say(tostring(cnt)+" people are sharing the hostmask "+(*liste)[i].host+": "+saytemp); - shared=true; - } - } - - - 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; - } - - - } -} - diff --git a/plugins/greet.cpp b/plugins/greet.cpp deleted file mode 100644 index 8ac5820..0000000 --- a/plugins/greet.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include -#include - -using namespace std; - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -#include "../TUserList.h" -#include "../mytypes.h" -#include "../myfuncs.h" - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=0; *conndefault=0; *chandefault=PFLAGS_EXEC_ONDEMAND; *sessdefault=0; -} - -extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, int reason) -{ - if (reason&PFLAGS_EXEC_ONDEMAND) - if (ucase(msg.command)=="PRIVMSG") - if (parent->get_parent()->isuser(msg.origin)) - { - list foo=parent->get_parent()->get_channel_users(parent->get_name()).give_list(); - for (list::iterator it=foo.begin(); it!=foo.end(); it++) - parent->say ("hello, "+*it+"!"); - } - else - { - parent->say ("sorry, you aren't a user, "+msg.origin+"!"); - } -} diff --git a/plugins/ops.cpp.additional b/plugins/ops.cpp.additional deleted file mode 100644 index 9b4ecc3..0000000 --- a/plugins/ops.cpp.additional +++ /dev/null @@ -1 +0,0 @@ -../TUserList.o diff --git a/plugins/pass.cpp b/plugins/pass.cpp index 79db2e1..1429fc5 100644 --- a/plugins/pass.cpp +++ b/plugins/pass.cpp @@ -21,7 +21,7 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig cout << "foo" << endl; if (reason&PFLAGS_EXEC_ONDEMAND) { - if (parent->get_parent()->ismaster(msg.origin)) + if (parent->get_parent()->ismaster(msg.origin_raw)) { cout << "bar" << endl; parent->say("processing..."); diff --git a/plugins/quit.cpp b/plugins/quit.cpp index 9bb410d..71c2a3c 100644 --- a/plugins/quit.cpp +++ b/plugins/quit.cpp @@ -18,7 +18,7 @@ extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLig { if (reason&PFLAGS_EXEC_ONDEMAND) if (ucase(msg.command)=="PRIVMSG") - if (parent->get_parent()->ismaster(msg.origin)) + if (parent->get_parent()->ismaster(msg.origin_raw)) parent->get_parent()->quit(msg.origin+" told me to quit. cya!"); //parent->get_parent()->send (msg.content.substr(6)+NEWLINE); } diff --git a/plugins/rejoin.cpp.stabil b/plugins/rejoin.cpp.stabil deleted file mode 100644 index 3098668..0000000 --- a/plugins/rejoin.cpp.stabil +++ /dev/null @@ -1,154 +0,0 @@ -/* TODO - * 470 forwarding to another channel implementieren - * evtl timeout implementieren - * aus config folgendes lesen: - * rejoinen? - * wie lange warten? - * - */ - -#include -#include -#include - -using namespace std; - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -#include "../TUserList.h" -#include "../mytypes.h" -#include "../myfuncs.h" -#include "../TConfigReadOnly.h" - -struct entry_t -{ - char state; - int wait; - time_t last; - string name; -}; - -extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault) -{ - *csize=sizeof(list*); - *conndefault=PFLAGS_EXEC_ONEVENT; *chandefault=0; *sessdefault=0; -} - -extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, TConfigReadOnly& config, int reason) -{ - list *liste=*static_cast **>(context->data); - if (liste==0) - { - liste=new list; - *static_cast **>(context->data)=liste; - } - - if (reason&PFLAGS_EXEC_ONEVENT) - { - if ((msg.command=="KICK") && (lcase(ntharg(msg.params,2))==lcase(parent->get_parent()->get_nick()))) //wir wurden gekickt? sauerei! - { - cout << "we got kicked from " << ntharg(msg.params,1) << endl; - if (config.get_valid_boolean(parent->get_parent()->get_networkname() + "." + ntharg(msg.params,1) + ".rejoin", false)) - { - cout << " trying to rejoin" << endl; - - entry_t tmp; - tmp.state=1; - tmp.last=time(NULL)+1; //fake time to wait 1 second ONCE - tmp.wait=0; - tmp.name=ntharg(msg.params,1); - liste->push_back(tmp); - - context->flags |= PFLAGS_EXEC_ALWAYS; - } - } - //evtl aus datei lesen? -// parent->get_parent()->send ("join #DrunkenMan" NEWLINE); - -// if (config.is_string(parent->get_parent()->get_networkname()+".pass")) -// parent->get_parent()->send("PRIVMSG NickServ :identify "+config.get_string(parent->get_parent()->get_networkname()+".nick")+" "+config.get_string(parent->get_parent()->get_networkname()+".pass")); - - } - - if (reason&PFLAGS_EXEC_ALWAYS) - { - for (list::iterator it=liste->begin(); it!=liste->end(); it++) - { - switch (it->state) - { - case 1: - if (time(NULL)>(it->last+it->wait)) - { - cout << "DEBUG: waiting is over" << endl; - parent->get_parent()->send("join "+it->name); - it->state=2; - } - break; - case 2: //waiting for JOIN answer - if ((ucase(msg.command)=="JOIN") && (ucase(msg.origin)==ucase(parent->get_parent()->get_nick()))) - { - it->state=99; - cout << "!!!!!!!SUCCESS" << endl; - } - else - { - if ((lcase(ntharg(msg.params,1))==lcase(parent->get_parent()->get_nick())) && (lcase(ntharg(msg.params, 2))==lcase(it->name))) - { - cout << "!!!!!!!!betrifft uns" << endl; - int numcmd=atoi(msg.command.c_str()); - switch (numcmd) - { - case 471: //channel is full - it->last=time(NULL); - it->state=1; - it->wait++; - break; - case 473: //inviteonly - parent->get_parent()->send("PRIVMSG ChanServ :invite "+it->name); - it->state=3; - break; - case 474: //banned - parent->get_parent()->send("PRIVMSG ChanServ :unban "+it->name); - it->state=3; - break; - case 475: //bad key, no such chan, too many chans. fatal. - case 403: - case 405: - it->state=99; - cout << "!!!!!!!!!FATAL" << endl; - break; - } - } - } - break; - - case 3: //waiting for CHANSERV answer - if ( ((msg.command=="401") && (ucase(ntharg(msg.params,2))=="CHANSERV")) || ((msg.command=="NOTICE") && (ucase(msg.origin)=="CHANSERV")) ) - { - //answer arrived or no chanserv? - it->last=time(NULL); - it->state=1; - } - - break; - } - } - - bool temp=true; - while (temp) - { - temp=false; - for (list::iterator it=liste->begin(); it!=liste->end(); it++) - { - if (it->state==99) - { - cout << "cleanup: removing entry for channel " << it->name << "..." << endl; - liste->erase(it); - temp=true; - break; - } - } - } - - } -} diff --git a/test.conf b/test.conf deleted file mode 100644 index 3963a92..0000000 --- a/test.conf +++ /dev/null @@ -1,6 +0,0 @@ -#str="hello" -#foo.bar.str="lol" -foo.bar.int=99l -#int=123 -foo.bar.baz.bool=ja -#bool=yes diff --git a/todo.txt b/todo.txt deleted file mode 100644 index 6079228..0000000 --- a/todo.txt +++ /dev/null @@ -1,6 +0,0 @@ -main.cpp: //dann sessions/channels kontrollieren lassen, ob diese nachricht interessant für diese ist (todo: names etc erkennen) -main.cpp: //pluginsend: im falle eines channels: notice oder privmsg oder ggf weitere channel-verwandte befehle (names #chan etc) (todo!) -TConnection.cpp: // TODO: ONCREATE -TConnection.cpp: return ""; //todo: oder servername? -TPluginParent.cpp: cout << "PANIC: unable to create context data!" << endl; //todo: reaktion -TSession.cpp: bool TSession::valid() //todo -- cgit v1.2.1