diff options
author | Florian Jung <flo@thinkpad.(none)> | 2011-02-28 18:48:58 +0100 |
---|---|---|
committer | Florian Jung <flo@thinkpad.(none)> | 2011-02-28 18:48:58 +0100 |
commit | 74377ece178e661194a40fa79238b3089bb0d0f2 (patch) | |
tree | a1313c5518c5304b90396ef6ed3c04088e8fefe0 | |
parent | d26ab5f2338aaf07289dd57c7770f85a79cf7b2b (diff) |
Cleaned up unneeded files, some bugfixes
ismaster/isuser now gets called with origin_raw
-rw-r--r-- | TConnection.cpp | 12 | ||||
-rw-r--r-- | TODO | 21 | ||||
-rw-r--r-- | TPluginParent.cpp | 6 | ||||
-rw-r--r-- | conftest.cpp | 15 | ||||
-rw-r--r-- | etc/autoload.conf | 3 | ||||
-rw-r--r-- | main.cpp | 40 | ||||
-rw-r--r-- | myfuncs.cpp | 7 | ||||
-rw-r--r-- | myfuncs.h | 1 | ||||
-rw-r--r-- | parseline.cpp | 89 | ||||
-rw-r--r-- | plugins/Makefile | 2 | ||||
-rw-r--r-- | plugins/alt/autoghost.cpp | 28 | ||||
-rw-r--r-- | plugins/alt/bar.cpp | 46 | ||||
-rw-r--r-- | plugins/alt/display.cpp | 23 | ||||
-rw-r--r-- | plugins/alt/display2.cpp | 23 | ||||
-rw-r--r-- | plugins/alt/foo.cpp | 66 | ||||
-rw-r--r-- | plugins/alt/ircsend.cpp | 23 | ||||
-rw-r--r-- | plugins/alt/pong.cpp | 43 | ||||
-rw-r--r-- | plugins/alt/say.cpp | 45 | ||||
-rw-r--r-- | plugins/alt/send.cpp | 23 | ||||
-rw-r--r-- | plugins/alt/test.cpp | 22 | ||||
-rw-r--r-- | plugins/finddoubles.cpp | 142 | ||||
-rwxr-xr-x | plugins/finddoubles2 | bin | 34249 -> 0 bytes | |||
-rw-r--r-- | plugins/finddoubles2.cpp | 238 | ||||
-rw-r--r-- | plugins/greet.cpp | 31 | ||||
-rw-r--r-- | plugins/ops.cpp.additional | 1 | ||||
-rw-r--r-- | plugins/pass.cpp | 2 | ||||
-rw-r--r-- | plugins/quit.cpp | 2 | ||||
-rw-r--r-- | plugins/rejoin.cpp.stabil | 154 | ||||
-rw-r--r-- | test.conf | 6 | ||||
-rw-r--r-- | todo.txt | 6 |
30 files changed, 164 insertions, 956 deletions
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 '"<<cut_nick(nick)<<"' from list of logged in users due to a hostmask mismatch" << endl; @@ -673,6 +679,12 @@ void TConnection::delmaster(string nick) bool TConnection::ismaster(string nick) { + if (nick.find('!')==string::npos) + { + cout << "WARNING: called ismaster() with stripped nick instead of raw_nick. returning false" << endl; + return false; + } + if ((masters_li.isinlist(cut_nick(nick))) && (masters_li.get_info(cut_nick(nick))!=nick)) //still logged in, but wrong hostmask? { cout << "removing '"<<cut_nick(nick)<<"' from list of logged in masters due to a hostmask mismatch" << endl; @@ -1,4 +1,23 @@ - o unter git stellen + o !votekick und !kick müssen best. kickfunktion aufrufen. die kann dann + kickban und nach 3 sec unban oder sowas machen. + o benutzergruppen; z.B. votekick-wahlberechtigt? + + o ein plugin soll auf verschiedene commands ansprechen können + (z.B. !kick, !kickban etc) + + + o neuladen von listen + conf via plugins + o listenfunktionen: add/del z.B.(useradd, userdel) + o bot forken lassen (damit nohup wegfallen kann) + o user per nickserv identifizieren, alternative: passwort + o alle plugins sollen configfile nutzen + + + o bannlisten??? (mode #channel +b) + + o einige sachen können mit maps besser gelöst werden + o DrunkenMan[,:] do_sth statt !do_sth als befehl-prefix + channel und session ist dafür relevant o slot- oder hook-konzept: plugins senden nicht mehr "KICK :foo", sondern rufen parent->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<TPlugin*> 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 "<<csize<<"bytes RAM free!" << endl; + cout << "PANIC: unable to create context data!" << endl; + cout << "HINT: this should N E V E R happen! you don't have even "<<csize<<"bytes of RAM free!" << endl; cout << " consider rebooting your machine as soon as possible!" << endl; + panic(); cptr=NULL; } else diff --git a/conftest.cpp b/conftest.cpp deleted file mode 100644 index 1dbb183..0000000 --- a/conftest.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include <iostream> -#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 - @@ -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 <list> #include <string> #include <fstream> diff --git a/myfuncs.cpp b/myfuncs.cpp index 4e28976..cbe8c2f 100644 --- a/myfuncs.cpp +++ b/myfuncs.cpp @@ -11,6 +11,7 @@ #include <netdb.h> #include <cstring> #include <dlfcn.h> +#include <cstdlib> #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); +} @@ -29,4 +29,5 @@ struct ircmode_t list<ircmode_t> 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 <flo@arch> -// -// 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 <iostream> -#include <string> -#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 <iostream> -#include <string> - -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 <flo@localhost.localdomain> - * - * 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 <iostream> -#include <string> - -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 "<<context<<endl; - cout << "message is: "<<msg.origin<<"|"<<msg.command<<"|"<<msg.params<<"|"<<msg.content<<"|"<<endl; - parent->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 <iostream> -#include <string> - -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 <iostream> -#include <string> - -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 <flo@localhost.localdomain> - * - * 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 <iostream> -#include <string> - -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 "<<context<<endl; - cout << "message is: "<<msg.origin<<"|"<<msg.command<<"|"<<msg.params<<"|"<<msg.content<<"|"<<endl; - parent->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 <iostream> -#include <string> - -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 <flo@localhost.localdomain> - * - * 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 <iostream> -#include <string> - -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 <flo@localhost.localdomain> - * - * 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 <iostream> -#include <string> - -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 <iostream> -#include <string> - -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 <iostream> -#include <string> - -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 <iostream> #include <string> - -using namespace std; +#include <sstream> #include "../TConnectionInterface.h" #include "../TPluginParentLight.h" -#include "../TUserList.h" +//#include "../TUserList.h" +#include <vector> #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<whoisinfo>::iterator whereinlist(vector<whoisinfo>* l, string s) +{ + for (vector<whoisinfo>::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<whoisinfo> *)+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<whoisinfo> **) ( (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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector<whoisinfo>; + 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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector<whoisinfo>; *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<whoisinfo>** lptr= (vector<whoisinfo>**) ((string**)(((char*) context->data+1))+1); + vector<whoisinfo>* 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<whoisinfo>::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<string> nicks = liste->give_list(); - list<string> add = liste->give_additional(); + for (int i=0; i<sz; i++) + { + saytemp=(*liste)[i].who; + cnt=1; + if ( (*liste)[i].proc == false ) + { + for (int j=i+1; j<sz; j++) + { + if ( (*liste)[i].host == (*liste)[j].host ) + { + saytemp+=", "+(*liste)[j].who; + cnt++; + (*liste)[i].proc=true; + } + } + } + if (cnt>1) + { + parent->say(tostring(cnt)+" people are sharing the hostmask "+(*liste)[i].host+": "+saytemp); + shared=true; + } + } - list<string>::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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); + *lptr=new vector<whoisinfo>; + if (*lptr) + delete (*lptr); + *lptr=NULL; + + *((char*)(context->data))=0; + context->flags=PFLAGS_EXEC_ONDEMAND; } } } + diff --git a/plugins/finddoubles2 b/plugins/finddoubles2 Binary files differdeleted file mode 100755 index 3b37fa3..0000000 --- a/plugins/finddoubles2 +++ /dev/null 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 <flo@localhost.localdomain> - * - * 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 <iostream> - -using namespace std; - -#include <iostream> -#include <string> -#include <sstream> - -#include "../TConnectionInterface.h" -#include "../TPluginParentLight.h" -//#include "../TUserList.h" -#include <vector> -#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<whoisinfo>::iterator whereinlist(vector<whoisinfo>* l, string s) -{ - for (vector<whoisinfo>::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<whoisinfo> *)+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<whoisinfo> **) ( (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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); - *lptr=new vector<whoisinfo>; - 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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); - - *lptr=new vector<whoisinfo>; - - *whoiscnt=0; - } - } - } - } - - if (reason&PFLAGS_EXEC_ONANYEVENT) - { - vector<whoisinfo>** lptr= (vector<whoisinfo>**) ((string**)(((char*) context->data+1))+1); - vector<whoisinfo>* 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<whoisinfo>::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; i<sz; i++) - { - saytemp=(*liste)[i].who; - cnt=1; - if ( (*liste)[i].proc == false ) - { - for (int j=i+1; j<sz; j++) - { - if ( (*liste)[i].host == (*liste)[j].host ) - { - saytemp+=", "+(*liste)[j].who; - cnt++; - (*liste)[i].proc=true; - } - } - } - if (cnt>1) - { - 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<whoisinfo> **lptr= (vector<whoisinfo> **) ((string**)(((char*) context->data+1))+1); - *lptr=new vector<whoisinfo>; - 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 <iostream> -#include <string> - -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<string> foo=parent->get_parent()->get_channel_users(parent->get_name()).give_list(); - for (list<string>::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 <iostream> -#include <string> -#include <list> - -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<entry_t>*); - *conndefault=PFLAGS_EXEC_ONEVENT; *chandefault=0; *sessdefault=0; -} - -extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, TConfigReadOnly& config, int reason) -{ - list<entry_t> *liste=*static_cast<list<entry_t> **>(context->data); - if (liste==0) - { - liste=new list<entry_t>; - *static_cast<list<entry_t> **>(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<entry_t>::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<entry_t>::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 |