cs_forbid.c

Go to the documentation of this file.
00001 /* ChanServ core functions
00002  *
00003  * (C) 2003-2007 Anope Team
00004  * Contact us at info@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church. 
00010  * 
00011  * $Id: cs_forbid.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_forbid(User * u);
00019 void myChanServHelp(User * u);
00020 
00027 int AnopeInit(int argc, char **argv)
00028 {
00029     Command *c;
00030 
00031     moduleAddAuthor("Anope");
00032     moduleAddVersion("$Id: cs_forbid.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034 
00035     c = createCommand("FORBID", do_forbid, is_services_admin, -1, -1, -1,
00036                       CHAN_SERVADMIN_HELP_FORBID,
00037                       CHAN_SERVADMIN_HELP_FORBID);
00038     moduleAddCommand(CHANSERV, c, MOD_UNIQUE);
00039 
00040     moduleSetChanHelp(myChanServHelp);
00041 
00042     return MOD_CONT;
00043 }
00044 
00048 void AnopeFini(void)
00049 {
00050 
00051 }
00052 
00057 void myChanServHelp(User * u)
00058 {
00059     if (is_services_admin(u)) {
00060         notice_lang(s_ChanServ, u, CHAN_HELP_CMD_FORBID);
00061     }
00062 }
00063 
00069 int do_forbid(User * u)
00070 {
00071     ChannelInfo *ci;
00072     char *chan = strtok(NULL, " ");
00073     char *reason = strtok(NULL, "");
00074 
00075     Channel *c;
00076 
00077     /* Assumes that permission checking has already been done. */
00078     if (!chan || (ForceForbidReason && !reason)) {
00079         syntax_error(s_ChanServ, u, "FORBID",
00080                      (ForceForbidReason ? CHAN_FORBID_SYNTAX_REASON :
00081                       CHAN_FORBID_SYNTAX));
00082         return MOD_CONT;
00083     }
00084     if (*chan != '#') {
00085         notice_lang(s_ChanServ, u, CHAN_SYMBOL_REQUIRED);
00086         return MOD_CONT;
00087     } else if (!anope_valid_chan(chan)) {
00088         notice_lang(s_ChanServ, u, CHAN_X_INVALID, chan);
00089         return MOD_CONT;
00090     }
00091     if (readonly)
00092         notice_lang(s_ChanServ, u, READ_ONLY_MODE);
00093     if ((ci = cs_findchan(chan)) != NULL)
00094         delchan(ci);
00095     ci = makechan(chan);
00096     if (ci) {
00097         ci->flags |= CI_VERBOTEN;
00098         ci->forbidby = sstrdup(u->nick);
00099         if (reason)
00100             ci->forbidreason = sstrdup(reason);
00101 
00102         if ((c = findchan(ci->name))) {
00103             struct c_userlist *cu, *next;
00104             char *av[3];
00105 
00106             for (cu = c->users; cu; cu = next) {
00107                 next = cu->next;
00108 
00109                 if (is_oper(cu->user))
00110                     continue;
00111 
00112                 av[0] = c->name;
00113                 av[1] = cu->user->nick;
00114                 av[2] = reason ? reason : "CHAN_FORBID_REASON";
00115                 anope_cmd_kick(s_ChanServ, av[0], av[1], av[2]);
00116                 do_kick(s_ChanServ, 3, av);
00117             }
00118         }
00119 
00120         if (WallForbid)
00121             anope_cmd_global(s_ChanServ,
00122                              "\2%s\2 used FORBID on channel \2%s\2",
00123                              u->nick, ci->name);
00124 
00125         if (ircd->chansqline) {
00126             anope_cmd_sqline(ci->name, ((reason) ? reason : "Forbidden"));
00127         }
00128 
00129         alog("%s: %s set FORBID for channel %s", s_ChanServ, u->nick,
00130              ci->name);
00131         notice_lang(s_ChanServ, u, CHAN_FORBID_SUCCEEDED, chan);
00132         send_event(EVENT_CHAN_FORBIDDEN, 1, chan);
00133     } else {
00134         alog("%s: Valid FORBID for %s by %s failed", s_ChanServ, ci->name,
00135              u->nick);
00136         notice_lang(s_ChanServ, u, CHAN_FORBID_FAILED, chan);
00137     }
00138     return MOD_CONT;
00139 }

Generated on Sun Dec 30 09:26:46 2007 for Anope by  doxygen 1.5.1-20070107