summaryrefslogtreecommitdiff
path: root/plugins/pass.cpp
blob: 1429fc5042212029d85ac2c1d752fc9241210c28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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_raw))
		{
			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!");
		}
		
	}
}