bs_botlist.c

Go to the documentation of this file.
00001 /* BotServ 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: bs_botlist.c 1265 2007-08-26 15:33:06Z geniusdex $
00012  *
00013  */
00014 /*************************************************************************/
00015 
00016 #include "module.h"
00017 
00018 int do_botlist(User * u);
00019 void myBotServHelp(User * u);
00020 
00027 int AnopeInit(int argc, char **argv)
00028 {
00029     Command *c;
00030 
00031     moduleAddAuthor("Anope");
00032     moduleAddVersion("$Id: bs_botlist.c 1265 2007-08-26 15:33:06Z geniusdex $");
00033     moduleSetType(CORE);
00034     c = createCommand("BOTLIST", do_botlist, NULL, BOT_HELP_BOTLIST, -1,
00035                       -1, -1, -1);
00036     moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
00037 
00038     moduleSetBotHelp(myBotServHelp);
00039 
00040     return MOD_CONT;
00041 }
00042 
00046 void AnopeFini(void)
00047 {
00048 
00049 }
00050 
00051 
00052 
00057 void myBotServHelp(User * u)
00058 {
00059     notice_lang(s_BotServ, u, BOT_HELP_CMD_BOTLIST);
00060 }
00061 
00067 int do_botlist(User * u)
00068 {
00069     int i, count = 0;
00070     BotInfo *bi;
00071 
00072     if (!nbots) {
00073         notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
00074         return MOD_CONT;
00075     }
00076 
00077     for (i = 0; i < 256; i++) {
00078         for (bi = botlists[i]; bi; bi = bi->next) {
00079             if (!(bi->flags & BI_PRIVATE)) {
00080                 if (!count)
00081                     notice_lang(s_BotServ, u, BOT_BOTLIST_HEADER);
00082                 count++;
00083                 notice_user(s_BotServ, u, "   %-15s  (%s@%s)", bi->nick,
00084                             bi->user, bi->host);
00085             }
00086         }
00087     }
00088 
00089     if (is_oper(u) && count < nbots) {
00090         notice_lang(s_BotServ, u, BOT_BOTLIST_PRIVATE_HEADER);
00091 
00092         for (i = 0; i < 256; i++) {
00093             for (bi = botlists[i]; bi; bi = bi->next) {
00094                 if (bi->flags & BI_PRIVATE) {
00095                     notice_user(s_BotServ, u, "   %-15s  (%s@%s)",
00096                                 bi->nick, bi->user, bi->host);
00097                     count++;
00098                 }
00099             }
00100         }
00101     }
00102 
00103     if (!count)
00104         notice_lang(s_BotServ, u, BOT_BOTLIST_EMPTY);
00105     else
00106         notice_lang(s_BotServ, u, BOT_BOTLIST_FOOTER, count);
00107     return MOD_CONT;
00108 }

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