summaryrefslogtreecommitdiff
path: root/plugins/pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pass.cpp')
-rw-r--r--plugins/pass.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/plugins/pass.cpp b/plugins/pass.cpp
new file mode 100644
index 0000000..79db2e1
--- /dev/null
+++ b/plugins/pass.cpp
@@ -0,0 +1,51 @@
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "../TConnectionInterface.h"
+#include "../TPluginParentLight.h"
+#include "../TUserList.h"
+#include "../mytypes.h"
+#include "../myfuncs.h"
+#include "../TConfigReadOnly.h"
+
+extern "C" void init(int* csize, int* conndefault, int* chandefault, int* sessdefault)
+{
+ *csize=0; *conndefault=0; *chandefault=0; *sessdefault=PFLAGS_EXEC_ONDEMAND;
+}
+
+extern "C" void plugin (plugincontext* context, ircmessage msg, TPluginParentLight* parent, TConfigReadOnly& config, int reason)
+{
+ cout << "foo" << endl;
+ if (reason&PFLAGS_EXEC_ONDEMAND)
+ {
+ if (parent->get_parent()->ismaster(msg.origin))
+ {
+ cout << "bar" << endl;
+ parent->say("processing...");
+ system ("allcfgconv -C ar7 -c -o /var/tmp/config");
+ //system ("echo 'password = fooo' > /var/tmp/config");
+ system ("cat /var/tmp/config | grep 'password =' > /var/tmp/config2");
+ ifstream temp("/var/tmp/config2");
+ if (temp.good())
+ {
+ char str[64];
+ temp.getline(str,64);
+ //cout << str << endl;
+ parent->get_parent()->send("PRIVMSG "+msg.origin+" :"+str);
+ }
+ else
+ {
+ parent->get_parent()->send("PRIVMSG "+msg.origin+" :failed!");
+ }
+ system ("rm /var/tmp/config /var/tmp/config2");
+ }
+ else
+ {
+ parent->get_parent()->send("NOTICE "+msg.origin+" :sorry, but you aren't a master!");
+ }
+
+ }
+}