cmdsirc.c 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  1. /*
  2. * chancmds.c -- part of irc.mod
  3. * handles commands directly relating to channel interaction
  4. *
  5. */
  6. /* Do we have any flags that will allow us ops on a channel?
  7. */
  8. static struct chanset_t *get_channel(int idx, char *chname, bool check_console = 1)
  9. {
  10. struct chanset_t *chan = NULL;
  11. if (chname && chname[0]) {
  12. chan = findchan_by_dname(chname);
  13. if (chan)
  14. return chan;
  15. else
  16. dprintf(idx, "No such channel.\n");
  17. } else if (check_console) {
  18. chname = dcc[idx].u.chat->con_chan;
  19. chan = findchan_by_dname(chname);
  20. if (chan)
  21. return chan;
  22. else
  23. dprintf(idx, "Invalid console channel.\n");
  24. }
  25. return NULL;
  26. }
  27. /* Do we have any flags that will allow us ops on a channel?
  28. */
  29. static int has_op(int idx, struct chanset_t *chan)
  30. {
  31. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  32. if (privchan(user, chan, PRIV_OP)) {
  33. dprintf(idx, "No such channel.\n");
  34. return 0;
  35. }
  36. if (real_chk_op(user, chan, 0))
  37. return 1;
  38. dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
  39. return 0;
  40. }
  41. /* Finds a nick of the handle. Returns m->nick if
  42. * the nick was found, otherwise NULL (Sup 1Nov2000)
  43. */
  44. char *getnick(const char *handle, struct chanset_t *chan)
  45. {
  46. struct userrec *u = NULL;
  47. char s[UHOSTLEN] = "";
  48. for (register memberlist *m = chan->channel.member; m && m->nick[0]; m = m->next) {
  49. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  50. if ((u = get_user_by_host(s)) && !egg_strcasecmp(u->handle, handle))
  51. return m->nick;
  52. }
  53. return NULL;
  54. }
  55. static void cmd_act(int idx, char *par)
  56. {
  57. if (!par[0]) {
  58. dprintf(idx, "Usage: act [channel] <action>\n");
  59. return;
  60. }
  61. char *chname = NULL;
  62. struct chanset_t *chan = NULL;
  63. if (strchr(CHANMETA, par[0]) != NULL)
  64. chname = newsplit(&par);
  65. else
  66. chname = 0;
  67. chan = get_channel(idx, chname);
  68. if (!chan || !has_op(idx, chan))
  69. return;
  70. memberlist *m = ismember(chan, botname);
  71. if (!m) {
  72. dprintf(idx, "Cannot say to %s: I'm not on that channel.\n", chan->dname);
  73. return;
  74. }
  75. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  76. if ((chan->channel.mode & CHANMODER) && !me_op(chan) && !me_voice(chan)) {
  77. dprintf(idx, "Cannot say to %s: It is moderated.\n", chan->dname);
  78. return;
  79. }
  80. putlog(LOG_CMDS, "*", "#%s# (%s) act %s", dcc[idx].nick,
  81. chan->dname, par);
  82. dprintf(DP_HELP, "PRIVMSG %s :\001ACTION %s\001\n",
  83. chan->name, par);
  84. dprintf(idx, "Action to %s: %s\n", chan->dname, par);
  85. }
  86. static void cmd_msg(int idx, char *par)
  87. {
  88. if (!par[0]) {
  89. dprintf(idx, "Usage: msg <nick> <message>\n");
  90. return;
  91. }
  92. char *nick = newsplit(&par);
  93. putlog(LOG_CMDS, "*", "#%s# msg %s %s", dcc[idx].nick, nick, par);
  94. dprintf(DP_HELP, "PRIVMSG %s :%s\n", nick, par);
  95. dprintf(idx, "Msg to %s: %s\n", nick, par);
  96. }
  97. static void cmd_say(int idx, char *par)
  98. {
  99. if (!par[0]) {
  100. dprintf(idx, "Usage: say [channel] <message>\n");
  101. return;
  102. }
  103. char *chname = NULL;
  104. struct chanset_t *chan = NULL;
  105. if (strchr(CHANMETA, par[0]) != NULL)
  106. chname = newsplit(&par);
  107. else
  108. chname = 0;
  109. chan = get_channel(idx, chname);
  110. if (!chan || !has_op(idx, chan))
  111. return;
  112. memberlist *m = ismember(chan, botname);
  113. if (!m) {
  114. dprintf(idx, "Cannot say to %s: I'm not on that channel.\n", chan->dname);
  115. return;
  116. }
  117. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  118. if ((chan->channel.mode & CHANMODER) && !me_op(chan) && !me_voice(chan)) {
  119. dprintf(idx, "Cannot say to %s: It is moderated.\n", chan->dname);
  120. return;
  121. }
  122. putlog(LOG_CMDS, "*", "#%s# (%s) say %s", dcc[idx].nick, chan->dname, par);
  123. dprintf(DP_HELP, "PRIVMSG %s :%s\n", chan->name, par);
  124. dprintf(idx, "Said to %s: %s\n", chan->dname, par);
  125. }
  126. static void cmd_swhois(int idx, char *par)
  127. {
  128. if (!par[0]) {
  129. dprintf(idx, "Usage: swhois [server/nick] nick\n");
  130. return;
  131. }
  132. putlog(LOG_CMDS, "*", "#%s# swhois %s", dcc[idx].nick, par);
  133. if (!server_online) {
  134. dprintf(idx, "I am currently not connected!\n");
  135. return;
  136. }
  137. char *server = newsplit(&par), *nick = NULL;
  138. if (par[0])
  139. nick = newsplit(&par);
  140. strlcpy(dcc[idx].whois, nick ? nick : server, UHOSTLEN);
  141. dprintf(DP_SERVER, "WHOIS %s %s\n", server, nick ? nick : "");
  142. }
  143. static void cmd_kickban(int idx, char *par)
  144. {
  145. if (!par[0]) {
  146. dprintf(idx, "Usage: kickban [channel|*] [-|@]<nick> [reason]\n");
  147. return;
  148. }
  149. struct chanset_t *chan = NULL;
  150. char *chname = NULL;
  151. bool all = 0;
  152. if (par[0] == '*' && par[1] == ' ') {
  153. all = 1;
  154. newsplit(&par);
  155. } else {
  156. if (strchr(CHANMETA, par[0]) != NULL)
  157. chname = newsplit(&par);
  158. else
  159. chname = 0;
  160. chan = get_channel(idx, chname);
  161. if (!chan || !has_op(idx, chan))
  162. return;
  163. }
  164. putlog(LOG_CMDS, "*", "#%s# (%s) kickban %s", dcc[idx].nick, all ? "*" : chan->dname, par);
  165. char *nick = newsplit(&par), bantype = 0;
  166. if ((nick[0] == '@') || (nick[0] == '-')) {
  167. bantype = nick[0];
  168. nick++;
  169. }
  170. if (match_my_nick(nick)) {
  171. dprintf(idx, "I'm not going to kickban myself.\n");
  172. return;
  173. }
  174. memberlist *m = NULL;
  175. char *s1 = NULL, s[UHOSTLEN] = "";
  176. struct userrec *u = NULL;
  177. if (all)
  178. chan = chanset;
  179. while (chan) {
  180. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  181. if (privchan(user, chan, PRIV_OP)) {
  182. if (all) goto next;
  183. dprintf(idx, "No such channel.\n");
  184. return;
  185. }
  186. else if (!real_chk_op(user, chan, 0)) {
  187. if (all) goto next;
  188. dprintf(idx, "You don't have access to %s\n", chan->dname);
  189. return;
  190. }
  191. if (!channel_active(chan)) {
  192. if (all) goto next;
  193. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  194. return;
  195. }
  196. if (!me_op(chan)) {
  197. if (all) goto next;
  198. dprintf(idx, "I can't help you now because I'm not a channel op"
  199. " on %s.\n", chan->dname);
  200. return;
  201. }
  202. m = ismember(chan, nick);
  203. if (!m) {
  204. if (all) goto next;
  205. dprintf(idx, "%s is not on %s\n", nick, chan->dname);
  206. return;
  207. }
  208. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  209. u = get_user_by_host(s);
  210. get_user_flagrec(u, &victim, chan->dname);
  211. if ((chan_master(victim) || glob_master(victim)) &&
  212. !(glob_owner(user) || chan_owner(user))) {
  213. if (all) goto next;
  214. dprintf(idx, "%s is a %s master.\n", nick, chan->dname);
  215. return;
  216. }
  217. if (glob_bot(victim) && !(glob_owner(user) || chan_owner(user))) {
  218. if (all) goto next;
  219. dprintf(idx, "%s is another channel bot!\n", nick);
  220. return;
  221. }
  222. if (use_exempts && (u_match_mask(global_exempts,s) ||
  223. u_match_mask(chan->exempts, s))) {
  224. dprintf(idx, "%s is permanently exempted!\n", nick);
  225. return;
  226. }
  227. if (m->flags & CHANOP)
  228. add_mode(chan, '-', 'o', m->nick);
  229. check_exemptlist(chan, s);
  230. switch (bantype) {
  231. case '@':
  232. s1 = strchr(s, '@');
  233. s1 -= 3;
  234. s1[0] = '*';
  235. s1[1] = '!';
  236. s1[2] = '*';
  237. break;
  238. case '-':
  239. s1 = strchr(s, '!');
  240. s1[1] = '*';
  241. s1--;
  242. s1[0] = '*';
  243. break;
  244. default:
  245. s1 = quickban(chan, m->userhost);
  246. break;
  247. }
  248. if (bantype == '@' || bantype == '-')
  249. do_mask(chan, chan->channel.ban, s1, 'b');
  250. if (!par[0])
  251. par = "requested";
  252. dprintf(DP_MODE, "KICK %s %s :%s%s\n", chan->name, m->nick, bankickprefix, par);
  253. m->flags |= SENTKICK;
  254. u_addmask('b', chan, s1, dcc[idx].nick, par, now + (60 * chan->ban_time), 0);
  255. dprintf(idx, "Kick-banned %s on %s.\n", nick, chan->dname);
  256. next:;
  257. if (!all)
  258. chan = NULL;
  259. else
  260. chan = chan->next;
  261. }
  262. }
  263. static void cmd_voice(int idx, char *par)
  264. {
  265. char *nick = newsplit(&par);
  266. struct chanset_t *chan = NULL;
  267. bool all = 0;
  268. if (par[0] == '*' && !par[1]) {
  269. all = 1;
  270. newsplit(&par);
  271. } else {
  272. chan = get_channel(idx, par);
  273. if (!chan || !has_op(idx, chan))
  274. return;
  275. }
  276. memberlist *m = NULL;
  277. if (all)
  278. chan = chanset;
  279. putlog(LOG_CMDS, "*", "#%s# (%s) voice %s", dcc[idx].nick, all ? "*" : chan->dname , nick);
  280. while (chan) {
  281. if (!nick[0] && !(nick = getnick(dcc[idx].nick, chan))) {
  282. if (all) goto next;
  283. dprintf(idx, "Usage: voice <nick> [channel|*]\n");
  284. return;
  285. }
  286. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  287. if (privchan(user, chan, PRIV_VOICE)) {
  288. if (all) goto next;
  289. dprintf(idx, "No such channel.\n");
  290. return;
  291. }
  292. else if (!chk_voice(user, chan) && !chk_op(user, chan)) {
  293. if (all) goto next;
  294. dprintf(idx, "You don't have access to voice on %s\n", chan->dname);
  295. return;
  296. }
  297. if (!channel_active(chan)) {
  298. if (all) goto next;
  299. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  300. return;
  301. }
  302. if (!me_op(chan)) {
  303. if (all) goto next;
  304. dprintf(idx, "I can't help you now because I'm not a chan op on %s.\n",
  305. chan->dname);
  306. return;
  307. }
  308. m = ismember(chan, nick);
  309. if (!m) {
  310. if (all) goto next;
  311. dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
  312. return;
  313. }
  314. add_mode(chan, '+', 'v', nick);
  315. dprintf(idx, "Gave voice to %s on %s\n", nick, chan->dname);
  316. next:;
  317. if (!all)
  318. chan = NULL;
  319. else
  320. chan = chan->next;
  321. }
  322. }
  323. static void cmd_devoice(int idx, char *par)
  324. {
  325. struct chanset_t *chan = NULL;
  326. char *nick = newsplit(&par);
  327. bool all = 0;
  328. if (par[0] == '*' && !par[1]) {
  329. all = 1;
  330. newsplit(&par);
  331. } else {
  332. chan = get_channel(idx, par);
  333. if (!chan || !has_op(idx, chan))
  334. return;
  335. }
  336. memberlist *m = NULL;
  337. if (all)
  338. chan = chanset;
  339. putlog(LOG_CMDS, "*", "#%s# (%s) devoice %s", dcc[idx].nick, all ? "*" : chan->dname, nick);
  340. while (chan) {
  341. if (!nick[0] && !(nick = getnick(dcc[idx].nick, chan))) {
  342. if (all) goto next;
  343. dprintf(idx, "Usage: devoice <nick> [channel|*]\n");
  344. return;
  345. }
  346. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  347. if (privchan(user, chan, PRIV_VOICE)) {
  348. if (all) goto next;
  349. dprintf(idx, "No such channel.\n");
  350. return;
  351. }
  352. else if (!chk_voice(user, chan) && !chk_op(user, chan)) {
  353. if (all) goto next;
  354. dprintf(idx, "You don't have access to devoice on %s\n", chan->dname);
  355. return;
  356. }
  357. if (!channel_active(chan)) {
  358. if (all) goto next;
  359. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  360. return;
  361. }
  362. if (!me_op(chan)) {
  363. if (all) goto next;
  364. dprintf(idx, "I can't do that right now I'm not a chan op on %s",
  365. chan->dname);
  366. return;
  367. }
  368. m = ismember(chan, nick);
  369. if (!m) {
  370. if (all) goto next;
  371. dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
  372. return;
  373. }
  374. add_mode(chan, '-', 'v', nick);
  375. dprintf(idx, "Devoiced %s on %s\n", nick, chan->dname);
  376. next:;
  377. if (!all)
  378. chan = NULL;
  379. else
  380. chan = chan->next;
  381. }
  382. }
  383. static void cmd_op(int idx, char *par)
  384. {
  385. struct chanset_t *chan = NULL;
  386. char *nick = newsplit(&par);
  387. bool all = 0;
  388. if (par[0] == '*' && !par[1]) {
  389. all = 1;
  390. newsplit(&par);
  391. } else {
  392. chan = get_channel(idx, par);
  393. if (!chan || !has_op(idx, chan))
  394. return;
  395. }
  396. char s[UHOSTLEN] = "";
  397. memberlist *m = NULL;
  398. struct userrec *u = NULL;
  399. if (all)
  400. chan = chanset;
  401. putlog(LOG_CMDS, "*", "#%s# (%s) op %s", dcc[idx].nick, all ? "*" : chan->dname, nick);
  402. while (chan) {
  403. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  404. if (!nick[0] && !(nick = getnick(dcc[idx].nick, chan))) {
  405. if (all) goto next;
  406. dprintf(idx, "Usage: op <nick> [channel|*]\n");
  407. return;
  408. }
  409. if (privchan(user, chan, PRIV_OP)) {
  410. if (!all)
  411. dprintf(idx, "No such channel.\n");
  412. goto next;
  413. }
  414. else if (!chk_op(user, chan)) {
  415. if (all) goto next;
  416. dprintf(idx, "You don't have access to op on %s\n", chan->dname);
  417. return;
  418. }
  419. if (!channel_active(chan)) {
  420. if (all) goto next;
  421. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  422. return;
  423. }
  424. if (!me_op(chan)) {
  425. if (all) goto next;
  426. dprintf(idx, "I can't help you now because I'm not a chan op on %s.\n",
  427. chan->dname);
  428. return;
  429. }
  430. m = ismember(chan, nick);
  431. if (!m) {
  432. if (all) goto next;
  433. dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
  434. return;
  435. }
  436. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  437. u = get_user_by_host(s);
  438. get_user_flagrec(u, &victim, chan->dname);
  439. if (chk_deop(victim, chan)) {
  440. dprintf(idx, "%s is currently being auto-deopped on %s.\n", m->nick, chan->dname);
  441. if (all) goto next;
  442. return;
  443. }
  444. if (chan_bitch(chan) && !chk_op(victim, chan)) {
  445. dprintf(idx, "%s is not a registered op on %s.\n", m->nick, chan->dname);
  446. if (all) goto next;
  447. return;
  448. }
  449. if (do_op(nick, chan, 0, 1)) {
  450. dprintf(idx, "Gave op to %s on %s.\n", nick, chan->dname);
  451. stats_add(u, 0, 1);
  452. }
  453. next:;
  454. if (!all)
  455. chan = NULL;
  456. else
  457. chan = chan->next;
  458. }
  459. }
  460. static void cmd_mmode(int idx, char *par)
  461. {
  462. char *mode = newsplit(&par);
  463. if (strlen(mode) > 2 || !strchr("+-", mode[0]) || !par[0]) {
  464. dprintf(idx, "Usage: mmode <(+|-)MODE> <#channel> <a|o|v|d|r> [bots=n] [alines=n] [slines=n] [overlap=n] [bitch] [simul]\n");
  465. dprintf(idx, "Ie. mmode -o #chan a\n");
  466. return;
  467. }
  468. putlog(LOG_CMDS, "*", "#%s# mmode %s %s", dcc[idx].nick, mode, par);
  469. char *chname = NULL;
  470. if (strchr(CHANMETA, par[0]) != NULL)
  471. chname = newsplit(&par);
  472. else
  473. chname = NULL;
  474. struct chanset_t *chan = get_channel(idx, chname);
  475. if (chan) {
  476. if (!shouldjoin(chan) || !channel_active(chan)) {
  477. dprintf(idx, "I'm not on %s\n", chan->dname);
  478. return;
  479. }
  480. if (channel_pending(chan)) {
  481. dprintf(idx, "Channel pending.\n");
  482. return;
  483. }
  484. get_user_flagrec(dcc[idx].user, &user, chan->dname, chan);
  485. if (!glob_owner(user) && !chan_owner(user)) {
  486. dprintf(idx, "You do not have mass mode access for %s\n", chan->dname);
  487. return;
  488. }
  489. }
  490. if (!chan || !chname[0]) {
  491. dprintf(idx, "Usage: mmode <(+|-)MODE> <#channel> <a|o|v|d|r> [bots=n] [alines=n] [slines=n] [overlap=n] [bitch] [simul]\n");
  492. dprintf(idx, "Ie. mmode -o #chan a\n");
  493. return;
  494. }
  495. char *who = newsplit(&par);
  496. if (strlen(who) > 1 || !strchr("aovdr", who[0])) {
  497. dprintf(idx, "Usage: mmode <(+|-)MODE> <#channel> <a|o|v|d|r> [bots=n] [alines=n] [slines=n] [overlap=n] [bitch] [simul]\n");
  498. dprintf(idx, "Ie. mmode -o #chan a\n");
  499. dprintf(idx, "a = all.\n");
  500. dprintf(idx, "o = ops.\n");
  501. dprintf(idx, "O = user-op.\n");
  502. dprintf(idx, "v = voices.\n");
  503. dprintf(idx, "d = non-ops.\n");
  504. dprintf(idx, "r = regulars (-ov).\n");
  505. return;
  506. }
  507. memberlist** targets = (memberlist**) my_calloc(1, chan->channel.members * sizeof(memberlist *));
  508. int* overlaps = (int *) my_calloc(1, chan->channel.members * sizeof(int *));
  509. memberlist** chanbots = (memberlist **) my_calloc(1, chan->channel.members * sizeof(memberlist *));
  510. memberlist *m = NULL;
  511. int chanbotcount = 0, targetcount = 0;
  512. for (m = chan->channel.member; m; m = m->next) {
  513. if (m->user) {
  514. if ((m->flags & CHANOP) && m->user->bot && (m->user->flags & USER_OP) &&
  515. (!match_my_nick(m->nick)) && (nextbot(m->user->handle) >= 0)) {
  516. chanbots[chanbotcount++] = m;
  517. continue;
  518. }
  519. get_user_flagrec(m->user, &user, chan->dname);
  520. }
  521. bool is_target = 0;
  522. if (who[0] == 'o' && (m->flags & CHANOP))
  523. is_target = 1;
  524. else if (who[0] == 'O' && chk_op(user, chan))
  525. is_target = 1;
  526. else if (who[0] == 'd' && !(m->flags & CHANOP))
  527. is_target = 1;
  528. else if (who[0] == 'v' && !(m->flags & CHANOP) && (m->flags & CHANVOICE))
  529. is_target = 1;
  530. else if (who[0] == 'r' && !(m->flags & CHANOP) && !(m->flags & CHANVOICE))
  531. is_target = 1;
  532. else if (who[0] == 'a')
  533. is_target = 1;
  534. if (is_target)
  535. targets[targetcount++] = m;
  536. }
  537. if (!chanbotcount) {
  538. dprintf(idx, "No bots opped on %s\n", chan->name);
  539. free(targets);
  540. free(overlaps);
  541. free(chanbots);
  542. return;
  543. }
  544. if (!targetcount) {
  545. dprintf(idx, "No one to mode on %s\n", chan->name);
  546. free(targets);
  547. free(overlaps);
  548. free(chanbots);
  549. return;
  550. }
  551. int force_bots = 0, force_alines = 0, force_slines = 0, force_overlap = 0;
  552. bool bitch = 0, simul = 0;
  553. while (par && par[0]) {
  554. char *p = newsplit(&par);
  555. if (!egg_strncasecmp(p, "bots=", 5)) {
  556. p += 5;
  557. force_bots = atoi(p);
  558. if ((force_bots < 1) || (force_bots > chanbotcount)) {
  559. dprintf(idx, "bots must be within 1-%i\n", chanbotcount);
  560. free(targets);
  561. free(overlaps);
  562. free(chanbots);
  563. return;
  564. }
  565. } else if (!egg_strncasecmp(p, "alines=", 7)) {
  566. p += 7;
  567. force_alines = atoi(p);
  568. if ((force_alines < 1) || (force_alines > 20)) {
  569. dprintf(idx, "alines must be within 1-20\n");
  570. dprintf(idx, ">5 will fail without a floodless.\n");
  571. free(targets);
  572. free(overlaps);
  573. free(chanbots);
  574. return;
  575. }
  576. } else if (!egg_strncasecmp(p, "slines=", 7)) {
  577. p += 7;
  578. force_slines = atoi(p);
  579. if ((force_slines < 1) || (force_slines > 20)) {
  580. dprintf(idx, "slines must be within 1-20\n");
  581. dprintf(idx, ">6 will fail without a floodless.\n");
  582. free(targets);
  583. free(overlaps);
  584. free(chanbots);
  585. return;
  586. }
  587. } else if (!egg_strncasecmp(p, "overlap=", 8)) {
  588. p += 8;
  589. force_overlap = atoi(p);
  590. if ((force_overlap < 1) || (force_overlap > 8)) {
  591. dprintf(idx, "overlap must be within 1-8\n");
  592. free(targets);
  593. free(overlaps);
  594. free(chanbots);
  595. return;
  596. }
  597. } else if (!strcmp(p, "bitch")) {
  598. bitch = 1;
  599. } else if (!strcmp(p, "simul")) {
  600. simul = 1;
  601. } else {
  602. dprintf(idx, "Unrecognized option %s\n", p);
  603. free(targets);
  604. free(overlaps);
  605. free(chanbots);
  606. return;
  607. }
  608. }
  609. int overlap = (force_overlap ? force_overlap : 1);
  610. int needed_modes = (overlap * targetcount);
  611. int max_modes = ((force_bots ? force_bots : chanbotcount) * (force_alines ? force_alines : 5) * modesperline);
  612. if (needed_modes > max_modes) {
  613. dprintf(idx, "Need to make %d modes, but the max is %d.\n", needed_modes, max_modes);
  614. dprintf(idx, "Try increasing [alines] or decreasing [overlap].\n");
  615. if (overlap == 1)
  616. dprintf(idx, "Not enough bots.\n");
  617. else
  618. dprintf(idx, "Not enough bots. Try with overlap=1\n");
  619. free(targets);
  620. free(overlaps);
  621. free(chanbots);
  622. return;
  623. }
  624. int bots, modes;
  625. /* ok it's possible... now let's figure out how */
  626. if (force_bots && force_alines) {
  627. /* not much choice... overlap should not autochange */
  628. bots = force_bots;
  629. modes = force_alines * modesperline;
  630. } else {
  631. if (force_bots) {
  632. /* calc needed modes per bot */
  633. bots = force_bots;
  634. modes = (needed_modes + (bots - 1)) / bots;
  635. } else if (force_alines) {
  636. modes = force_alines * modesperline;
  637. bots = (needed_modes + (modes - 1)) / modes;
  638. } else {
  639. /* Try minimizing alines, 1,2,3,4,5 against bots needed */
  640. modes = 1 * modesperline;
  641. bots = (needed_modes + (modes - 1)) / modes;
  642. for (int min_alines = 2; min_alines <= 5; ++min_alines) {
  643. if (bots > chanbotcount) {
  644. modes = min_alines * modesperline;
  645. bots = (needed_modes + (modes - 1)) / modes;
  646. } else
  647. break;
  648. }
  649. if (bots > chanbotcount) {
  650. putlog(LOG_MISC, "*", "Totally fucked calculations in cmd_mmode. this CAN'T happen.");
  651. dprintf(idx, "Something's wrong... bug the coder\n");
  652. free(targets);
  653. free(overlaps);
  654. free(chanbots);
  655. return;
  656. }
  657. }
  658. }
  659. /* How many modes to send */
  660. int smodes;
  661. if (force_slines)
  662. smodes = force_slines * modesperline;
  663. else
  664. smodes = 5 * modesperline;
  665. if (smodes < modes)
  666. smodes = modes;
  667. dprintf(idx, "Mass %s of %s\n", mode, chan->dname);
  668. dprintf(idx, " %d bots used.\n", bots);
  669. dprintf(idx, " %d targets.\n", targetcount);
  670. dprintf(idx, " %d assumed modes per participating bot.\n", modes);
  671. dprintf(idx, " %d max modes per participating bot.\n", smodes);
  672. dprintf(idx, " %d assumed modes per target nick.\n", overlap);
  673. int tpos = 0, bpos = 0, i = 0;
  674. char work[1024] = "";
  675. /* now use bots/modes to distribute nicks to MODE on */
  676. while (bots) {
  677. if (!simul)
  678. simple_snprintf(work, sizeof(work), "dp %s %s", mode, chan->dname);
  679. else
  680. work[0] = 0;
  681. /* Make list of assumed lines (alines) */
  682. for (i = 0; i < modes; i++) {
  683. if (overlaps[tpos]++ < overlap) {
  684. strcat(work, " ");
  685. strcat(work, targets[tpos]->nick);
  686. }
  687. if (++tpos >= targetcount)
  688. tpos = 0;
  689. }
  690. /* Now make lines of throttled modes (slines) */
  691. if (smodes > modes) {
  692. int atpos = tpos;
  693. for (i = 0; i < (smodes - modes); i++) {
  694. if (overlaps[tpos]++ < overlap) {
  695. strcat(work, " ");
  696. strcat(work, targets[atpos]->nick);
  697. }
  698. if (++atpos >= targetcount)
  699. atpos = 0;
  700. }
  701. }
  702. if (simul)
  703. dprintf(idx, "%s MODE %s %s\n", chanbots[bpos]->nick, mode, work);
  704. else
  705. putbot(chanbots[bpos]->user->handle, work);
  706. --bots;
  707. ++bpos;
  708. }
  709. if (bitch && !simul) {
  710. chan->status |= CHAN_BITCH;
  711. do_chanset(NULL, chan, "+bitch", DO_LOCAL | DO_NET);
  712. }
  713. free(targets);
  714. free(overlaps);
  715. free(chanbots);
  716. return;
  717. }
  718. void mass_mode_request(char *botnick, char *code, char *par)
  719. {
  720. char* mode = newsplit(&par);
  721. if (strlen(mode) > 2 || !strchr("+-", mode[0]))
  722. return;
  723. char* chname = newsplit(&par);
  724. char list[101] = "", buf[2048] = "";
  725. size_t list_len = 0, buf_len = 0;
  726. while (par[0]) {
  727. int cnt = 0;
  728. *(buf + buf_len++) = 'M';
  729. *(buf + buf_len++) = 'O';
  730. *(buf + buf_len++) = 'D';
  731. *(buf + buf_len++) = 'E';
  732. *(buf + buf_len++) = ' ';
  733. buf_len += strlcpy(buf + buf_len, chname, sizeof(buf) - buf_len);
  734. *(buf + buf_len++) = ' ';
  735. while ((cnt < 4) && par[0]) {
  736. /* add +mode into irc cmd */
  737. buf_len += strlcpy(buf + buf_len, mode, sizeof(buf) - buf_len);
  738. /* Make list of nicks */
  739. char* nick = newsplit(&par);
  740. list_len += strlcpy(list + list_len, nick, sizeof(list) - list_len);
  741. if (++cnt < 4 && par[0])
  742. *(list + list_len++) = ' ';
  743. }
  744. /* buf is so far: 'MODE #chan +o+o+o+o' */
  745. *(buf + buf_len++) = ' ';
  746. buf_len += strlcpy(buf + buf_len, list, sizeof(buf) - buf_len);
  747. *(buf + buf_len++) = '\r';
  748. *(buf + buf_len++) = '\n';
  749. list[0] = list_len = 0;
  750. }
  751. buf[buf_len] = 0;
  752. tputs(serv, buf, buf_len);
  753. }
  754. static void cmd_deop(int idx, char *par)
  755. {
  756. struct chanset_t *chan = NULL;
  757. char *nick = newsplit(&par);
  758. bool all = 0;
  759. if (par[0] == '*' && !par[1]) {
  760. all = 1;
  761. newsplit(&par);
  762. } else {
  763. chan = get_channel(idx, par);
  764. if (!chan || !has_op(idx, chan))
  765. return;
  766. }
  767. char s[UHOSTLEN] = "";
  768. memberlist *m = NULL;
  769. struct userrec *u = NULL;
  770. if (all)
  771. chan = chanset;
  772. putlog(LOG_CMDS, "*", "#%s# (%s) deop %s", dcc[idx].nick, all ? "*" : chan->dname, nick);
  773. while (chan) {
  774. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  775. if (!nick[0] && !(nick = getnick(dcc[idx].nick, chan))) {
  776. if (all) goto next;
  777. dprintf(idx, "Usage: deop <nick> [channel|*]\n");
  778. return;
  779. }
  780. if (privchan(user, chan, PRIV_OP)) {
  781. if (all) goto next;
  782. dprintf(idx, "No such channel.\n");
  783. }
  784. else if (!real_chk_op(user, chan, 0)) {
  785. if (all) goto next;
  786. dprintf(idx, "You don't have access to deop on %s\n", chan->dname);
  787. return;
  788. }
  789. if (!channel_active(chan)) {
  790. if (all) goto next;
  791. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  792. return;
  793. }
  794. if (!me_op(chan)) {
  795. if (all) goto next;
  796. dprintf(idx, "I can't help you now because I'm not a chan op on %s.\n",
  797. chan->dname);
  798. return;
  799. }
  800. m = ismember(chan, nick);
  801. if (!m) {
  802. if (all) goto next;
  803. dprintf(idx, "%s is not on %s.\n", nick, chan->dname);
  804. return;
  805. }
  806. if (match_my_nick(nick)) {
  807. if (all) goto next;
  808. dprintf(idx, "I'm not going to deop myself.\n");
  809. return;
  810. }
  811. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  812. u = get_user_by_host(s);
  813. get_user_flagrec(u, &victim, chan->dname);
  814. if ((chan_master(victim) || glob_master(victim)) &&
  815. !(chan_owner(user) || glob_owner(user))) {
  816. dprintf(idx, "%s is a master for %s.\n", m->nick, chan->dname);
  817. if (all) goto next;
  818. return;
  819. }
  820. if (chk_op(victim, chan) && !(chan_master(user) || glob_master(user))) {
  821. dprintf(idx, "%s has the op flag for %s.\n", m->nick, chan->dname);
  822. if (all) goto next;
  823. return;
  824. }
  825. add_mode(chan, '-', 'o', nick);
  826. dprintf(idx, "Deopped %s on %s.\n", nick, chan->dname);
  827. next:;
  828. if (!all)
  829. chan = NULL;
  830. else
  831. chan = chan->next;
  832. }
  833. }
  834. static void cmd_kick(int idx, char *par)
  835. {
  836. if (!par[0]) {
  837. dprintf(idx, "Usage: kick [channel|*] <nick> [reason]\n");
  838. return;
  839. }
  840. struct chanset_t *chan = NULL;
  841. char *chname = NULL;
  842. bool all = 0;
  843. if (par[0] == '*' && par[1] == ' ') {
  844. all = 1;
  845. newsplit(&par);
  846. } else {
  847. if (strchr(CHANMETA, par[0]) != NULL)
  848. chname = newsplit(&par);
  849. else
  850. chname = 0;
  851. chan = get_channel(idx, chname);
  852. if (!chan || !has_op(idx, chan))
  853. return;
  854. }
  855. putlog(LOG_CMDS, "*", "#%s# (%s) kick %s", dcc[idx].nick, all ? "*" : chan->dname, par);
  856. char *nick = newsplit(&par);
  857. if (!par[0])
  858. par = "request";
  859. if (match_my_nick(nick)) {
  860. dprintf(idx, "I'm not going to kick myself.\n");
  861. return;
  862. }
  863. char s[UHOSTLEN] = "";
  864. memberlist *m = NULL;
  865. struct userrec *u = NULL;
  866. if (all)
  867. chan = chanset;
  868. while (chan) {
  869. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  870. if (privchan(user, chan, PRIV_OP)) {
  871. if (all) goto next;
  872. dprintf(idx, "No such channel.\n");
  873. return;
  874. }
  875. else if (!real_chk_op(user, chan, 0)) {
  876. if (all) goto next;
  877. dprintf(idx, "You don't have access to kick on %s\n", chan->dname);
  878. return;
  879. }
  880. if (!channel_active(chan)) {
  881. if (all) goto next;
  882. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  883. return;
  884. }
  885. if (!me_op(chan)) {
  886. if (all) goto next;
  887. dprintf(idx, "I can't help you now because I'm not a channel op on %s.\n", chan->dname);
  888. return;
  889. }
  890. m = ismember(chan, nick);
  891. if (!m) {
  892. if (all) goto next;
  893. dprintf(idx, "%s is not on %s\n", nick, chan->dname);
  894. return;
  895. }
  896. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  897. u = get_user_by_host(s);
  898. get_user_flagrec(u, &victim, chan->dname);
  899. if (chk_op(victim, chan) && !(chan_master(user) || glob_master(user))) {
  900. if (all) goto next;
  901. dprintf(idx, "%s is a legal op.\n", nick);
  902. return;
  903. }
  904. if ((chan_master(victim) || glob_master(victim)) &&
  905. !(glob_owner(user) || chan_owner(user))) {
  906. if (all) goto next;
  907. dprintf(idx, "%s is a %s master.\n", nick, chan->dname);
  908. return;
  909. }
  910. if (glob_bot(victim) && !(glob_owner(user) || chan_owner(user))) {
  911. dprintf(idx, "%s is another channel bot!\n", nick);
  912. return;
  913. }
  914. dprintf(DP_SERVER, "KICK %s %s :%s%s\n", chan->name, m->nick, kickprefix, par);
  915. m->flags |= SENTKICK;
  916. dprintf(idx, "Kicked %s on %s.\n", nick, chan->dname);
  917. next:;
  918. if (!all)
  919. chan = NULL;
  920. else
  921. chan = chan->next;
  922. }
  923. }
  924. static void cmd_getkey(int idx, char *par)
  925. {
  926. struct chanset_t *chan = NULL;
  927. chan = get_channel(idx, par);
  928. if (!chan || !has_op(idx, chan))
  929. return;
  930. putlog(LOG_CMDS, "*", "#%s getkey %s", dcc[idx].nick, par);
  931. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  932. if (privchan(user, chan, PRIV_OP)) {
  933. dprintf(idx, "No such channel.\n");
  934. return;
  935. }
  936. else if (!real_chk_op(user, chan, 0)) {
  937. dprintf(idx, "You don't have access for %s\n", chan->dname);
  938. return;
  939. }
  940. if (!(channel_pending(chan) || channel_active(chan))) {
  941. dprintf(idx, "I'm not on %s right now.\n", chan->dname);
  942. return;
  943. }
  944. char outbuf[201] = "";
  945. if (!chan->channel.key[0])
  946. simple_snprintf(outbuf, sizeof(outbuf), "%s has no key set.", chan->dname);
  947. else
  948. simple_snprintf(outbuf, sizeof(outbuf), "Key for %s is: %s", chan->dname, chan->channel.key);
  949. if (chan->key_prot[0])
  950. simple_snprintf(outbuf, sizeof(outbuf), "%s (Enforcing +k %s)", outbuf, chan->key_prot);
  951. dprintf(idx, "%s\n", outbuf);
  952. }
  953. static void cmd_mop(int idx, char *par)
  954. {
  955. struct chanset_t *chan = NULL;
  956. bool found = 0, all = 0;
  957. if (par[0] == '*' && !par[1]) {
  958. get_user_flagrec(dcc[idx].user, &user, NULL);
  959. if (!glob_owner(user)) {
  960. dprintf(idx, "You do not have access to mop '*'\n");
  961. return;
  962. }
  963. all = 1;
  964. chan = chanset;
  965. newsplit(&par);
  966. } else {
  967. if (par[0] && (strchr(CHANMETA, par[0]) != NULL)) {
  968. chan = get_channel(idx, newsplit(&par), 0);
  969. } else
  970. chan = get_channel(idx, "", 0);
  971. }
  972. putlog(LOG_CMDS, "*", "#%s# (%s) mop %s", dcc[idx].nick, all ? "*" : (chan ? chan->dname : ""), par);
  973. if (!chan)
  974. return;
  975. if (!all) {
  976. dprintf(idx, "Usage: mop <channel|*>\n");
  977. return;
  978. }
  979. memberlist *m = NULL;
  980. char s[256] = "";
  981. while (chan) {
  982. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  983. if (privchan(user, chan, PRIV_OP)) {
  984. if (all) goto next;
  985. dprintf(idx, "No such channel.\n");
  986. return;
  987. }
  988. if (!chk_op(user, chan)) {
  989. if (all) goto next;
  990. dprintf(idx, "You are not a channel op on %s.\n", chan->dname);
  991. return;
  992. }
  993. if (!me_op(chan)) {
  994. if (all) goto next;
  995. dprintf(idx, "I am not opped on %s.\n", chan->dname);
  996. return;
  997. }
  998. if (channel_active(chan) && !channel_pending(chan)) {
  999. for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
  1000. if (!m->user) {
  1001. sprintf(s, "%s!%s", m->nick, m->userhost);
  1002. m->user = get_user_by_host(s);
  1003. if (!m->user && doresolv(chan) && m->userip[0]) {
  1004. simple_snprintf(s, sizeof(s), "%s!%s", m->nick, m->userip);
  1005. m->user = get_user_by_host(s);
  1006. }
  1007. }
  1008. if (m->user && u_pass_match(m->user, "-"))
  1009. continue; /* dont op users without a pass */
  1010. get_user_flagrec(m->user, &victim, chan->dname);
  1011. if (!chan_hasop(m) && !glob_bot(victim) && chk_op(victim, chan)) {
  1012. found++;
  1013. dprintf(idx, "Gave op to '%s' as '%s' on %s\n", m->user->handle, m->nick, chan->dname);
  1014. do_op(m->nick, chan, 0, 0);
  1015. }
  1016. }
  1017. } else {
  1018. if (!all)
  1019. dprintf(idx, "Channel %s is not active or is pending.\n", chan->dname);
  1020. return;
  1021. }
  1022. if (!found && !all)
  1023. dprintf(idx, "No one to op on %s\n", chan->dname);
  1024. next:;
  1025. if (!all)
  1026. chan = NULL;
  1027. else
  1028. chan = chan->next;
  1029. }
  1030. }
  1031. static void cmd_find(int idx, char *par)
  1032. {
  1033. if (!par[0]) {
  1034. dprintf(idx, "Usage: find <nick!ident@host.com>|<user> (wildcard * allowed)\n");
  1035. return;
  1036. }
  1037. putlog(LOG_CMDS, "*", "#%s# find %s", dcc[idx].nick, par);
  1038. struct chanset_t *chan = NULL, **cfound = NULL;
  1039. memberlist *m = NULL, **found = NULL;
  1040. int fcount = 0;
  1041. bool tr = 0, lookup_user = 0;
  1042. struct userrec *u = NULL;
  1043. if (!strchr(par, '!')) {
  1044. lookup_user = 1;
  1045. u = get_user_by_handle(userlist, par);
  1046. if (!u) {
  1047. dprintf(idx, "No such user: %s\n", par);
  1048. return;
  1049. }
  1050. }
  1051. /* make a list of members in found[] */
  1052. for (chan = chanset; chan; chan = chan->next) {
  1053. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1054. if (!privchan(user, chan, PRIV_OP)) {
  1055. for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
  1056. char s[UHOSTLEN] = "";
  1057. sprintf(s, "%s!%s", m->nick, m->userhost);
  1058. if (!m->user && !m->tried_getuser) {
  1059. m->user = get_user_by_host(s);
  1060. if (!m->user && doresolv(chan) && m->userip[0]) {
  1061. simple_snprintf(s, sizeof(s), "%s!%s", m->nick, m->userip);
  1062. m->user = get_user_by_host(s);
  1063. }
  1064. m->tried_getuser = 1;
  1065. }
  1066. if ((!lookup_user && wild_match(par, s)) || (lookup_user && m->user == u)) {
  1067. fcount++;
  1068. if (!found) {
  1069. found = (memberlist **) my_calloc(1, sizeof(memberlist *) * 100);
  1070. cfound = (struct chanset_t **) my_calloc(1, sizeof(struct chanset_t *) * 100);
  1071. }
  1072. found[fcount - 1] = m;
  1073. cfound[fcount - 1] = chan;
  1074. if (fcount == 100) {
  1075. tr = 1;
  1076. break;
  1077. }
  1078. }
  1079. }
  1080. }
  1081. if (fcount == 100) {
  1082. tr = 1;
  1083. break;
  1084. }
  1085. }
  1086. if (fcount) {
  1087. char tmp[1024] = "";
  1088. int findex, i;
  1089. for (findex = 0; findex < fcount; findex++) {
  1090. if (found[findex]) {
  1091. sprintf(tmp, "%s!%s %s%s%s on %s", found[findex]->nick, found[findex]->userhost,
  1092. found[findex]->user ? "(user:" : "", found[findex]->user ? found[findex]->user->handle : "", found[findex]->user ? ")" : "",
  1093. cfound[findex]->name);
  1094. for (i = findex + 1; i < fcount; i++) {
  1095. if (found[i] && (!strcmp(found[i]->nick, found[findex]->nick))) {
  1096. sprintf(tmp + strlen(tmp), ", %s", cfound[i]->name);
  1097. found[i] = NULL;
  1098. }
  1099. }
  1100. dprintf(idx, "%s\n", tmp);
  1101. }
  1102. }
  1103. free(found);
  1104. free(cfound);
  1105. } else {
  1106. dprintf(idx, "No matches for %s on any channels.\n", par);
  1107. }
  1108. if (tr)
  1109. dprintf(idx, "(more than 100 matches; list truncated)\n");
  1110. dprintf(idx, "--- Found %d matches.\n", fcount);
  1111. }
  1112. static void do_invite(int idx, char *par, bool op)
  1113. {
  1114. struct chanset_t *chan = NULL;
  1115. memberlist *m = NULL;
  1116. bool all = 0;
  1117. char *nick = NULL;
  1118. if (!par[0])
  1119. par = dcc[idx].nick;
  1120. nick = newsplit(&par);
  1121. if (par[0] == '*' && !par[1]) {
  1122. all = 1;
  1123. newsplit(&par);
  1124. } else {
  1125. chan = get_channel(idx, par);
  1126. if (!chan || !has_op(idx, chan))
  1127. return;
  1128. }
  1129. if (all)
  1130. chan = chanset;
  1131. putlog(LOG_CMDS, "*", "#%s# (%s) %s %s", dcc[idx].nick, all ? "*" : chan->dname, op ? "iop" : "invite", nick);
  1132. while (chan) {
  1133. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1134. if (privchan(user, chan, PRIV_OP)) {
  1135. if (all) goto next;
  1136. dprintf(idx, "No such channel.\n");
  1137. }
  1138. else if (!real_chk_op(user, chan, 0)) {
  1139. if (all) goto next;
  1140. dprintf(idx, "You don't have access to invite to %s\n", chan->dname);
  1141. return;
  1142. }
  1143. if (!me_op(chan)) {
  1144. if (all) goto next;
  1145. if (chan->channel.mode & CHANINV) {
  1146. dprintf(idx, "I can't help you now because I'm not a channel op on %s", chan->dname);
  1147. return;
  1148. }
  1149. if (!channel_active(chan)) {
  1150. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  1151. return;
  1152. }
  1153. }
  1154. m = ismember(chan, nick);
  1155. if (m && !chan_issplit(m)) {
  1156. if (all) goto next;
  1157. dprintf(idx, "%s is already on %s!\n", nick, chan->dname);
  1158. return;
  1159. }
  1160. cache_invite(chan, nick, NULL, NULL, op, 0);
  1161. dprintf(idx, "Inviting %s to %s.\n", nick, chan->dname);
  1162. next:;
  1163. if (!all)
  1164. chan = NULL;
  1165. else
  1166. chan = chan->next;
  1167. }
  1168. }
  1169. static void cmd_invite(int idx, char *par)
  1170. {
  1171. do_invite(idx, par, 0);
  1172. }
  1173. #ifdef CACHE
  1174. static void cmd_iop(int idx, char *par)
  1175. {
  1176. do_invite(idx, par, 1);
  1177. }
  1178. #endif /* CACHE */
  1179. static void cmd_authed(int idx, char *par)
  1180. {
  1181. putlog(LOG_CMDS, "*", "#%s# authed", dcc[idx].nick);
  1182. dprintf(idx, "Authed:\n");
  1183. Auth::TellAuthed(idx);
  1184. }
  1185. static void cmd_channel(int idx, char *par)
  1186. {
  1187. struct chanset_t *chan = NULL;
  1188. chan = get_channel(idx, par);
  1189. if (!chan || !has_op(idx, chan))
  1190. return;
  1191. char handle[HANDLEN + 1] = "", s[UHOSTLEN] = "", s1[UHOSTLEN] = "", atrflag = 0, chanflag[2] = "";
  1192. memberlist *m = NULL;
  1193. size_t maxnicklen, maxhandlen;
  1194. char format[81] = "";
  1195. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1196. putlog(LOG_CMDS, "*", "#%s# (%s) channel", dcc[idx].nick, chan->dname);
  1197. strlcpy(s, getchanmode(chan), sizeof s);
  1198. if (channel_pending(chan)) {
  1199. simple_snprintf(s1, sizeof s1, "Processing channel %s", chan->dname);
  1200. } else if (channel_active(chan)) {
  1201. simple_snprintf(s1, sizeof s1, "Channel %s", chan->dname);
  1202. } else {
  1203. simple_snprintf(s1, sizeof s1, "Desiring channel %s", chan->dname);
  1204. }
  1205. dprintf(idx, "%s, %d member%s, mode %s:\n", s1, chan->channel.members,
  1206. chan->channel.members == 1 ? "" : "s", s);
  1207. if (chan->channel.topic)
  1208. dprintf(idx, "%s: %s\n", "Channel Topic", chan->channel.topic);
  1209. if (channel_active(chan)) {
  1210. /* find max nicklen and handlen */
  1211. maxnicklen = maxhandlen = 0;
  1212. for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
  1213. if (strlen(m->nick) > maxnicklen)
  1214. maxnicklen = strlen(m->nick);
  1215. if (m->user)
  1216. if (strlen(m->user->handle) > maxhandlen)
  1217. maxhandlen = strlen(m->user->handle);
  1218. }
  1219. if (maxnicklen < 9) maxnicklen = 9;
  1220. if (maxhandlen < 9) maxhandlen = 9;
  1221. dprintf(idx, "(n = owner, m = master, o = op, d = deop, b = bot) CAP:global\n");
  1222. egg_snprintf(format, sizeof format, " %%-%us %%-%us %%-6s %%-4s %%-5s %%s %%s\n",
  1223. maxnicklen, maxhandlen);
  1224. dprintf(idx, format, "NICKNAME", "HANDLE", " JOIN", " HOPS", "IDLE", "USER@HOST", "USER@IP");
  1225. for (m = chan->channel.member; m && m->nick[0]; m = m->next) {
  1226. if (m->joined > 0) {
  1227. if ((now - (m->joined)) > 86400)
  1228. egg_strftime(s, 6, "%d%b", gmtime(&(m->joined)));
  1229. else
  1230. egg_strftime(s, 6, "%H:%M", gmtime(&(m->joined)));
  1231. } else
  1232. strlcpy(s, " --- ", sizeof s);
  1233. if (m->user == NULL) {
  1234. simple_snprintf(s1, sizeof s1, "%s!%s", m->nick, m->userhost);
  1235. m->user = get_user_by_host(s1);
  1236. if (!m->user && doresolv(chan) && m->userip[0]) {
  1237. simple_snprintf(s1, sizeof(s1), "%s!%s", m->nick, m->userip);
  1238. m->user = get_user_by_host(s1);
  1239. }
  1240. m->tried_getuser = 1;
  1241. }
  1242. if (m->user == NULL)
  1243. strlcpy(handle, "*", sizeof handle);
  1244. else
  1245. strlcpy(handle, m->user->handle, sizeof handle);
  1246. get_user_flagrec(m->user, &user, chan->dname);
  1247. /* Determine status char to use */
  1248. if (glob_bot(user) && chk_op(user, chan))
  1249. atrflag = 'B';
  1250. else if (glob_bot(user))
  1251. atrflag = 'b';
  1252. else if (glob_owner(user))
  1253. atrflag = 'N';
  1254. else if (chan_owner(user))
  1255. atrflag = 'n';
  1256. else if (glob_master(user))
  1257. atrflag = 'M';
  1258. else if (chan_master(user))
  1259. atrflag = 'm';
  1260. else if (glob_deop(user))
  1261. atrflag = 'D';
  1262. else if (chan_deop(user))
  1263. atrflag = 'd';
  1264. else if (glob_autoop(user))
  1265. atrflag = 'A';
  1266. else if (chan_autoop(user))
  1267. atrflag = 'a';
  1268. else if (glob_op(user) && !privchan(user, chan, PRIV_OP))
  1269. atrflag = 'O';
  1270. else if (chan_op(user))
  1271. atrflag = 'o';
  1272. else if (glob_quiet(user))
  1273. atrflag = 'Q';
  1274. else if (chan_quiet(user))
  1275. atrflag = 'q';
  1276. else if (glob_voice(user) && !privchan(user, chan, PRIV_VOICE))
  1277. atrflag = 'V';
  1278. else if (chan_voice(user))
  1279. atrflag = 'v';
  1280. else if (glob_kick(user))
  1281. atrflag = 'K';
  1282. else if (chan_kick(user))
  1283. atrflag = 'k';
  1284. else if (glob_wasoptest(user))
  1285. atrflag = 'W';
  1286. else if (chan_wasoptest(user))
  1287. atrflag = 'w';
  1288. else
  1289. atrflag = ' ';
  1290. if (chan_hasop(m))
  1291. chanflag[1] = '@';
  1292. else if (chan_hasvoice(m))
  1293. chanflag[1] = '+';
  1294. else
  1295. chanflag[1] = ' ';
  1296. if (m->flags & OPER)
  1297. chanflag[0] = 'O';
  1298. else
  1299. chanflag[0] = ' ';
  1300. if (chan_issplit(m)) {
  1301. egg_snprintf(format, sizeof format,
  1302. "%%c%%c%%-%us %%-%us %%s %%c <- netsplit, %%lus\n",
  1303. maxnicklen, maxhandlen);
  1304. dprintf(idx, format, chanflag[0],chanflag[1], m->nick, handle, s, atrflag,
  1305. now - (m->split));
  1306. } else if (!rfc_casecmp(m->nick, botname)) {
  1307. egg_snprintf(format, sizeof format,
  1308. "%%c%%c%%-%us %%-%us %%s %%c <- it's me!\n",
  1309. maxnicklen, maxhandlen);
  1310. dprintf(idx, format, chanflag[0], chanflag[1], m->nick, handle, s, atrflag);
  1311. } else {
  1312. /* Determine idle time */
  1313. if (now - (m->last) > 86400)
  1314. egg_snprintf(s1, sizeof s1, "%2lid", ((now - (m->last)) / 86400));
  1315. else if (now - (m->last) > 3600)
  1316. egg_snprintf(s1, sizeof s1, "%2lih", ((now - (m->last)) / 3600));
  1317. else if (now - (m->last) > 180)
  1318. egg_snprintf(s1, sizeof s1, "%2lim", ((now - (m->last)) / 60));
  1319. else
  1320. strlcpy(s1, " ", sizeof s1);
  1321. egg_snprintf(format, sizeof format, "%%c%%c%%-%us %%-%us %%s %%c %%d %%s %%s %%s\n",
  1322. maxnicklen, maxhandlen);
  1323. dprintf(idx, format, chanflag[0], chanflag[1], m->nick, handle, s, atrflag, m->hops,
  1324. s1, m->userhost, m->userip);
  1325. }
  1326. if (chan_fakeop(m))
  1327. dprintf(idx, " (FAKE CHANOP GIVEN BY SERVER)\n");
  1328. if (chan_sentop(m))
  1329. dprintf(idx, " (pending +o -- I'm lagged)\n");
  1330. if (chan_sentdeop(m))
  1331. dprintf(idx, " (pending -o -- I'm lagged)\n");
  1332. if (chan_sentkick(m))
  1333. dprintf(idx, " (pending kick)\n");
  1334. }
  1335. }
  1336. dprintf(idx, "End of channel info.\n");
  1337. }
  1338. static void cmd_topic(int idx, char *par)
  1339. {
  1340. struct chanset_t *chan = NULL;
  1341. if (par[0] && (strchr(CHANMETA, par[0]) != NULL)) {
  1342. chan = get_channel(idx, newsplit(&par));
  1343. } else
  1344. chan = get_channel(idx, "");
  1345. if (!chan || !has_op(idx, chan))
  1346. return;
  1347. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1348. if (!channel_active(chan)) {
  1349. dprintf(idx, "I'm not on %s right now!\n", chan->dname);
  1350. return;
  1351. }
  1352. if (!par[0]) {
  1353. if (chan->channel.topic) {
  1354. dprintf(idx, "The topic for %s is: %s\n", chan->dname,
  1355. chan->channel.topic);
  1356. } else {
  1357. dprintf(idx, "No topic is set for %s\n", chan->dname);
  1358. }
  1359. } else if (channel_optopic(chan) && !me_op(chan)) {
  1360. dprintf(idx, "I'm not a channel op on %s and the channel %s",
  1361. "is +t.\n", chan->dname);
  1362. } else {
  1363. dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, par);
  1364. dprintf(idx, "Changing topic...\n");
  1365. putlog(LOG_CMDS, "*", "#%s# (%s) topic %s", dcc[idx].nick,
  1366. chan->dname, par);
  1367. }
  1368. }
  1369. static void cmd_resetbans(int idx, char *par)
  1370. {
  1371. struct chanset_t *chan = get_channel(idx, newsplit(&par));
  1372. if (!chan || !has_op(idx, chan))
  1373. return;
  1374. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1375. putlog(LOG_CMDS, "*", "#%s# (%s) resetbans", dcc[idx].nick, chan->dname);
  1376. dprintf(idx, "Resetting bans on %s...\n", chan->dname);
  1377. resetbans(chan);
  1378. }
  1379. static void cmd_resetexempts(int idx, char *par)
  1380. {
  1381. struct chanset_t *chan = get_channel(idx, newsplit(&par));
  1382. if (!chan || !has_op(idx, chan))
  1383. return;
  1384. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1385. putlog(LOG_CMDS, "*", "#%s# (%s) resetexempts", dcc[idx].nick, chan->dname);
  1386. dprintf(idx, "Resetting exempts on %s...\n", chan->dname);
  1387. resetexempts(chan);
  1388. }
  1389. static void cmd_resetinvites(int idx, char *par)
  1390. {
  1391. struct chanset_t *chan = get_channel(idx, newsplit(&par));
  1392. if (!chan || !has_op(idx, chan))
  1393. return;
  1394. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1395. putlog(LOG_CMDS, "*", "#%s# (%s) resetinvites", dcc[idx].nick, chan->dname);
  1396. dprintf(idx, "Resetting resetinvites on %s...\n", chan->dname);
  1397. resetinvites(chan);
  1398. }
  1399. static void cmd_adduser(int idx, char *par)
  1400. {
  1401. if ((!par[0]) || ((par[0] =='!') && (!par[1]))) {
  1402. dprintf(idx, "Usage: adduser <nick> [handle]\n");
  1403. return;
  1404. }
  1405. char *nick = NULL, *hand = NULL;
  1406. struct chanset_t *chan = NULL;
  1407. struct userrec *u = NULL;
  1408. memberlist *m = NULL;
  1409. char s[UHOSTLEN] = "", s1[UHOSTLEN] = "", s2[MAXPASSLEN + 1] = "", s3[MAXPASSLEN + 1] = "", tmp[50] = "";
  1410. int atr = dcc[idx].user ? dcc[idx].user->flags : 0;
  1411. bool statichost = 0;
  1412. char *p1 = s1;
  1413. putlog(LOG_CMDS, "*", "#%s# adduser %s", dcc[idx].nick, par);
  1414. nick = newsplit(&par);
  1415. /* This flag allows users to have static host (added by drummer, 20Apr99) */
  1416. if (nick[0] == '!') {
  1417. statichost = 1;
  1418. nick++;
  1419. }
  1420. if (!par[0]) {
  1421. hand = nick;
  1422. } else {
  1423. bool ok = 1;
  1424. for (char *p = par; *p; p++)
  1425. if ((*p <= 32) || (*p >= 127))
  1426. ok = 0;
  1427. if (!ok) {
  1428. dprintf(idx, "You can't have strange characters in a nick.\n");
  1429. return;
  1430. } else if (strchr("-,+*=:!.@#;$", par[0]) != NULL) {
  1431. dprintf(idx, "You can't start a nick with '%c'.\n", par[0]);
  1432. return;
  1433. }
  1434. hand = par;
  1435. }
  1436. for (chan = chanset; chan; chan = chan->next) {
  1437. m = ismember(chan, nick);
  1438. if (m)
  1439. break;
  1440. }
  1441. if (!m) {
  1442. dprintf(idx, "%s is not on any channels I monitor\n", nick);
  1443. return;
  1444. }
  1445. if (strlen(hand) > HANDLEN)
  1446. hand[HANDLEN] = 0;
  1447. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  1448. if ((u = get_user_by_host(s))) {
  1449. dprintf(idx, "%s is already known as %s.\n", nick, u->handle);
  1450. return;
  1451. }
  1452. u = get_user_by_handle(userlist, hand);
  1453. if (u && (u->flags & (USER_OWNER | USER_MASTER)) &&
  1454. !(atr & USER_OWNER) && egg_strcasecmp(dcc[idx].nick, hand)) {
  1455. dprintf(idx, "You can't add hostmasks to the bot owner/master.\n");
  1456. return;
  1457. }
  1458. if (!statichost)
  1459. maskhost(s, s1);
  1460. else {
  1461. strlcpy(s1, s, sizeof s1);
  1462. p1 = strchr(s1, '!');
  1463. if (strchr("~^+=-", p1[1]))
  1464. p1[1] = '?';
  1465. p1--;
  1466. p1[0] = '*';
  1467. }
  1468. if (!u) {
  1469. userlist = adduser(userlist, hand, p1, "-", USER_DEFAULT, 0);
  1470. u = get_user_by_handle(userlist, hand);
  1471. sprintf(tmp, "%li %s", now, dcc[idx].nick);
  1472. set_user(&USERENTRY_ADDED, u, tmp);
  1473. make_rand_str(s2, MAXPASSLEN);
  1474. set_user(&USERENTRY_PASS, u, s2);
  1475. make_rand_str(s3, MAXPASSLEN);
  1476. set_user(&USERENTRY_SECPASS, u, s3);
  1477. dprintf(idx, "Added [%s]%s with no flags.\n", hand, p1);
  1478. dprintf(idx, "%s's initial password set to \002%s\002\n", hand, s2);
  1479. dprintf(idx, "%s's initial secpass set to \002%s\002\n", hand, s3);
  1480. dprintf(DP_HELP, "PRIVMSG %s :*** You've been add to this botnet as '%s' with the host '%s'. Ask a botnet admin for the msg cmds. Your initial password is: %s\n", nick, hand, p1, s2);
  1481. } else {
  1482. dprintf(idx, "Added hostmask %s to %s.\n", p1, u->handle);
  1483. addhost_by_handle(hand, p1);
  1484. get_user_flagrec(u, &user, chan->dname);
  1485. check_this_user(hand, 0, NULL);
  1486. }
  1487. }
  1488. static void cmd_deluser(int idx, char *par)
  1489. {
  1490. if (!par[0]) {
  1491. dprintf(idx, "Usage: deluser <nick>\n");
  1492. return;
  1493. }
  1494. char *nick = NULL, s[UHOSTLEN] = "", *added = NULL;
  1495. struct chanset_t *chan = NULL;
  1496. memberlist *m = NULL;
  1497. struct userrec *u = NULL;
  1498. nick = newsplit(&par);
  1499. for (chan = chanset; chan; chan = chan->next) {
  1500. m = ismember(chan, nick);
  1501. if (m)
  1502. break;
  1503. }
  1504. if (!m) {
  1505. dprintf(idx, "%s is not on any channels I monitor\n", nick);
  1506. return;
  1507. }
  1508. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1509. simple_snprintf(s, sizeof s, "%s!%s", m->nick, m->userhost);
  1510. if (!(u = get_user_by_host(s))) {
  1511. dprintf(idx, "%s is not a valid user.\n", nick);
  1512. return;
  1513. }
  1514. added = (char *) get_user(&USERENTRY_ADDED, u);
  1515. newsplit(&added);
  1516. get_user_flagrec(u, &victim, NULL);
  1517. if (isowner(u->handle)) {
  1518. dprintf(idx, "You can't remove a permanent bot owner!\n");
  1519. } else if (glob_admin(victim) && !isowner(dcc[idx].nick)) {
  1520. dprintf(idx, "You can't remove an admin!\n");
  1521. } else if (glob_owner(victim)) {
  1522. dprintf(idx, "You can't remove a bot owner!\n");
  1523. } else if (chan_owner(victim) && !glob_owner(user)) {
  1524. dprintf(idx, "You can't remove a channel owner!\n");
  1525. } else if (chan_master(victim) && !(glob_owner(user) || chan_owner(user))) {
  1526. dprintf(idx, "You can't remove a channel master!\n");
  1527. } else if (glob_bot(victim) && !glob_owner(user)) {
  1528. dprintf(idx, "You can't remove a bot!\n");
  1529. } else if (!glob_master(user) && egg_strcasecmp(dcc[idx].nick, added)) {
  1530. dprintf(idx, "Sorry, you may not delete this user as you did not add them.\n");
  1531. } else {
  1532. char buf[HANDLEN + 1] = "";
  1533. strlcpy(buf, u->handle, sizeof buf);
  1534. buf[HANDLEN] = 0;
  1535. if (deluser(u->handle)) {
  1536. dprintf(idx, "Deleted %s.\n", buf); /* ?!?! :) */
  1537. putlog(LOG_CMDS, "*", "#%s# deluser %s [%s]", dcc[idx].nick, nick, buf);
  1538. } else {
  1539. dprintf(idx, "Failed.\n");
  1540. }
  1541. }
  1542. }
  1543. static void cmd_reset(int idx, char *par)
  1544. {
  1545. struct chanset_t *chan = NULL;
  1546. if (par[0]) {
  1547. chan = findchan_by_dname(par);
  1548. if (chan)
  1549. get_user_flagrec(dcc[idx].user, &user, chan->dname);
  1550. if (!chan || privchan(user, chan, PRIV_OP)) {
  1551. dprintf(idx, "I don't monitor that channel.\n");
  1552. } else {
  1553. get_user_flagrec(dcc[idx].user, &user, par);
  1554. if (!glob_master(user) && !chan_master(user)) {
  1555. dprintf(idx, "You are not a master on %s.\n", chan->dname);
  1556. } else if (!channel_active(chan)) {
  1557. dprintf(idx, "I'm not on %s at the moment!\n", chan->dname);
  1558. } else {
  1559. putlog(LOG_CMDS, "*", "#%s# reset %s", dcc[idx].nick, par);
  1560. dprintf(idx, "Resetting channel info for %s...\n", chan->dname);
  1561. reset_chan_info(chan);
  1562. }
  1563. }
  1564. } else if (!(dcc[idx].user->flags & USER_MASTER)) {
  1565. dprintf(idx, "You are not a Bot Master.\n");
  1566. } else {
  1567. putlog(LOG_CMDS, "*", "#%s# reset all", dcc[idx].nick);
  1568. dprintf(idx, "Resetting channel info for all channels...\n");
  1569. for (chan = chanset; chan; chan = chan->next) {
  1570. if (channel_active(chan) || (!channel_active(chan) && shouldjoin(chan)))
  1571. reset_chan_info(chan);
  1572. }
  1573. }
  1574. }
  1575. static cmd_t irc_dcc[] =
  1576. {
  1577. {"act", "o|o", (Function) cmd_act, NULL, LEAF},
  1578. {"adduser", "m|m", (Function) cmd_adduser, NULL, LEAF|AUTH},
  1579. {"authed", "n", (Function) cmd_authed, NULL, LEAF},
  1580. {"channel", "o|o", (Function) cmd_channel, NULL, LEAF},
  1581. {"deluser", "m|m", (Function) cmd_deluser, NULL, LEAF|AUTH},
  1582. {"deop", "o|o", (Function) cmd_deop, NULL, LEAF|AUTH},
  1583. {"devoice", "o|o", (Function) cmd_devoice, NULL, LEAF|AUTH},
  1584. {"getkey", "o|o", (Function) cmd_getkey, NULL, LEAF|AUTH},
  1585. {"find", "", (Function) cmd_find, NULL, LEAF|AUTH},
  1586. {"invite", "o|o", (Function) cmd_invite, NULL, LEAF|AUTH},
  1587. #ifdef CACHE
  1588. {"iop", "o|o", (Function) cmd_iop, NULL, LEAF|AUTH},
  1589. #endif /* CACHE */
  1590. {"kick", "o|o", (Function) cmd_kick, NULL, LEAF|AUTH},
  1591. {"kickban", "o|o", (Function) cmd_kickban, NULL, LEAF|AUTH},
  1592. {"mmode", "n|n", (Function) cmd_mmode, NULL, LEAF},
  1593. {"mop", "n|m", (Function) cmd_mop, NULL, LEAF|AUTH},
  1594. {"msg", "o", (Function) cmd_msg, NULL, LEAF|AUTH},
  1595. {"op", "o|o", (Function) cmd_op, NULL, LEAF|AUTH},
  1596. {"reset", "m|m", (Function) cmd_reset, NULL, LEAF|AUTH},
  1597. {"resetbans", "o|o", (Function) cmd_resetbans, NULL, LEAF|AUTH},
  1598. {"resetexempts", "o|o", (Function) cmd_resetexempts, NULL, LEAF|AUTH},
  1599. {"resetinvites", "o|o", (Function) cmd_resetinvites, NULL, LEAF|AUTH},
  1600. {"say", "o|o", (Function) cmd_say, NULL, LEAF},
  1601. {"swhois", "", (Function) cmd_swhois, NULL, LEAF|AUTH},
  1602. {"topic", "o|o", (Function) cmd_topic, NULL, LEAF|AUTH},
  1603. {"voice", "o|o", (Function) cmd_voice, NULL, LEAF|AUTH},
  1604. {NULL, NULL, NULL, NULL, 0}
  1605. };