]>
Commit | Line | Data |
---|---|---|
3e3692bf CP |
1 | #include <stdio.h>\r |
2 | #include <stdlib.h>\r | |
3 | #include <stdarg.h>\r | |
4 | #include <string.h>\r | |
5 | #include <time.h>\r | |
6 | \r | |
7 | #include "../control/control.h"\r | |
8 | #include "../nick/nick.h"\r | |
9 | #include "../localuser/localuserchannel.h"\r | |
10 | \r | |
11 | int controlkill(void *sender, int cargc, char **cargv);\r | |
12 | int controlopchan(void *sender, int cargc, char **cargv);\r | |
13 | int controlkick(void *sender, int cargc, char **cargv);\r | |
14 | \r | |
15 | void _init() {\r | |
16 | registercontrolhelpcmd("kill",NO_OPER,2,&controlkill,"Usage: kill nick <reason>\nKill specificed user.");\r | |
17 | registercontrolhelpcmd("opchan",NO_OPER,2,&controlopchan,"Usage: opchan channel nick\nGive user +o on channel.");\r | |
18 | registercontrolhelpcmd("kick",NO_OPER,3,&controlkick,"Usage: kick channel user <reason>\nKick a user from the given channel");\r | |
19 | }\r | |
20 | \r | |
21 | void _fini() {\r | |
22 | deregistercontrolcmd("kill",controlkill); \r | |
23 | deregistercontrolcmd("opchan",controlopchan);\r | |
24 | deregistercontrolcmd("kick",controlkick);\r | |
25 | }\r | |
26 | \r | |
27 | int controlkick(void *sender, int cargc, char **cargv) {\r | |
28 | nick *np=(nick *)sender;\r | |
29 | nick *victim;\r | |
30 | channel *cp;\r | |
31 | modechanges changes;\r | |
32 | nick *target;\r | |
33 | \r | |
34 | if (cargc<2) {\r | |
35 | controlreply(sender,"Usage: kick channel user <reason>");\r | |
36 | return CMD_ERROR;\r | |
37 | }\r | |
38 | \r | |
39 | if ((cp=findchannel(cargv[0]))!=NULL) {\r | |
40 | if (cargv[1][0]=='#') {\r | |
41 | if (!(target=getnickbynumericstr(cargv[1]+1))) {\r | |
42 | controlreply(np,"Sorry, couldn't find numeric %s",cargv[0]+1);\r | |
43 | return CMD_ERROR;\r | |
44 | }\r | |
45 | } else {\r | |
46 | if ((target=getnickbynick(cargv[1]))==NULL) {\r | |
47 | controlreply(np,"Sorry, couldn't find that user");\r | |
48 | return CMD_ERROR;\r | |
49 | }\r | |
50 | }\r | |
51 | \r | |
52 | if(cargc > 2) {\r | |
53 | irc_send("%s K %s %s :%s",mynumeric->content,cp->index->name->content,longtonumeric(target->numeric,5),cargv[2]);\r | |
54 | } else {\r | |
55 | irc_send("%s K %s %s :Kicked",mynumeric->content,cp->index->name->content,longtonumeric(target->numeric,5));\r | |
56 | }\r | |
57 | delnickfromchannel(cp, target->numeric, 1);\r | |
58 | \r | |
59 | controlreply(sender,"Put Kick for %s from %s.", target->nick, cp->index->name->content);\r | |
60 | controlwall(NO_OPER, NL_KICKS, "%s/%s sent KICK for %s!%s@%s from %s", np->nick, np->authname, target->nick, target->ident, target->host->name->content,cp->index->name->content);\r | |
61 | \r | |
62 | } else {\r | |
63 | controlreply(np,"Couldn't find channel %s.",cargv[0]);\r | |
64 | return;\r | |
65 | }\r | |
66 | \r | |
67 | return CMD_OK;\r | |
68 | }\r | |
69 | \r | |
70 | int controlopchan(void *source, int cargc, char **cargv) {\r | |
71 | nick *sender=(nick *)source;\r | |
72 | nick *victim;\r | |
73 | channel *cp;\r | |
74 | modechanges changes;\r | |
75 | nick *target;\r | |
76 | unsigned long *lp;\r | |
77 | \r | |
78 | if (cargc<2) {\r | |
79 | controlreply(sender,"Usage: opchan channel user");\r | |
80 | return CMD_ERROR;\r | |
81 | }\r | |
82 | \r | |
83 | if ((cp=findchannel(cargv[0]))!=NULL) {\r | |
84 | if (cargv[1][0]=='#') {\r | |
85 | if (!(target=getnickbynumericstr(cargv[1]+1))) {\r | |
86 | controlreply(sender,"Sorry, couldn't find numeric %s",cargv[0]+1);\r | |
87 | return CMD_ERROR;\r | |
88 | }\r | |
89 | } else {\r | |
90 | if ((target=getnickbynick(cargv[1]))==NULL) {\r | |
91 | controlreply((nick *)sender,"Sorry, couldn't find that user");\r | |
92 | return CMD_ERROR;\r | |
93 | }\r | |
94 | }\r | |
95 | \r | |
96 | if ((lp=getnumerichandlefromchanhash(cp->users,target->numeric))==NULL) {\r | |
97 | controlreply((nick *)sender,"Sorry, User not on channel");\r | |
98 | return CMD_ERROR;\r | |
99 | }\r | |
100 | \r | |
101 | (*lp)|=CUMODE_OP;\r | |
102 | irc_send("%s OM %s +o %s",mynumeric->content,cp->index->name->content,longtonumeric(target->numeric,5));\r | |
103 | controlreply(sender,"Put mode +o %s on %s.", target->nick, cp->index->name->content); \r | |
104 | } else {\r | |
105 | controlreply(sender,"Couldn't find channel %s.",cargv[0]);\r | |
106 | return;\r | |
107 | }\r | |
108 | \r | |
109 | return CMD_OK;\r | |
110 | }\r | |
111 | \r | |
112 | int controlkill(void *sender, int cargc, char **cargv) {\r | |
113 | nick *target;\r | |
114 | char buf[BUFSIZE];\r | |
115 | int i;\r | |
116 | nick *np = (nick *)sender;\r | |
117 | \r | |
118 | if (cargc<1) {\r | |
119 | controlreply(np,"Usage: kill <user> <reason>");\r | |
120 | return CMD_ERROR;\r | |
121 | }\r | |
122 | \r | |
123 | if (cargv[0][0]=='#') {\r | |
124 | if (!(target=getnickbynumericstr(cargv[0]+1))) {\r | |
125 | controlreply(np,"Sorry, couldn't find numeric %s",cargv[0]+1);\r | |
126 | return CMD_ERROR;\r | |
127 | }\r | |
128 | } else {\r | |
129 | if ((target=getnickbynick(cargv[0]))==NULL) {\r | |
130 | controlreply(np,"Sorry, couldn't find that user");\r | |
131 | return CMD_ERROR;\r | |
132 | }\r | |
133 | }\r | |
134 | \r | |
135 | killuser(NULL, target, (cargc>1)?cargv[1]:"Killed");\r | |
136 | controlreply(np,"KILL sent.");\r | |
137 | controlwall(NO_OPER, NL_KILLS, "%s/%s sent KILL for %s!%s@%s (%s)", np->nick, np->authname, target->nick, target->ident, target->host->name->content,(cargc>1)?cargv[1]:"Killed");\r | |
138 | \r | |
139 | return CMD_OK;\r | |
140 | }\r |