00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "module.h"
00017
00018 int do_info(User * u);
00019 void send_bot_channels(User * u, BotInfo * bi);
00020 void myBotServHelp(User * u);
00021
00028 int AnopeInit(int argc, char **argv)
00029 {
00030 Command *c;
00031
00032 moduleAddAuthor("Anope");
00033 moduleAddVersion("$Id: bs_info.c 1265 2007-08-26 15:33:06Z geniusdex $");
00034 moduleSetType(CORE);
00035 c = createCommand("INFO", do_info, NULL, BOT_HELP_INFO, -1, -1, -1,
00036 -1);
00037 moduleAddCommand(BOTSERV, c, MOD_UNIQUE);
00038
00039 moduleSetBotHelp(myBotServHelp);
00040
00041 return MOD_CONT;
00042 }
00043
00047 void AnopeFini(void)
00048 {
00049
00050 }
00051
00052
00053
00058 void myBotServHelp(User * u)
00059 {
00060 notice_lang(s_BotServ, u, BOT_HELP_CMD_INFO);
00061 }
00062
00068 int do_info(User * u)
00069 {
00070 BotInfo *bi;
00071 ChannelInfo *ci;
00072 char *query = strtok(NULL, " ");
00073
00074 int need_comma = 0, is_servadmin = is_services_admin(u);
00075 char buf[BUFSIZE], *end;
00076 const char *commastr = getstring(u->na, COMMA_SPACE);
00077
00078 if (!query)
00079 syntax_error(s_BotServ, u, "INFO", BOT_INFO_SYNTAX);
00080 else if ((bi = findbot(query))) {
00081 char buf[BUFSIZE];
00082 struct tm *tm;
00083
00084 notice_lang(s_BotServ, u, BOT_INFO_BOT_HEADER, bi->nick);
00085 notice_lang(s_BotServ, u, BOT_INFO_BOT_MASK, bi->user, bi->host);
00086 notice_lang(s_BotServ, u, BOT_INFO_BOT_REALNAME, bi->real);
00087 tm = localtime(&bi->created);
00088 strftime_lang(buf, sizeof(buf), u, STRFTIME_DATE_TIME_FORMAT, tm);
00089 notice_lang(s_BotServ, u, BOT_INFO_BOT_CREATED, buf);
00090 notice_lang(s_BotServ, u, BOT_INFO_BOT_OPTIONS,
00091 getstring(u->na,
00092 (bi->
00093 flags & BI_PRIVATE) ? BOT_INFO_OPT_PRIVATE :
00094 BOT_INFO_OPT_NONE));
00095 notice_lang(s_BotServ, u, BOT_INFO_BOT_USAGE, bi->chancount);
00096
00097 if (is_services_admin(u))
00098 send_bot_channels(u, bi);
00099 } else if ((ci = cs_findchan(query))) {
00100 if (!is_servadmin && !is_founder(u, ci)) {
00101 notice_lang(s_BotServ, u, PERMISSION_DENIED);
00102 return MOD_CONT;
00103 }
00104 if (ci->flags & CI_VERBOTEN) {
00105 notice_lang(s_BotServ, u, CHAN_X_FORBIDDEN, query);
00106 return MOD_CONT;
00107 }
00108
00109 notice_lang(s_BotServ, u, BOT_INFO_CHAN_HEADER, ci->name);
00110 if (ci->bi)
00111 notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT, ci->bi->nick);
00112 else
00113 notice_lang(s_BotServ, u, BOT_INFO_CHAN_BOT_NONE);
00114
00115 if (ci->botflags & BS_KICK_BADWORDS) {
00116 if (ci->ttb[TTB_BADWORDS])
00117 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS_BAN,
00118 getstring(u->na, BOT_INFO_ACTIVE),
00119 ci->ttb[TTB_BADWORDS]);
00120 else
00121 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
00122 getstring(u->na, BOT_INFO_ACTIVE));
00123 } else
00124 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BADWORDS,
00125 getstring(u->na, BOT_INFO_INACTIVE));
00126 if (ci->botflags & BS_KICK_BOLDS) {
00127 if (ci->ttb[TTB_BOLDS])
00128 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS_BAN,
00129 getstring(u->na, BOT_INFO_ACTIVE),
00130 ci->ttb[TTB_BOLDS]);
00131 else
00132 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
00133 getstring(u->na, BOT_INFO_ACTIVE));
00134 } else
00135 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_BOLDS,
00136 getstring(u->na, BOT_INFO_INACTIVE));
00137 if (ci->botflags & BS_KICK_CAPS) {
00138 if (ci->ttb[TTB_CAPS])
00139 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_BAN,
00140 getstring(u->na, BOT_INFO_ACTIVE),
00141 ci->ttb[TTB_CAPS], ci->capsmin,
00142 ci->capspercent);
00143 else
00144 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_ON,
00145 getstring(u->na, BOT_INFO_ACTIVE), ci->capsmin,
00146 ci->capspercent);
00147 } else
00148 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_CAPS_OFF,
00149 getstring(u->na, BOT_INFO_INACTIVE));
00150 if (ci->botflags & BS_KICK_COLORS) {
00151 if (ci->ttb[TTB_COLORS])
00152 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS_BAN,
00153 getstring(u->na, BOT_INFO_ACTIVE),
00154 ci->ttb[TTB_COLORS]);
00155 else
00156 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
00157 getstring(u->na, BOT_INFO_ACTIVE));
00158 } else
00159 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_COLORS,
00160 getstring(u->na, BOT_INFO_INACTIVE));
00161 if (ci->botflags & BS_KICK_FLOOD) {
00162 if (ci->ttb[TTB_FLOOD])
00163 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_BAN,
00164 getstring(u->na, BOT_INFO_ACTIVE),
00165 ci->ttb[TTB_FLOOD], ci->floodlines,
00166 ci->floodsecs);
00167 else
00168 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_ON,
00169 getstring(u->na, BOT_INFO_ACTIVE),
00170 ci->floodlines, ci->floodsecs);
00171 } else
00172 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_FLOOD_OFF,
00173 getstring(u->na, BOT_INFO_INACTIVE));
00174 if (ci->botflags & BS_KICK_REPEAT) {
00175 if (ci->ttb[TTB_REPEAT])
00176 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_BAN,
00177 getstring(u->na, BOT_INFO_ACTIVE),
00178 ci->ttb[TTB_REPEAT], ci->repeattimes);
00179 else
00180 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_ON,
00181 getstring(u->na, BOT_INFO_ACTIVE),
00182 ci->repeattimes);
00183 } else
00184 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REPEAT_OFF,
00185 getstring(u->na, BOT_INFO_INACTIVE));
00186 if (ci->botflags & BS_KICK_REVERSES) {
00187 if (ci->ttb[TTB_REVERSES])
00188 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES_BAN,
00189 getstring(u->na, BOT_INFO_ACTIVE),
00190 ci->ttb[TTB_REVERSES]);
00191 else
00192 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
00193 getstring(u->na, BOT_INFO_ACTIVE));
00194 } else
00195 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_REVERSES,
00196 getstring(u->na, BOT_INFO_INACTIVE));
00197 if (ci->botflags & BS_KICK_UNDERLINES) {
00198 if (ci->ttb[TTB_UNDERLINES])
00199 notice_lang(s_BotServ, u,
00200 BOT_INFO_CHAN_KICK_UNDERLINES_BAN,
00201 getstring(u->na, BOT_INFO_ACTIVE),
00202 ci->ttb[TTB_UNDERLINES]);
00203 else
00204 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
00205 getstring(u->na, BOT_INFO_ACTIVE));
00206 } else
00207 notice_lang(s_BotServ, u, BOT_INFO_CHAN_KICK_UNDERLINES,
00208 getstring(u->na, BOT_INFO_INACTIVE));
00209
00210 end = buf;
00211 *end = 0;
00212 if (ci->botflags & BS_DONTKICKOPS) {
00213 end += snprintf(end, sizeof(buf) - (end - buf), "%s",
00214 getstring(u->na, BOT_INFO_OPT_DONTKICKOPS));
00215 need_comma = 1;
00216 }
00217 if (ci->botflags & BS_DONTKICKVOICES) {
00218 end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
00219 need_comma ? commastr : "",
00220 getstring(u->na, BOT_INFO_OPT_DONTKICKVOICES));
00221 need_comma = 1;
00222 }
00223 if (ci->botflags & BS_FANTASY) {
00224 end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
00225 need_comma ? commastr : "",
00226 getstring(u->na, BOT_INFO_OPT_FANTASY));
00227 need_comma = 1;
00228 }
00229 if (ci->botflags & BS_GREET) {
00230 end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
00231 need_comma ? commastr : "",
00232 getstring(u->na, BOT_INFO_OPT_GREET));
00233 need_comma = 1;
00234 }
00235 if (ci->botflags & BS_NOBOT) {
00236 end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
00237 need_comma ? commastr : "",
00238 getstring(u->na, BOT_INFO_OPT_NOBOT));
00239 need_comma = 1;
00240 }
00241 if (ci->botflags & BS_SYMBIOSIS) {
00242 end += snprintf(end, sizeof(buf) - (end - buf), "%s%s",
00243 need_comma ? commastr : "",
00244 getstring(u->na, BOT_INFO_OPT_SYMBIOSIS));
00245 need_comma = 1;
00246 }
00247 notice_lang(s_BotServ, u, BOT_INFO_CHAN_OPTIONS,
00248 *buf ? buf : getstring(u->na, BOT_INFO_OPT_NONE));
00249
00250 } else
00251 notice_lang(s_BotServ, u, BOT_INFO_NOT_FOUND, query);
00252 return MOD_CONT;
00253 }
00254
00255 void send_bot_channels(User * u, BotInfo * bi)
00256 {
00257 int i;
00258 ChannelInfo *ci;
00259 char buf[307], *end;
00260
00261 *buf = 0;
00262 end = buf;
00263
00264 for (i = 0; i < 256; i++) {
00265 for (ci = chanlists[i]; ci; ci = ci->next) {
00266 if (ci->bi == bi) {
00267 if (strlen(buf) + strlen(ci->name) > 300) {
00268 notice_user(s_BotServ, u, buf);
00269 *buf = 0;
00270 end = buf;
00271 }
00272 end +=
00273 snprintf(end, sizeof(buf) - (end - buf), " %s ",
00274 ci->name);
00275 }
00276 }
00277 }
00278
00279 if (*buf)
00280 notice_user(s_BotServ, u, buf);
00281 return;
00282 }