00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "module.h"
00017
00018 int do_chankill(User * u);
00019 void myOperServHelp(User * u);
00020
00027 int AnopeInit(int argc, char **argv)
00028 {
00029 Command *c;
00030
00031 moduleAddAuthor("Anope");
00032 moduleAddVersion
00033 ("$Id: os_chankill.c 1345 2008-01-13 12:54:14Z geniusdex $");
00034 moduleSetType(CORE);
00035
00036 c = createCommand("CHANKILL", do_chankill, is_services_admin,
00037 OPER_HELP_CHANKILL, -1, -1, -1, -1);
00038 moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00039
00040 moduleSetOperHelp(myOperServHelp);
00041
00042 return MOD_CONT;
00043 }
00044
00048 void AnopeFini(void)
00049 {
00050
00051 }
00052
00053
00054
00059 void myOperServHelp(User * u)
00060 {
00061 if (is_services_admin(u)) {
00062 notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANKILL);
00063 }
00064 }
00065
00074 int do_chankill(User * u)
00075 {
00076 char *expiry, *channel, *reason;
00077 time_t expires;
00078 char breason[BUFSIZE];
00079 char mask[USERMAX + HOSTMAX + 2];
00080 struct c_userlist *cu, *next;
00081 Channel *c;
00082
00083 channel = strtok(NULL, " ");
00084 if (channel && *channel == '+') {
00085 expiry = channel;
00086 channel = strtok(NULL, " ");
00087 } else {
00088 expiry = NULL;
00089 }
00090
00091 expires = expiry ? dotime(expiry) : ChankillExpiry;
00092 if (expiry && isdigit(expiry[strlen(expiry) - 1]))
00093 expires *= 86400;
00094 if (expires != 0 && expires < 60) {
00095 notice_lang(s_OperServ, u, BAD_EXPIRY_TIME);
00096 return MOD_CONT;
00097 } else if (expires > 0) {
00098 expires += time(NULL);
00099 }
00100
00101 if (channel && (reason = strtok(NULL, ""))) {
00102
00103 if (AddAkiller) {
00104 snprintf(breason, sizeof(breason), "[%s] %s", u->nick, reason);
00105 reason = sstrdup(breason);
00106 }
00107
00108 if ((c = findchan(channel))) {
00109 for (cu = c->users; cu; cu = next) {
00110 next = cu->next;
00111 if (is_oper(cu->user)) {
00112 continue;
00113 }
00114 (void) strncpy(mask, "*@", 3);
00115 strncat(mask, cu->user->host, HOSTMAX);
00116 add_akill(NULL, mask, s_OperServ, expires, reason);
00117 check_akill(cu->user->nick, cu->user->username,
00118 cu->user->host, NULL, NULL);
00119 }
00120 if (WallOSAkill) {
00121 anope_cmd_global(s_OperServ, "%s used CHANKILL on %s (%s)",
00122 u->nick, channel, reason);
00123 }
00124 } else {
00125 notice_lang(s_OperServ, u, CHAN_X_NOT_IN_USE, channel);
00126 }
00127 if (AddAkiller) {
00128 free(reason);
00129 }
00130 } else {
00131 syntax_error(s_OperServ, u, "CHANKILL", OPER_CHANKILL_SYNTAX);
00132 }
00133 return MOD_CONT;
00134 }