os_chanlist.c

Go to the documentation of this file.
00001 /* OperServ core functions
00002  *
00003  * (C) 2003-2008 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: os_chanlist.c 1347 2008-01-15 15:05:23Z drstein $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_chanlist(User * u);
00019 void myOperServHelp(User * u);
00020 #ifdef _WIN32
00021 extern MDE int anope_get_private_mode();
00022 #endif
00023 
00030 int AnopeInit(int argc, char **argv)
00031 {
00032     Command *c;
00033 
00034     moduleAddAuthor("Anope");
00035     moduleAddVersion("$Id: os_chanlist.c 1347 2008-01-15 15:05:23Z drstein $");
00036     moduleSetType(CORE);
00037 
00038     c = createCommand("CHANLIST", do_chanlist, is_services_oper,
00039                       OPER_HELP_CHANLIST, -1, -1, -1, -1);
00040     moduleAddCommand(OPERSERV, c, MOD_UNIQUE);
00041 
00042     moduleSetOperHelp(myOperServHelp);
00043 
00044     return MOD_CONT;
00045 }
00046 
00047 
00051 void AnopeFini(void)
00052 {
00053 
00054 }
00055 
00056 
00061 void myOperServHelp(User * u)
00062 {
00063     notice_lang(s_OperServ, u, OPER_HELP_CMD_CHANLIST);
00064 }
00065 
00071 int do_chanlist(User * u)
00072 {
00073     char *pattern = strtok(NULL, " ");
00074     char *opt = strtok(NULL, " ");
00075 
00076     int modes = 0;
00077     User *u2;
00078 
00079     if (opt && !stricmp(opt, "SECRET"))
00080         modes |= (anope_get_secret_mode() | anope_get_private_mode());
00081 
00082     if (pattern && (u2 = finduser(pattern))) {
00083         struct u_chanlist *uc;
00084 
00085         notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER_USER, u2->nick);
00086 
00087         for (uc = u2->chans; uc; uc = uc->next) {
00088             if (modes && !(uc->chan->mode & modes))
00089                 continue;
00090             notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD,
00091                         uc->chan->name, uc->chan->usercount,
00092                         chan_get_modes(uc->chan, 1, 1),
00093                         (uc->chan->topic ? uc->chan->topic : ""));
00094         }
00095     } else {
00096         int i;
00097         Channel *c;
00098 
00099         notice_lang(s_OperServ, u, OPER_CHANLIST_HEADER);
00100 
00101         for (i = 0; i < 1024; i++) {
00102             for (c = chanlist[i]; c; c = c->next) {
00103                 if (pattern && !match_wild_nocase(pattern, c->name))
00104                     continue;
00105                 if (modes && !(c->mode & modes))
00106                     continue;
00107                 notice_lang(s_OperServ, u, OPER_CHANLIST_RECORD, c->name,
00108                             c->usercount, chan_get_modes(c, 1, 1),
00109                             (c->topic ? c->topic : ""));
00110             }
00111         }
00112     }
00113 
00114     notice_lang(s_OperServ, u, OPER_CHANLIST_END);
00115     return MOD_CONT;
00116 }

Generated on Sun Oct 5 09:06:55 2008 for Anope by  doxygen 1.5.7.1