cmdschan.c 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902
  1. #include <ctype.h>
  2. static struct flag_record user = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
  3. static struct flag_record victim = { FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0 };
  4. static void
  5. cmd_pls_ban (struct userrec *u, int idx, char *par)
  6. {
  7. char *chname, *who, s[UHOSTLEN], s1[UHOSTLEN], *p, *p_expire;
  8. unsigned long int expire_time = 0, expire_foo;
  9. int sticky = 0;
  10. struct chanset_t *chan = NULL;
  11. module_entry *me;
  12. if (!par[0])
  13. {
  14. dprintf (idx,
  15. "Usage: +ban <hostmask> [channel] [%%<XdXhXm>] [reason]\n");
  16. }
  17. else
  18. {
  19. who = newsplit (&par);
  20. if (par[0] && strchr (CHANMETA, par[0]))
  21. chname = newsplit (&par);
  22. else
  23. chname = 0;
  24. if (chname || !(u->flags & USER_MASTER))
  25. {
  26. if (!chname)
  27. chname = dcc[idx].u.chat->con_chan;
  28. get_user_flagrec (u, &user, chname);
  29. chan = findchan_by_dname (chname);
  30. if (!chan)
  31. {
  32. dprintf (idx, "That channel doesn't exist!\n");
  33. return;
  34. }
  35. else if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  36. {
  37. dprintf (idx, "You don't have access to set bans on %s.\n",
  38. chname);
  39. return;
  40. }
  41. }
  42. else
  43. chan = 0;
  44. if (par[0] == '%')
  45. {
  46. p = newsplit (&par);
  47. p_expire = p + 1;
  48. while (*(++p) != 0)
  49. {
  50. switch (tolower (*p))
  51. {
  52. case 'd':
  53. *p = 0;
  54. expire_foo = strtol (p_expire, NULL, 10);
  55. if (expire_foo > 365)
  56. expire_foo = 365;
  57. expire_time += 86400 * expire_foo;
  58. p_expire = p + 1;
  59. break;
  60. case 'h':
  61. *p = 0;
  62. expire_foo = strtol (p_expire, NULL, 10);
  63. if (expire_foo > 8760)
  64. expire_foo = 8760;
  65. expire_time += 3600 * expire_foo;
  66. p_expire = p + 1;
  67. break;
  68. case 'm':
  69. *p = 0;
  70. expire_foo = strtol (p_expire, NULL, 10);
  71. if (expire_foo > 525600)
  72. expire_foo = 525600;
  73. expire_time += 60 * expire_foo;
  74. p_expire = p + 1;
  75. }
  76. }
  77. }
  78. if (!par[0])
  79. par = "requested";
  80. else if (strlen (par) > MASKREASON_MAX)
  81. par[MASKREASON_MAX] = 0;
  82. if (strlen (who) > UHOSTMAX - 4)
  83. who[UHOSTMAX - 4] = 0;
  84. if (!strchr (who, '!'))
  85. {
  86. if (!strchr (who, '@'))
  87. egg_snprintf (s, sizeof s, "%s!*@*", who);
  88. else
  89. egg_snprintf (s, sizeof s, "*!%s", who);
  90. }
  91. else if (!strchr (who, '@'))
  92. egg_snprintf (s, sizeof s, "%s@*", who);
  93. else
  94. strncpyz (s, who, sizeof s);
  95. if ((me = module_find ("server", 0, 0)) && me->funcs)
  96. egg_snprintf (s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
  97. me->funcs[SERVER_BOTUSERHOST]);
  98. else
  99. egg_snprintf (s1, sizeof s1, "%s!%s@%s", origbotname, botuser,
  100. hostname);
  101. if (wild_match (s, s1))
  102. {
  103. dprintf (idx, "I'm not going to ban myself.\n");
  104. putlog (LOG_CMDS, "*", "#%s# attempted +ban %s", dcc[idx].nick, s);
  105. }
  106. else
  107. {
  108. if (strlen (s) > 70)
  109. {
  110. s[69] = '*';
  111. s[70] = 0;
  112. }
  113. if (chan)
  114. {
  115. u_addban (chan, s, dcc[idx].nick, par,
  116. expire_time ? now + expire_time : 0, 0);
  117. if (par[0] == '*')
  118. {
  119. sticky = 1;
  120. par++;
  121. putlog (LOG_CMDS, "*", "#%s# (%s) +ban %s %s (%s) (sticky)",
  122. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  123. chan->dname, par);
  124. dprintf (idx, "New %s sticky ban: %s (%s)\n", chan->dname,
  125. s, par);
  126. }
  127. else
  128. {
  129. putlog (LOG_CMDS, "*", "#%s# (%s) +ban %s %s (%s)",
  130. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  131. chan->dname, par);
  132. dprintf (idx, "New %s ban: %s (%s)\n", chan->dname, s, par);
  133. }
  134. if ((me = module_find ("irc", 0, 0)))
  135. (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky);
  136. }
  137. else
  138. {
  139. u_addban (NULL, s, dcc[idx].nick, par,
  140. expire_time ? now + expire_time : 0, 0);
  141. if (par[0] == '*')
  142. {
  143. sticky = 1;
  144. par++;
  145. putlog (LOG_CMDS, "*",
  146. "#%s# (GLOBAL) +ban %s (%s) (sticky)",
  147. dcc[idx].nick, s, par);
  148. dprintf (idx, "New sticky ban: %s (%s)\n", s, par);
  149. }
  150. else
  151. {
  152. putlog (LOG_CMDS, "*", "#%s# (GLOBAL) +ban %s (%s)",
  153. dcc[idx].nick, s, par);
  154. dprintf (idx, "New ban: %s (%s)\n", s, par);
  155. }
  156. if ((me = module_find ("irc", 0, 0)))
  157. for (chan = chanset; chan != NULL; chan = chan->next)
  158. (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, sticky);
  159. }
  160. }
  161. }
  162. }
  163. #ifdef S_IRCNET
  164. static void
  165. cmd_pls_exempt (struct userrec *u, int idx, char *par)
  166. {
  167. char *chname, *who, s[UHOSTLEN], s1[UHOSTLEN], *p, *p_expire;
  168. unsigned long int expire_time = 0, expire_foo;
  169. struct chanset_t *chan = NULL;
  170. module_entry *me;
  171. if (!use_exempts)
  172. {
  173. dprintf (idx,
  174. "This command can only be used with use-exempts enabled.\n");
  175. return;
  176. }
  177. if (!par[0])
  178. {
  179. dprintf (idx,
  180. "Usage: +exempt <hostmask> [channel] [%%<XdXhXm>] [reason]\n");
  181. }
  182. else
  183. {
  184. who = newsplit (&par);
  185. if (par[0] && strchr (CHANMETA, par[0]))
  186. chname = newsplit (&par);
  187. else
  188. chname = 0;
  189. if (chname || !(u->flags & USER_MASTER))
  190. {
  191. if (!chname)
  192. chname = dcc[idx].u.chat->con_chan;
  193. get_user_flagrec (u, &user, chname);
  194. chan = findchan_by_dname (chname);
  195. if (!chan)
  196. {
  197. dprintf (idx, "That channel doesn't exist!\n");
  198. return;
  199. }
  200. else if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  201. {
  202. dprintf (idx, "You don't have access to set exempts on %s.\n",
  203. chname);
  204. return;
  205. }
  206. }
  207. else
  208. chan = 0;
  209. if (par[0] == '%')
  210. {
  211. p = newsplit (&par);
  212. p_expire = p + 1;
  213. while (*(++p) != 0)
  214. {
  215. switch (tolower (*p))
  216. {
  217. case 'd':
  218. *p = 0;
  219. expire_foo = strtol (p_expire, NULL, 10);
  220. if (expire_foo > 365)
  221. expire_foo = 365;
  222. expire_time += 86400 * expire_foo;
  223. p_expire = p + 1;
  224. break;
  225. case 'h':
  226. *p = 0;
  227. expire_foo = strtol (p_expire, NULL, 10);
  228. if (expire_foo > 8760)
  229. expire_foo = 8760;
  230. expire_time += 3600 * expire_foo;
  231. p_expire = p + 1;
  232. break;
  233. case 'm':
  234. *p = 0;
  235. expire_foo = strtol (p_expire, NULL, 10);
  236. if (expire_foo > 525600)
  237. expire_foo = 525600;
  238. expire_time += 60 * expire_foo;
  239. p_expire = p + 1;
  240. }
  241. }
  242. }
  243. if (!par[0])
  244. par = "requested";
  245. else if (strlen (par) > MASKREASON_MAX)
  246. par[MASKREASON_MAX] = 0;
  247. if (strlen (who) > UHOSTMAX - 4)
  248. who[UHOSTMAX - 4] = 0;
  249. if (!strchr (who, '!'))
  250. {
  251. if (!strchr (who, '@'))
  252. egg_snprintf (s, sizeof s, "%s!*@*", who);
  253. else
  254. egg_snprintf (s, sizeof s, "*!%s", who);
  255. }
  256. else if (!strchr (who, '@'))
  257. egg_snprintf (s, sizeof s, "%s@*", who);
  258. else
  259. strncpyz (s, who, sizeof s);
  260. if ((me = module_find ("server", 0, 0)) && me->funcs)
  261. egg_snprintf (s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
  262. me->funcs[SERVER_BOTUSERHOST]);
  263. else
  264. egg_snprintf (s1, sizeof s1, "%s!%s@%s", origbotname, botuser,
  265. hostname);
  266. if (strlen (s) > 70)
  267. {
  268. s[69] = '*';
  269. s[70] = 0;
  270. }
  271. if (chan)
  272. {
  273. u_addexempt (chan, s, dcc[idx].nick, par,
  274. expire_time ? now + expire_time : 0, 0);
  275. if (par[0] == '*')
  276. {
  277. par++;
  278. putlog (LOG_CMDS, "*", "#%s# (%s) +exempt %s %s (%s) (sticky)",
  279. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  280. chan->dname, par);
  281. dprintf (idx, "New %s sticky exempt: %s (%s)\n", chan->dname, s,
  282. par);
  283. }
  284. else
  285. {
  286. putlog (LOG_CMDS, "*", "#%s# (%s) +exempt %s %s (%s)",
  287. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  288. chan->dname, par);
  289. dprintf (idx, "New %s exempt: %s (%s)\n", chan->dname, s, par);
  290. }
  291. add_mode (chan, '+', 'e', s);
  292. }
  293. else
  294. {
  295. u_addexempt (NULL, s, dcc[idx].nick, par,
  296. expire_time ? now + expire_time : 0, 0);
  297. if (par[0] == '*')
  298. {
  299. par++;
  300. putlog (LOG_CMDS, "*", "#%s# (GLOBAL) +exempt %s (%s) (sticky)",
  301. dcc[idx].nick, s, par);
  302. dprintf (idx, "New sticky exempt: %s (%s)\n", s, par);
  303. }
  304. else
  305. {
  306. putlog (LOG_CMDS, "*", "#%s# (GLOBAL) +exempt %s (%s)",
  307. dcc[idx].nick, s, par);
  308. dprintf (idx, "New exempt: %s (%s)\n", s, par);
  309. }
  310. for (chan = chanset; chan != NULL; chan = chan->next)
  311. add_mode (chan, '+', 'e', s);
  312. }
  313. }
  314. }
  315. static void
  316. cmd_pls_invite (struct userrec *u, int idx, char *par)
  317. {
  318. char *chname, *who, s[UHOSTLEN], s1[UHOSTLEN], *p, *p_expire;
  319. unsigned long int expire_time = 0, expire_foo;
  320. struct chanset_t *chan = NULL;
  321. module_entry *me;
  322. if (!use_invites)
  323. {
  324. dprintf (idx,
  325. "This command can only be used with use-invites enabled.\n");
  326. return;
  327. }
  328. if (!par[0])
  329. {
  330. dprintf (idx,
  331. "Usage: +invite <hostmask> [channel] [%%<XdXhXm>] [reason]\n");
  332. }
  333. else
  334. {
  335. who = newsplit (&par);
  336. if (par[0] && strchr (CHANMETA, par[0]))
  337. chname = newsplit (&par);
  338. else
  339. chname = 0;
  340. if (chname || !(u->flags & USER_MASTER))
  341. {
  342. if (!chname)
  343. chname = dcc[idx].u.chat->con_chan;
  344. get_user_flagrec (u, &user, chname);
  345. chan = findchan_by_dname (chname);
  346. if (!chan)
  347. {
  348. dprintf (idx, "That channel doesn't exist!\n");
  349. return;
  350. }
  351. else if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  352. {
  353. dprintf (idx, "You don't have access to set invites on %s.\n",
  354. chname);
  355. return;
  356. }
  357. }
  358. else
  359. chan = 0;
  360. if (par[0] == '%')
  361. {
  362. p = newsplit (&par);
  363. p_expire = p + 1;
  364. while (*(++p) != 0)
  365. {
  366. switch (tolower (*p))
  367. {
  368. case 'd':
  369. *p = 0;
  370. expire_foo = strtol (p_expire, NULL, 10);
  371. if (expire_foo > 365)
  372. expire_foo = 365;
  373. expire_time += 86400 * expire_foo;
  374. p_expire = p + 1;
  375. break;
  376. case 'h':
  377. *p = 0;
  378. expire_foo = strtol (p_expire, NULL, 10);
  379. if (expire_foo > 8760)
  380. expire_foo = 8760;
  381. expire_time += 3600 * expire_foo;
  382. p_expire = p + 1;
  383. break;
  384. case 'm':
  385. *p = 0;
  386. expire_foo = strtol (p_expire, NULL, 10);
  387. if (expire_foo > 525600)
  388. expire_foo = 525600;
  389. expire_time += 60 * expire_foo;
  390. p_expire = p + 1;
  391. }
  392. }
  393. }
  394. if (!par[0])
  395. par = "requested";
  396. else if (strlen (par) > MASKREASON_MAX)
  397. par[MASKREASON_MAX] = 0;
  398. if (strlen (who) > UHOSTMAX - 4)
  399. who[UHOSTMAX - 4] = 0;
  400. if (!strchr (who, '!'))
  401. {
  402. if (!strchr (who, '@'))
  403. egg_snprintf (s, sizeof s, "%s!*@*", who);
  404. else
  405. egg_snprintf (s, sizeof s, "*!%s", who);
  406. }
  407. else if (!strchr (who, '@'))
  408. egg_snprintf (s, sizeof s, "%s@*", who);
  409. else
  410. strncpyz (s, who, sizeof s);
  411. if ((me = module_find ("server", 0, 0)) && me->funcs)
  412. egg_snprintf (s1, sizeof s1, "%s!%s", me->funcs[SERVER_BOTNAME],
  413. me->funcs[SERVER_BOTUSERHOST]);
  414. else
  415. egg_snprintf (s1, sizeof s1, "%s!%s@%s", origbotname, botuser,
  416. hostname);
  417. if (strlen (s) > 70)
  418. {
  419. s[69] = '*';
  420. s[70] = 0;
  421. }
  422. if (chan)
  423. {
  424. u_addinvite (chan, s, dcc[idx].nick, par,
  425. expire_time ? now + expire_time : 0, 0);
  426. if (par[0] == '*')
  427. {
  428. par++;
  429. putlog (LOG_CMDS, "*", "#%s# (%s) +invite %s %s (%s) (sticky)",
  430. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  431. chan->dname, par);
  432. dprintf (idx, "New %s sticky invite: %s (%s)\n", chan->dname, s,
  433. par);
  434. }
  435. else
  436. {
  437. putlog (LOG_CMDS, "*", "#%s# (%s) +invite %s %s (%s)",
  438. dcc[idx].nick, dcc[idx].u.chat->con_chan, s,
  439. chan->dname, par);
  440. dprintf (idx, "New %s invite: %s (%s)\n", chan->dname, s, par);
  441. }
  442. add_mode (chan, '+', 'I', s);
  443. }
  444. else
  445. {
  446. u_addinvite (NULL, s, dcc[idx].nick, par,
  447. expire_time ? now + expire_time : 0, 0);
  448. if (par[0] == '*')
  449. {
  450. par++;
  451. putlog (LOG_CMDS, "*", "#%s# (GLOBAL) +invite %s (%s) (sticky)",
  452. dcc[idx].nick, s, par);
  453. dprintf (idx, "New sticky invite: %s (%s)\n", s, par);
  454. }
  455. else
  456. {
  457. putlog (LOG_CMDS, "*", "#%s# (GLOBAL) +invite %s (%s)",
  458. dcc[idx].nick, s, par);
  459. dprintf (idx, "New invite: %s (%s)\n", s, par);
  460. }
  461. for (chan = chanset; chan != NULL; chan = chan->next)
  462. add_mode (chan, '+', 'I', s);
  463. }
  464. }
  465. }
  466. #endif
  467. static void
  468. cmd_mns_ban (struct userrec *u, int idx, char *par)
  469. {
  470. int console = 0, i = 0, j;
  471. struct chanset_t *chan = NULL;
  472. char s[UHOSTLEN], *ban, *chname, *mask;
  473. masklist *b;
  474. if (!par[0])
  475. {
  476. dprintf (idx, "Usage: -ban <hostmask|ban #> [channel]\n");
  477. return;
  478. }
  479. ban = newsplit (&par);
  480. if (par[0] && strchr (CHANMETA, par[0]))
  481. chname = newsplit (&par);
  482. else
  483. {
  484. chname = dcc[idx].u.chat->con_chan;
  485. console = 1;
  486. }
  487. if (chname || !(u->flags & USER_MASTER))
  488. {
  489. if (!chname)
  490. chname = dcc[idx].u.chat->con_chan;
  491. get_user_flagrec (u, &user, chname);
  492. if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  493. {
  494. dprintf (idx, "You don't have access to remove bans on %s.\n",
  495. chname);
  496. return;
  497. }
  498. }
  499. strncpyz (s, ban, sizeof s);
  500. if (console)
  501. {
  502. i = u_delban (NULL, s, (u->flags & USER_MASTER));
  503. if (i > 0)
  504. {
  505. if (lastdeletedmask)
  506. mask = lastdeletedmask;
  507. else
  508. mask = s;
  509. putlog (LOG_CMDS, "*", "#%s# -ban %s", dcc[idx].nick, mask);
  510. dprintf (idx, "%s: %s\n", IRC_REMOVEDBAN, mask);
  511. for (chan = chanset; chan != NULL; chan = chan->next)
  512. add_mode (chan, '-', 'b', mask);
  513. return;
  514. }
  515. }
  516. if (chname)
  517. chan = findchan_by_dname (chname);
  518. if (!chan)
  519. {
  520. dprintf (idx, "Invalid channel.\n");
  521. return;
  522. }
  523. if ((i = atoi (ban)) > 0)
  524. {
  525. egg_snprintf (s, sizeof s, "%d", i);
  526. j = u_delban (chan, s, 1);
  527. if (j > 0)
  528. {
  529. if (lastdeletedmask)
  530. mask = lastdeletedmask;
  531. else
  532. mask = s;
  533. putlog (LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick,
  534. chan->dname, mask);
  535. dprintf (idx, "Removed %s channel ban: %s\n", chan->dname, mask);
  536. add_mode (chan, '-', 'b', mask);
  537. return;
  538. }
  539. i = 0;
  540. for (b = chan->channel.ban; b && b->mask && b->mask[0]; b = b->next)
  541. {
  542. if ((!u_equals_mask (global_bans, b->mask))
  543. && (!u_equals_mask (chan->bans, b->mask)))
  544. {
  545. i++;
  546. if (i == -j)
  547. {
  548. add_mode (chan, '-', 'b', b->mask);
  549. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDBAN, b->mask,
  550. chan->dname);
  551. putlog (LOG_CMDS, "*", "#%s# (%s) -ban %s [on channel]",
  552. dcc[idx].nick, dcc[idx].u.chat->con_chan, ban);
  553. return;
  554. }
  555. }
  556. }
  557. }
  558. else
  559. {
  560. j = u_delban (chan, ban, 1);
  561. if (j > 0)
  562. {
  563. putlog (LOG_CMDS, "*", "#%s# (%s) -ban %s", dcc[idx].nick,
  564. dcc[idx].u.chat->con_chan, ban);
  565. dprintf (idx, "Removed %s channel ban: %s\n", chname, ban);
  566. add_mode (chan, '-', 'b', ban);
  567. return;
  568. }
  569. for (b = chan->channel.ban; b && b->mask && b->mask[0]; b = b->next)
  570. {
  571. if (!rfc_casecmp (b->mask, ban))
  572. {
  573. add_mode (chan, '-', 'b', b->mask);
  574. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDBAN, b->mask,
  575. chan->dname);
  576. putlog (LOG_CMDS, "*", "#%s# (%s) -ban %s [on channel]",
  577. dcc[idx].nick, dcc[idx].u.chat->con_chan, ban);
  578. return;
  579. }
  580. }
  581. }
  582. dprintf (idx, "No such ban.\n");
  583. }
  584. #ifdef S_IRCNET
  585. static void
  586. cmd_mns_exempt (struct userrec *u, int idx, char *par)
  587. {
  588. int i = 0, j;
  589. struct chanset_t *chan = NULL;
  590. char s[UHOSTLEN], *exempt, *chname;
  591. masklist *e;
  592. if (!use_exempts)
  593. {
  594. dprintf (idx,
  595. "This command can only be used with use-exempts enabled.\n");
  596. return;
  597. }
  598. if (!par[0])
  599. {
  600. dprintf (idx, "Usage: -exempt <hostmask|exempt #> [channel]\n");
  601. return;
  602. }
  603. exempt = newsplit (&par);
  604. if (par[0] && strchr (CHANMETA, par[0]))
  605. chname = newsplit (&par);
  606. else
  607. chname = dcc[idx].u.chat->con_chan;
  608. if (chname || !(u->flags & USER_MASTER))
  609. {
  610. if (!chname)
  611. chname = dcc[idx].u.chat->con_chan;
  612. get_user_flagrec (u, &user, chname);
  613. if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  614. {
  615. dprintf (idx, "You don't have access to remove exempts on %s.\n",
  616. chname);
  617. return;
  618. }
  619. }
  620. strncpyz (s, exempt, sizeof s);
  621. i = u_delexempt (NULL, s, (u->flags & USER_MASTER));
  622. if (i > 0)
  623. {
  624. putlog (LOG_CMDS, "*", "#%s# -exempt %s", dcc[idx].nick, s);
  625. dprintf (idx, "%s: %s\n", IRC_REMOVEDEXEMPT, s);
  626. for (chan = chanset; chan != NULL; chan = chan->next)
  627. add_mode (chan, '-', 'e', s);
  628. return;
  629. }
  630. if (chname)
  631. chan = findchan_by_dname (chname);
  632. if (chan)
  633. {
  634. if (atoi (exempt) > 0)
  635. {
  636. egg_snprintf (s, sizeof s, "%d", -i);
  637. j = u_delexempt (chan, s, 1);
  638. if (j > 0)
  639. {
  640. putlog (LOG_CMDS, "*", "#%s# (%s) -exempt %s", dcc[idx].nick,
  641. chan->dname, s);
  642. dprintf (idx, "Removed %s channel exempt: %s\n", chan->dname,
  643. s);
  644. add_mode (chan, '-', 'e', s);
  645. return;
  646. }
  647. i = 0;
  648. for (e = chan->channel.exempt; e && e->mask && e->mask[0];
  649. e = e->next)
  650. {
  651. if (!u_equals_mask (global_exempts, e->mask)
  652. && !u_equals_mask (chan->exempts, e->mask))
  653. {
  654. i++;
  655. if (i == -j)
  656. {
  657. add_mode (chan, '-', 'e', e->mask);
  658. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDEXEMPT,
  659. e->mask, chan->dname);
  660. putlog (LOG_CMDS, "*",
  661. "#%s# (%s) -exempt %s [on channel]",
  662. dcc[idx].nick, dcc[idx].u.chat->con_chan,
  663. exempt);
  664. return;
  665. }
  666. }
  667. }
  668. }
  669. else
  670. {
  671. j = u_delexempt (chan, exempt, 1);
  672. if (j > 0)
  673. {
  674. putlog (LOG_CMDS, "*", "#%s# (%s) -exempt %s", dcc[idx].nick,
  675. dcc[idx].u.chat->con_chan, exempt);
  676. dprintf (idx, "Removed %s channel exempt: %s\n", chname,
  677. exempt);
  678. add_mode (chan, '-', 'e', exempt);
  679. return;
  680. }
  681. for (e = chan->channel.exempt; e && e->mask && e->mask[0];
  682. e = e->next)
  683. {
  684. if (!rfc_casecmp (e->mask, exempt))
  685. {
  686. add_mode (chan, '-', 'e', e->mask);
  687. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDEXEMPT,
  688. e->mask, chan->dname);
  689. putlog (LOG_CMDS, "*", "#%s# (%s) -exempt %s [on channel]",
  690. dcc[idx].nick, dcc[idx].u.chat->con_chan, exempt);
  691. return;
  692. }
  693. }
  694. }
  695. }
  696. dprintf (idx, "No such exemption.\n");
  697. }
  698. static void
  699. cmd_mns_invite (struct userrec *u, int idx, char *par)
  700. {
  701. int i = 0, j;
  702. struct chanset_t *chan = NULL;
  703. char s[UHOSTLEN], *invite, *chname;
  704. masklist *inv;
  705. if (!use_invites)
  706. {
  707. dprintf (idx,
  708. "This command can only be used with use-invites enabled.\n");
  709. return;
  710. }
  711. if (!par[0])
  712. {
  713. dprintf (idx, "Usage: -invite <hostmask|invite #> [channel]\n");
  714. return;
  715. }
  716. invite = newsplit (&par);
  717. if (par[0] && strchr (CHANMETA, par[0]))
  718. chname = newsplit (&par);
  719. else
  720. chname = dcc[idx].u.chat->con_chan;
  721. if (chname || !(u->flags & USER_MASTER))
  722. {
  723. if (!chname)
  724. chname = dcc[idx].u.chat->con_chan;
  725. get_user_flagrec (u, &user, chname);
  726. if (!((glob_op (user) && !chan_deop (user)) || chan_op (user)))
  727. {
  728. dprintf (idx, "You don't have access to remove invites on %s.\n",
  729. chname);
  730. return;
  731. }
  732. }
  733. strncpyz (s, invite, sizeof s);
  734. i = u_delinvite (NULL, s, (u->flags & USER_MASTER));
  735. if (i > 0)
  736. {
  737. putlog (LOG_CMDS, "*", "#%s# -invite %s", dcc[idx].nick, s);
  738. dprintf (idx, "%s: %s\n", IRC_REMOVEDINVITE, s);
  739. for (chan = chanset; chan != NULL; chan = chan->next)
  740. add_mode (chan, '-', 'I', s);
  741. return;
  742. }
  743. if (chname)
  744. chan = findchan_by_dname (chname);
  745. if (chan)
  746. {
  747. if (atoi (invite) > 0)
  748. {
  749. egg_snprintf (s, sizeof s, "%d", -i);
  750. j = u_delinvite (chan, s, 1);
  751. if (j > 0)
  752. {
  753. putlog (LOG_CMDS, "*", "#%s# (%s) -invite %s", dcc[idx].nick,
  754. chan->dname, s);
  755. dprintf (idx, "Removed %s channel invite: %s\n", chan->dname,
  756. s);
  757. add_mode (chan, '-', 'I', s);
  758. return;
  759. }
  760. i = 0;
  761. for (inv = chan->channel.invite; inv && inv->mask && inv->mask[0];
  762. inv = inv->next)
  763. {
  764. if (!u_equals_mask (global_invites, inv->mask)
  765. && !u_equals_mask (chan->invites, inv->mask))
  766. {
  767. i++;
  768. if (i == -j)
  769. {
  770. add_mode (chan, '-', 'I', inv->mask);
  771. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDINVITE,
  772. inv->mask, chan->dname);
  773. putlog (LOG_CMDS, "*",
  774. "#%s# (%s) -invite %s [on channel]",
  775. dcc[idx].nick, dcc[idx].u.chat->con_chan,
  776. invite);
  777. return;
  778. }
  779. }
  780. }
  781. }
  782. else
  783. {
  784. j = u_delinvite (chan, invite, 1);
  785. if (j > 0)
  786. {
  787. putlog (LOG_CMDS, "*", "#%s# (%s) -invite %s", dcc[idx].nick,
  788. dcc[idx].u.chat->con_chan, invite);
  789. dprintf (idx, "Removed %s channel invite: %s\n", chname,
  790. invite);
  791. add_mode (chan, '-', 'I', invite);
  792. return;
  793. }
  794. for (inv = chan->channel.invite; inv && inv->mask && inv->mask[0];
  795. inv = inv->next)
  796. {
  797. if (!rfc_casecmp (inv->mask, invite))
  798. {
  799. add_mode (chan, '-', 'I', inv->mask);
  800. dprintf (idx, "%s '%s' on %s.\n", IRC_REMOVEDINVITE,
  801. inv->mask, chan->dname);
  802. putlog (LOG_CMDS, "*", "#%s# (%s) -invite %s [on channel]",
  803. dcc[idx].nick, dcc[idx].u.chat->con_chan, invite);
  804. return;
  805. }
  806. }
  807. }
  808. }
  809. dprintf (idx, "No such invite.\n");
  810. }
  811. #endif
  812. static void
  813. cmd_bans (struct userrec *u, int idx, char *par)
  814. {
  815. if (!egg_strcasecmp (par, "all"))
  816. {
  817. putlog (LOG_CMDS, "*", "#%s# bans all", dcc[idx].nick);
  818. tell_bans (idx, 1, "");
  819. }
  820. else
  821. {
  822. putlog (LOG_CMDS, "*", "#%s# bans %s", dcc[idx].nick, par);
  823. tell_bans (idx, 0, par);
  824. }
  825. }
  826. #ifdef S_IRCNET
  827. static void
  828. cmd_exempts (struct userrec *u, int idx, char *par)
  829. {
  830. if (!use_exempts)
  831. {
  832. dprintf (idx,
  833. "This command can only be used with use-exempts enabled.\n");
  834. return;
  835. }
  836. if (!egg_strcasecmp (par, "all"))
  837. {
  838. putlog (LOG_CMDS, "*", "#%s# exempts all", dcc[idx].nick);
  839. tell_exempts (idx, 1, "");
  840. }
  841. else
  842. {
  843. putlog (LOG_CMDS, "*", "#%s# exempts %s", dcc[idx].nick, par);
  844. tell_exempts (idx, 0, par);
  845. }
  846. }
  847. static void
  848. cmd_invites (struct userrec *u, int idx, char *par)
  849. {
  850. if (!use_invites)
  851. {
  852. dprintf (idx,
  853. "This command can only be used with use-invites enabled.\n");
  854. return;
  855. }
  856. if (!egg_strcasecmp (par, "all"))
  857. {
  858. putlog (LOG_CMDS, "*", "#%s# invites all", dcc[idx].nick);
  859. tell_invites (idx, 1, "");
  860. }
  861. else
  862. {
  863. putlog (LOG_CMDS, "*", "#%s# invites %s", dcc[idx].nick, par);
  864. tell_invites (idx, 0, par);
  865. }
  866. }
  867. #endif
  868. static void
  869. cmd_info (struct userrec *u, int idx, char *par)
  870. {
  871. char s[512], *chname, *s1;
  872. int locked = 0;
  873. if (!use_info)
  874. {
  875. dprintf (idx, "Info storage is turned off.\n");
  876. return;
  877. }
  878. s1 = get_user (&USERENTRY_INFO, u);
  879. if (s1 && s1[0] == '@')
  880. locked = 1;
  881. if (par[0] && strchr (CHANMETA, par[0]))
  882. {
  883. chname = newsplit (&par);
  884. if (!findchan_by_dname (chname))
  885. {
  886. dprintf (idx, "No such channel.\n");
  887. return;
  888. }
  889. get_handle_chaninfo (dcc[idx].nick, chname, s);
  890. if (s[0] == '@')
  891. locked = 1;
  892. s1 = s;
  893. }
  894. else
  895. chname = 0;
  896. if (!par[0])
  897. {
  898. if (s1 && s1[0] == '@')
  899. s1++;
  900. if (s1 && s1[0])
  901. {
  902. if (chname)
  903. {
  904. dprintf (idx, "Info on %s: %s\n", chname, s1);
  905. dprintf (idx, "Use '.info %s none' to remove it.\n", chname);
  906. }
  907. else
  908. {
  909. dprintf (idx, "Default info: %s\n", s1);
  910. dprintf (idx, "Use '.info none' to remove it.\n");
  911. }
  912. }
  913. else
  914. dprintf (idx, "No info has been set for you.\n");
  915. putlog (LOG_CMDS, "*", "#%s# info %s", dcc[idx].nick,
  916. chname ? chname : "");
  917. return;
  918. }
  919. if (locked && !(u && (u->flags & USER_MASTER)))
  920. {
  921. dprintf (idx, "Your info line is locked. Sorry.\n");
  922. return;
  923. }
  924. if (!egg_strcasecmp (par, "none"))
  925. {
  926. if (chname)
  927. {
  928. par[0] = 0;
  929. set_handle_chaninfo (userlist, dcc[idx].nick, chname, NULL);
  930. dprintf (idx, "Removed your info line on %s.\n", chname);
  931. putlog (LOG_CMDS, "*", "#%s# info %s none", dcc[idx].nick, chname);
  932. }
  933. else
  934. {
  935. set_user (&USERENTRY_INFO, u, NULL);
  936. dprintf (idx, "Removed your default info line.\n");
  937. putlog (LOG_CMDS, "*", "#%s# info none", dcc[idx].nick);
  938. }
  939. return;
  940. }
  941. if (chname)
  942. {
  943. set_handle_chaninfo (userlist, dcc[idx].nick, chname, par);
  944. dprintf (idx, "Your info on %s is now: %s\n", chname, par);
  945. putlog (LOG_CMDS, "*", "#%s# info %s ...", dcc[idx].nick, chname);
  946. }
  947. else
  948. {
  949. set_user (&USERENTRY_INFO, u, par);
  950. dprintf (idx, "Your default info is now: %s\n", par);
  951. putlog (LOG_CMDS, "*", "#%s# info ...", dcc[idx].nick);
  952. }
  953. }
  954. static void
  955. cmd_chinfo (struct userrec *u, int idx, char *par)
  956. {
  957. char *handle, *chname;
  958. struct userrec *u1;
  959. if (!use_info)
  960. {
  961. dprintf (idx, "Info storage is turned off.\n");
  962. return;
  963. }
  964. handle = newsplit (&par);
  965. if (!handle[0])
  966. {
  967. dprintf (idx, "Usage: chinfo <handle> [channel] <new-info>\n");
  968. return;
  969. }
  970. u1 = get_user_by_handle (userlist, handle);
  971. if (!u1)
  972. {
  973. dprintf (idx, "No such user.\n");
  974. return;
  975. }
  976. if (par[0] && strchr (CHANMETA, par[0]))
  977. {
  978. chname = newsplit (&par);
  979. if (!findchan_by_dname (chname))
  980. {
  981. dprintf (idx, "No such channel.\n");
  982. return;
  983. }
  984. }
  985. else
  986. chname = 0;
  987. if ((u1->flags & USER_BOT) && !(u->flags & USER_MASTER))
  988. {
  989. dprintf (idx, "You have to be master to change bots info.\n");
  990. return;
  991. }
  992. if ((u1->flags & USER_OWNER) && !(u->flags & USER_OWNER))
  993. {
  994. dprintf (idx, "You can't change info for the bot owner.\n");
  995. return;
  996. }
  997. if (chname)
  998. {
  999. get_user_flagrec (u, &user, chname);
  1000. get_user_flagrec (u1, &victim, chname);
  1001. if ((chan_owner (victim) || glob_owner (victim))
  1002. && !(glob_owner (user) || chan_owner (user)))
  1003. {
  1004. dprintf (idx, "You can't change info for the channel owner.\n");
  1005. return;
  1006. }
  1007. }
  1008. putlog (LOG_CMDS, "*", "#%s# chinfo %s %s %s", dcc[idx].nick, handle,
  1009. chname ? chname : par, chname ? par : "");
  1010. if (!egg_strcasecmp (par, "none"))
  1011. par[0] = 0;
  1012. if (chname)
  1013. {
  1014. set_handle_chaninfo (userlist, handle, chname, par);
  1015. if (par[0] == '@')
  1016. dprintf (idx, "New info (LOCKED) for %s on %s: %s\n", handle, chname,
  1017. &par[1]);
  1018. else if (par[0])
  1019. dprintf (idx, "New info for %s on %s: %s\n", handle, chname, par);
  1020. else
  1021. dprintf (idx, "Wiped info for %s on %s\n", handle, chname);
  1022. }
  1023. else
  1024. {
  1025. set_user (&USERENTRY_INFO, u1, par[0] ? par : NULL);
  1026. if (par[0] == '@')
  1027. dprintf (idx, "New default info (LOCKED) for %s: %s\n", handle,
  1028. &par[1]);
  1029. else if (par[0])
  1030. dprintf (idx, "New default info for %s: %s\n", handle, par);
  1031. else
  1032. dprintf (idx, "Wiped default info for %s\n", handle);
  1033. }
  1034. }
  1035. static void
  1036. cmd_slowjoin (struct userrec *u, int idx, char *par)
  1037. {
  1038. int intvl = 0, delay = 0, count = 1;
  1039. char *chname;
  1040. char buf[2048], buf2[1048];
  1041. struct chanset_t *chan;
  1042. struct userrec *bot;
  1043. char *p;
  1044. putlog (LOG_CMDS, "*", "#%s# slowjoin %s", dcc[idx].nick, par);
  1045. chname = newsplit (&par);
  1046. p = newsplit (&par);
  1047. intvl = atoi (p);
  1048. if (!chname[0] || !p[0])
  1049. {
  1050. dprintf (idx,
  1051. "Usage: slowjoin channel interval-seconds [channel options]\n");
  1052. return;
  1053. }
  1054. if (intvl < 10)
  1055. {
  1056. dprintf (idx, "Interval must be at least 10 seconds\n");
  1057. return;
  1058. }
  1059. if ((chan = findchan_by_dname (chname)))
  1060. {
  1061. dprintf (idx, "Already on %s\n", chan->dname);
  1062. return;
  1063. }
  1064. if (!strchr (CHANMETA, chname[0]))
  1065. {
  1066. dprintf (idx, "Invalid channel name\n");
  1067. return;
  1068. }
  1069. strcpy (buf, "+inactive ");
  1070. if (par[0])
  1071. strncat (buf, par, sizeof (buf));
  1072. if (tcl_channel_add (0, chname, buf) == TCL_ERROR)
  1073. {
  1074. dprintf (idx, "Invalid channel.\n");
  1075. return;
  1076. }
  1077. chan = findchan_by_dname (chname);
  1078. if (!chan)
  1079. {
  1080. dprintf (idx, "Hmmm... Channel didn't get added. Weird *shrug*\n");
  1081. return;
  1082. }
  1083. sprintf (buf2, "cjoin %s %s", chan->dname, buf);
  1084. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1085. #ifdef HUB
  1086. count = 0;
  1087. #else
  1088. count = 1;
  1089. #endif
  1090. for (bot = userlist; bot; bot = bot->next)
  1091. {
  1092. if ((bot->flags & USER_BOT) && ((nextbot (bot->handle) >= 0)))
  1093. {
  1094. char tmp[100];
  1095. if (!(bot_flags (bot) & BOT_LEAF))
  1096. {
  1097. sprintf (tmp, "sj %s 0\n", chan->dname);
  1098. }
  1099. else
  1100. {
  1101. int v = (rand () % (intvl / 2)) - (intvl / 4);
  1102. delay += intvl;
  1103. sprintf (tmp, "sj %s %i\n", chan->dname, delay + v);
  1104. count++;
  1105. } botnet_send_zapf (nextbot (bot->handle), botnetnick,
  1106. bot->handle, tmp);
  1107. }
  1108. } dprintf (idx, "%i bots joining %s during the next %i seconds\n", count,
  1109. chan->dname, delay);
  1110. chan->status &= ~CHAN_INACTIVE;
  1111. #ifdef LEAF
  1112. dprintf (DP_MODE, "JOIN %s %s\n", chan->dname, chan->key_prot);
  1113. #endif
  1114. } static void
  1115. cmd_stick_yn (int idx, char *par, int yn)
  1116. {
  1117. int i = 0, j;
  1118. struct chanset_t *chan, *achan;
  1119. char *stick_type, s[UHOSTLEN], chname[81];
  1120. module_entry *me;
  1121. stick_type = newsplit (&par);
  1122. strncpyz (s, newsplit (&par), sizeof s);
  1123. strncpyz (chname, newsplit (&par), sizeof chname);
  1124. #ifdef S_IRCNET
  1125. if (egg_strcasecmp (stick_type, "exempt")
  1126. && egg_strcasecmp (stick_type, "invite")
  1127. && egg_strcasecmp (stick_type, "ban"))
  1128. {
  1129. #else
  1130. if (egg_strcasecmp (stick_type, "ban"))
  1131. {
  1132. #endif
  1133. strncpyz (chname, s, sizeof chname);
  1134. strncpyz (s, stick_type, sizeof s);
  1135. }
  1136. if (!s[0])
  1137. {
  1138. #ifdef S_IRCNET
  1139. dprintf (idx,
  1140. "Usage: %sstick [ban/exempt/invite] <hostmask or number> [channel]\n",
  1141. #else
  1142. dprintf (idx, "Usage: %sstick [ban] <hostmask or number> [channel]\n",
  1143. #endif
  1144. yn ? "" : "un");
  1145. return;
  1146. }
  1147. #ifdef S_IRCNET
  1148. if (!egg_strcasecmp (stick_type, "exempt"))
  1149. {
  1150. if (!use_exempts)
  1151. {
  1152. dprintf (idx,
  1153. "This command can only be used with use-exempts enabled.\n");
  1154. return;
  1155. }
  1156. if (!chname[0])
  1157. {
  1158. i =
  1159. u_setsticky_exempt (NULL, s,
  1160. (dcc[idx].user->
  1161. flags & USER_MASTER) ? yn : -1);
  1162. if (i > 0)
  1163. {
  1164. putlog (LOG_CMDS, "*", "#%s# %sstick exempt %s", dcc[idx].nick,
  1165. yn ? "" : "un", s);
  1166. dprintf (idx, "%stuck exempt: %s\n", yn ? "S" : "Uns", s);
  1167. return;
  1168. }
  1169. strncpyz (chname, dcc[idx].u.chat->con_chan, sizeof chname);
  1170. }
  1171. if (!(chan = findchan_by_dname (chname)))
  1172. {
  1173. dprintf (idx, "No such channel.\n");
  1174. return;
  1175. }
  1176. if (i)
  1177. egg_snprintf (s, sizeof s, "%d", -i);
  1178. j = u_setsticky_exempt (chan, s, yn);
  1179. if (j > 0)
  1180. {
  1181. putlog (LOG_CMDS, "*", "#%s# %sstick exempt %s %s", dcc[idx].nick,
  1182. yn ? "" : "un", s, chname);
  1183. dprintf (idx, "%stuck %s exempt: %s\n", yn ? "S" : "Uns", chname,
  1184. s);
  1185. return;
  1186. }
  1187. dprintf (idx, "No such exempt.\n");
  1188. return;
  1189. }
  1190. else if (!egg_strcasecmp (stick_type, "invite"))
  1191. {
  1192. if (!use_invites)
  1193. {
  1194. dprintf (idx,
  1195. "This command can only be used with use-invites enabled.\n");
  1196. return;
  1197. }
  1198. if (!chname[0])
  1199. {
  1200. i =
  1201. u_setsticky_invite (NULL, s,
  1202. (dcc[idx].user->
  1203. flags & USER_MASTER) ? yn : -1);
  1204. if (i > 0)
  1205. {
  1206. putlog (LOG_CMDS, "*", "#%s# %sstick invite %s", dcc[idx].nick,
  1207. yn ? "" : "un", s);
  1208. dprintf (idx, "%stuck invite: %s\n", yn ? "S" : "Uns", s);
  1209. return;
  1210. }
  1211. strncpyz (chname, dcc[idx].u.chat->con_chan, sizeof chname);
  1212. }
  1213. if (!(chan = findchan_by_dname (chname)))
  1214. {
  1215. dprintf (idx, "No such channel.\n");
  1216. return;
  1217. }
  1218. if (i)
  1219. egg_snprintf (s, sizeof s, "%d", -i);
  1220. j = u_setsticky_invite (chan, s, yn);
  1221. if (j > 0)
  1222. {
  1223. putlog (LOG_CMDS, "*", "#%s# %sstick invite %s %s", dcc[idx].nick,
  1224. yn ? "" : "un", s, chname);
  1225. dprintf (idx, "%stuck %s invite: %s\n", yn ? "S" : "Uns", chname,
  1226. s);
  1227. return;
  1228. }
  1229. dprintf (idx, "No such invite.\n");
  1230. return;
  1231. }
  1232. #endif
  1233. if (!chname[0])
  1234. {
  1235. i =
  1236. u_setsticky_ban (NULL, s,
  1237. (dcc[idx].user->flags & USER_MASTER) ? yn : -1);
  1238. if (i > 0)
  1239. {
  1240. putlog (LOG_CMDS, "*", "#%s# %sstick ban %s", dcc[idx].nick,
  1241. yn ? "" : "un", s);
  1242. dprintf (idx, "%stuck ban: %s\n", yn ? "S" : "Uns", s);
  1243. if ((me = module_find ("irc", 0, 0)))
  1244. for (achan = chanset; achan != NULL; achan = achan->next)
  1245. (me->funcs[IRC_CHECK_THIS_BAN]) (achan, s, yn);
  1246. return;
  1247. }
  1248. strncpyz (chname, dcc[idx].u.chat->con_chan, sizeof chname);
  1249. }
  1250. if (!(chan = findchan_by_dname (chname)))
  1251. {
  1252. dprintf (idx, "No such channel.\n");
  1253. return;
  1254. }
  1255. if (i)
  1256. egg_snprintf (s, sizeof s, "%d", -i);
  1257. j = u_setsticky_ban (chan, s, yn);
  1258. if (j > 0)
  1259. {
  1260. putlog (LOG_CMDS, "*", "#%s# %sstick ban %s %s", dcc[idx].nick,
  1261. yn ? "" : "un", s, chname);
  1262. dprintf (idx, "%stuck %s ban: %s\n", yn ? "S" : "Uns", chname, s);
  1263. if ((me = module_find ("irc", 0, 0)))
  1264. (me->funcs[IRC_CHECK_THIS_BAN]) (chan, s, yn);
  1265. return;
  1266. }
  1267. dprintf (idx, "No such ban.\n");
  1268. }
  1269. static void
  1270. cmd_stick (struct userrec *u, int idx, char *par)
  1271. {
  1272. cmd_stick_yn (idx, par, 1);
  1273. } static void
  1274. cmd_unstick (struct userrec *u, int idx, char *par)
  1275. {
  1276. cmd_stick_yn (idx, par, 0);
  1277. } static void
  1278. cmd_pls_chrec (struct userrec *u, int idx, char *par)
  1279. {
  1280. char *nick, *chn;
  1281. struct chanset_t *chan;
  1282. struct userrec *u1;
  1283. struct chanuserrec *chanrec;
  1284. if (!par[0])
  1285. {
  1286. dprintf (idx, "Usage: +chrec <user> [channel]\n");
  1287. return;
  1288. }
  1289. nick = newsplit (&par);
  1290. u1 = get_user_by_handle (userlist, nick);
  1291. if (!u1)
  1292. {
  1293. dprintf (idx, "No such user.\n");
  1294. return;
  1295. }
  1296. if (!par[0])
  1297. chan = findchan_by_dname (dcc[idx].u.chat->con_chan);
  1298. else
  1299. {
  1300. chn = newsplit (&par);
  1301. chan = findchan_by_dname (chn);
  1302. }
  1303. if (!chan)
  1304. {
  1305. dprintf (idx, "No such channel.\n");
  1306. return;
  1307. }
  1308. get_user_flagrec (u, &user, chan->dname);
  1309. get_user_flagrec (u1, &victim, chan->dname);
  1310. if ((!glob_master (user) && !chan_master (user))
  1311. || (chan_owner (victim) && !chan_owner (user) && !glob_owner (user))
  1312. || (glob_owner (victim) && !glob_owner (user)))
  1313. {
  1314. dprintf (idx, "You have no permission to do that.\n");
  1315. return;
  1316. }
  1317. chanrec = get_chanrec (u1, chan->dname);
  1318. if (chanrec)
  1319. {
  1320. dprintf (idx, "User %s already has a channel record for %s.\n", nick,
  1321. chan->dname);
  1322. return;
  1323. }
  1324. putlog (LOG_CMDS, "*", "#%s# +chrec %s %s", dcc[idx].nick, nick,
  1325. chan->dname);
  1326. add_chanrec (u1, chan->dname);
  1327. dprintf (idx, "Added %s channel record for %s.\n", chan->dname, nick);
  1328. }
  1329. static void
  1330. cmd_mns_chrec (struct userrec *u, int idx, char *par)
  1331. {
  1332. char *nick, *chn = NULL;
  1333. struct userrec *u1;
  1334. struct chanuserrec *chanrec;
  1335. if (!par[0])
  1336. {
  1337. dprintf (idx, "Usage: -chrec <user> [channel]\n");
  1338. return;
  1339. }
  1340. nick = newsplit (&par);
  1341. u1 = get_user_by_handle (userlist, nick);
  1342. if (!u1)
  1343. {
  1344. dprintf (idx, "No such user.\n");
  1345. return;
  1346. }
  1347. if (!par[0])
  1348. {
  1349. struct chanset_t *chan;
  1350. chan = findchan_by_dname (dcc[idx].u.chat->con_chan);
  1351. if (chan)
  1352. chn = chan->dname;
  1353. else
  1354. {
  1355. dprintf (idx, "Invalid console channel.\n");
  1356. return;
  1357. }
  1358. }
  1359. else
  1360. chn = newsplit (&par);
  1361. get_user_flagrec (u, &user, chn);
  1362. get_user_flagrec (u1, &victim, chn);
  1363. if ((!glob_master (user) && !chan_master (user))
  1364. || (chan_owner (victim) && !chan_owner (user) && !glob_owner (user))
  1365. || (glob_owner (victim) && !glob_owner (user)))
  1366. {
  1367. dprintf (idx, "You have no permission to do that.\n");
  1368. return;
  1369. }
  1370. chanrec = get_chanrec (u1, chn);
  1371. if (!chanrec)
  1372. {
  1373. dprintf (idx, "User %s doesn't have a channel record for %s.\n", nick,
  1374. chn);
  1375. return;
  1376. }
  1377. putlog (LOG_CMDS, "*", "#%s# -chrec %s %s", dcc[idx].nick, nick, chn);
  1378. del_chanrec (u1, chn);
  1379. dprintf (idx, "Removed %s channel record from %s.\n", chn, nick);
  1380. }
  1381. static void
  1382. cmd_cycle (struct userrec *u, int idx, char *par)
  1383. {
  1384. char *chname;
  1385. char buf2[1024];
  1386. putlog (LOG_CMDS, "*", "#%s# cycle %s", dcc[idx].nick, par);
  1387. if (!par[0])
  1388. {
  1389. dprintf (idx, "Usage: cycle [%s]<channel>\n", CHANMETA);
  1390. return;
  1391. }
  1392. chname = newsplit (&par);
  1393. if (!findchan_by_dname (chname))
  1394. {
  1395. dprintf (idx, "%s it not a valid channel.\n", chname);
  1396. return;
  1397. }
  1398. sprintf (buf2, "cycle %s", chname);
  1399. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1400. #ifdef LEAF
  1401. dprintf (DP_SERVER, "PART %s\n", chname);
  1402. #endif
  1403. }
  1404. static void
  1405. cmd_down (struct userrec *u, int idx, char *par)
  1406. {
  1407. char *chname;
  1408. char buf2[1024];
  1409. putlog (LOG_CMDS, "*", "#%s# down %s", dcc[idx].nick, par);
  1410. if (!par[0])
  1411. {
  1412. dprintf (idx, "Usage: down [%s]<channel>\n", CHANMETA);
  1413. return;
  1414. }
  1415. chname = newsplit (&par);
  1416. if (!findchan_by_dname (chname))
  1417. {
  1418. dprintf (idx, "%s it not a valid channel.\n", chname);
  1419. return;
  1420. }
  1421. sprintf (buf2, "down %s", chname);
  1422. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1423. #ifdef LEAF
  1424. add_mode (findchan_by_dname (chname), '-', 'o', botname);
  1425. #endif
  1426. }
  1427. static void
  1428. cmd_pls_chan (struct userrec *u, int idx, char *par)
  1429. {
  1430. char *chname;
  1431. char buf2[1024];
  1432. struct chanset_t *chan;
  1433. putlog (LOG_CMDS, "*", "#%s# +chan %s", dcc[idx].nick, par);
  1434. if (!par[0])
  1435. {
  1436. dprintf (idx, "Usage: +chan [%s]<channel> [options]\n", CHANMETA);
  1437. return;
  1438. }
  1439. chname = newsplit (&par);
  1440. sprintf (buf2, "cjoin %s %s", chname, par);
  1441. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1442. if (findchan_by_dname (chname))
  1443. {
  1444. dprintf (idx, "That channel already exists!\n");
  1445. return;
  1446. }
  1447. else if ((chan = findchan (chname)))
  1448. {
  1449. dprintf (idx, "That channel already exists as %s!\n", chan->dname);
  1450. return;
  1451. }
  1452. if (tcl_channel_add (0, chname, par) == TCL_ERROR)
  1453. dprintf (idx, "Invalid channel or channel options.\n");
  1454. else
  1455. {
  1456. #ifdef HUB
  1457. write_userfile (-1);
  1458. #endif
  1459. }
  1460. }
  1461. static void
  1462. cmd_mns_chan (struct userrec *u, int idx, char *par)
  1463. {
  1464. char *chname;
  1465. char buf2[1024];
  1466. struct chanset_t *chan;
  1467. int i;
  1468. putlog (LOG_CMDS, "*", "#%s# -chan %s", dcc[idx].nick, par);
  1469. if (!par[0])
  1470. {
  1471. dprintf (idx, "Usage: -chan [%s]<channel>\n", CHANMETA);
  1472. return;
  1473. }
  1474. chname = newsplit (&par);
  1475. sprintf (buf2, "cpart %s", chname);
  1476. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1477. chan = findchan_by_dname (chname);
  1478. if (!chan)
  1479. {
  1480. if ((chan = findchan (chname)))
  1481. dprintf (idx,
  1482. "That channel exists with a short name of %s, use that.\n",
  1483. chan->dname);
  1484. else
  1485. dprintf (idx, "That channel doesn't exist!\n");
  1486. return;
  1487. }
  1488. for (i = 0; i < dcc_total; i++)
  1489. if ((dcc[i].type->flags & DCT_CHAT)
  1490. && !rfc_casecmp (dcc[i].u.chat->con_chan, chan->dname))
  1491. {
  1492. dprintf (i,
  1493. "%s is no longer a valid channel, changing your console to '*'\n",
  1494. chname);
  1495. strcpy (dcc[i].u.chat->con_chan, "*");
  1496. }
  1497. remove_channel (chan);
  1498. #ifdef HUB
  1499. write_userfile (-1);
  1500. #endif
  1501. dprintf (idx, "Channel %s removed from the bot.\n", chname);
  1502. dprintf (idx,
  1503. "This includes any channel specific bans, invites, exemptions and user records that you set.\n");
  1504. }
  1505. static void
  1506. cmd_chaninfo (struct userrec *u, int idx, char *par)
  1507. {
  1508. char *chname, work[512];
  1509. struct chanset_t *chan;
  1510. int ii, tmp;
  1511. struct udef_struct *ul;
  1512. if (!par[0])
  1513. {
  1514. chname = dcc[idx].u.chat->con_chan;
  1515. if (chname[0] == '*')
  1516. {
  1517. dprintf (idx, "Your console channel is invalid.\n");
  1518. return;
  1519. }
  1520. }
  1521. else
  1522. {
  1523. chname = newsplit (&par);
  1524. get_user_flagrec (u, &user, chname);
  1525. if (!glob_master (user) && !chan_master (user))
  1526. {
  1527. dprintf (idx, "You don't have access to %s.\n", chname);
  1528. return;
  1529. }
  1530. }
  1531. if (!(chan = findchan_by_dname (chname)))
  1532. dprintf (idx, "No such channel defined.\n");
  1533. else
  1534. {
  1535. dprintf (idx, "Settings for %s channel %s:\n",
  1536. channel_static (chan) ? "static" : "dynamic", chan->dname);
  1537. get_mode_protect (chan, work);
  1538. dprintf (idx, "Protect modes (chanmode): %s\n",
  1539. work[0] ? work : "None");
  1540. dprintf (idx, "Protect topic: %s\n",
  1541. chan->topic_prot[0] ? chan->topic_prot : "None");
  1542. if (chan->idle_kick)
  1543. dprintf (idx, "Idle Kick after (idle-kick): %d\n", chan->idle_kick);
  1544. else
  1545. dprintf (idx, "Idle Kick after (idle-kick): DON'T!\n");
  1546. if (chan->limitraise)
  1547. dprintf (idx, "Limit raise: %d\n", chan->limitraise);
  1548. else
  1549. dprintf (idx, "Limit raise: disabled\n");
  1550. if (chan->stopnethack_mode)
  1551. dprintf (idx, "stopnethack-mode: %d\n", chan->stopnethack_mode);
  1552. else
  1553. dprintf (idx, "stopnethack: DON'T!\n");
  1554. if (chan->revenge_mode)
  1555. dprintf (idx, "revenge-mode: %d\n", chan->revenge_mode);
  1556. else
  1557. dprintf (idx, "revenge-mode: 0\n");
  1558. if (chan->ban_time)
  1559. dprintf (idx, "ban-time: %d\n", chan->ban_time);
  1560. else
  1561. dprintf (idx, "ban-time: 0\n");
  1562. #ifdef S_IRCNET
  1563. if (chan->exempt_time)
  1564. dprintf (idx, "exempt-time: %d\n", chan->exempt_time);
  1565. else
  1566. dprintf (idx, "exempt-time: 0\n");
  1567. if (chan->invite_time)
  1568. dprintf (idx, "invite-time: %d\n", chan->invite_time);
  1569. else
  1570. dprintf (idx, "invite-time: 0\n");
  1571. #endif
  1572. if (u->flags & USER_OWNER)
  1573. {
  1574. if (chan->need_op[0])
  1575. dprintf (idx, "To regain op's (need-op):\n%s\n", chan->need_op);
  1576. if (chan->need_invite[0])
  1577. dprintf (idx, "To get invite (need-invite):\n%s\n",
  1578. chan->need_invite);
  1579. if (chan->need_key[0])
  1580. dprintf (idx, "To get key (need-key):\n%s\n", chan->need_key);
  1581. if (chan->need_unban[0])
  1582. dprintf (idx, "If I'm banned (need-unban):\n%s\n",
  1583. chan->need_unban);
  1584. if (chan->need_limit[0])
  1585. dprintf (idx, "When channel full (need-limit):\n%s\n",
  1586. chan->need_limit);
  1587. }
  1588. dprintf (idx, "Other modes:\n");
  1589. dprintf (idx,
  1590. " %cinactive %cprivate %ccycle %cdontkickops\n",
  1591. (chan->status & CHAN_INACTIVE) ? '+' : '-',
  1592. (chan->status & CHAN_PRIVATE) ? '+' : '-',
  1593. (chan->status & CHAN_CYCLE) ? '+' : '-',
  1594. (chan->status & CHAN_DONTKICKOPS) ? '+' : '-');
  1595. dprintf (idx,
  1596. " %cprotectops %cprotectfriends %crevenge %crevengebot\n",
  1597. (chan->status & CHAN_PROTECTOPS) ? '+' : '-',
  1598. (chan->status & CHAN_PROTECTFRIENDS) ? '+' : '-',
  1599. (chan->status & CHAN_REVENGE) ? '+' : '-',
  1600. (chan->status & CHAN_REVENGEBOT) ? '+' : '-');
  1601. dprintf (idx, " %cbitch %cnodesynch\n",
  1602. (chan->status & CHAN_BITCH) ? '+' : '-',
  1603. (chan->status & CHAN_NODESYNCH) ? '+' : '-');
  1604. dprintf (idx, " %cenforcebans %cdynamicbans %cuserbans\n",
  1605. (chan->status & CHAN_ENFORCEBANS) ? '+' : '-',
  1606. (chan->status & CHAN_DYNAMICBANS) ? '+' : '-',
  1607. (chan->status & CHAN_NOUSERBANS) ? '-' : '+');
  1608. #ifdef S_IRCNET
  1609. dprintf (idx,
  1610. " %cdynamicexempts %cuserexempts %cdynamicinvites %cuserinvites\n",
  1611. (chan->ircnet_status & CHAN_DYNAMICEXEMPTS) ? '+' : '-',
  1612. (chan->ircnet_status & CHAN_NOUSEREXEMPTS) ? '-' : '+',
  1613. (chan->ircnet_status & CHAN_DYNAMICINVITES) ? '+' : '-',
  1614. (chan->ircnet_status & CHAN_NOUSERINVITES) ? '-' : '+');
  1615. #endif
  1616. dprintf (idx,
  1617. " %cclosed %ctake %cnomop %cmanop\n",
  1618. (chan->status & CHAN_CLOSED) ? '+' : '-',
  1619. (chan->status & CHAN_TAKE) ? '+' : '-',
  1620. (chan->status & CHAN_NOMOP) ? '+' : '-',
  1621. (chan->status & CHAN_MANOP) ? '+' : '-');
  1622. dprintf (idx, " %cvoice %cfastop\n",
  1623. (chan->status & CHAN_VOICE) ? '+' : '-',
  1624. (chan->status & CHAN_FASTOP) ? '+' : '-');
  1625. ii = 1;
  1626. tmp = 0;
  1627. for (ul = udef; ul; ul = ul->next)
  1628. if (ul->defined && ul->type == UDEF_FLAG)
  1629. {
  1630. int work_len;
  1631. if (!tmp)
  1632. {
  1633. dprintf (idx, "User defined channel flags:\n");
  1634. tmp = 1;
  1635. }
  1636. if (ii == 1)
  1637. egg_snprintf (work, sizeof work, " ");
  1638. work_len = strlen (work);
  1639. egg_snprintf (work + work_len, sizeof (work) - work_len, " %c%s",
  1640. getudef (ul->values, chan->dname) ? '+' : '-',
  1641. ul->name);
  1642. ii++;
  1643. if (ii > 4)
  1644. {
  1645. dprintf (idx, "%s\n", work);
  1646. ii = 1;
  1647. }
  1648. }
  1649. if (ii > 1)
  1650. dprintf (idx, "%s\n", work);
  1651. work[0] = 0;
  1652. ii = 1;
  1653. tmp = 0;
  1654. for (ul = udef; ul; ul = ul->next)
  1655. if (ul->defined && ul->type == UDEF_INT)
  1656. {
  1657. int work_len = strlen (work);
  1658. if (!tmp)
  1659. {
  1660. dprintf (idx, "User defined channel settings:\n");
  1661. tmp = 1;
  1662. }
  1663. egg_snprintf (work + work_len, sizeof (work) - work_len,
  1664. "%s: %d ", ul->name, getudef (ul->values,
  1665. chan->dname));
  1666. ii++;
  1667. if (ii > 4)
  1668. {
  1669. dprintf (idx, "%s\n", work);
  1670. work[0] = 0;
  1671. ii = 1;
  1672. }
  1673. }
  1674. if (ii > 1)
  1675. dprintf (idx, "%s\n", work);
  1676. dprintf (idx, "flood settings: chan ctcp join kick deop nick\n");
  1677. dprintf (idx, "number: %3d %3d %3d %3d %3d %3d\n",
  1678. chan->flood_pub_thr, chan->flood_ctcp_thr,
  1679. chan->flood_join_thr, chan->flood_kick_thr,
  1680. chan->flood_deop_thr, chan->flood_nick_thr);
  1681. dprintf (idx, "time : %3d %3d %3d %3d %3d %3d\n",
  1682. chan->flood_pub_time, chan->flood_ctcp_time,
  1683. chan->flood_join_time, chan->flood_kick_time,
  1684. chan->flood_deop_time, chan->flood_nick_time);
  1685. putlog (LOG_CMDS, "*", "#%s# chaninfo %s", dcc[idx].nick, chname);
  1686. }
  1687. }
  1688. static void
  1689. cmd_chanset (struct userrec *u, int idx, char *par)
  1690. {
  1691. char *chname = NULL, answers[512], *parcpy;
  1692. char *list[2], *bak, *buf, buf2[1024];
  1693. struct chanset_t *chan = NULL;
  1694. int all = 0, items = 0;
  1695. putlog (LOG_CMDS, "*", "#%s# chanset %s", dcc[idx].nick, par);
  1696. if (!par[0])
  1697. dprintf (idx, "Usage: chanset [%schannel] <settings>\n", CHANMETA);
  1698. else
  1699. {
  1700. if (strlen (par) > 2 && par[0] == '*' && par[1] == ' ')
  1701. {
  1702. dprintf (idx,
  1703. "currently chanset * does not work. use %stcl foreach chan [channels] { channel set $chan +mode }\n",
  1704. dcc_prefix);
  1705. return;
  1706. all = 1;
  1707. get_user_flagrec (u, &user, chanset ? chanset->dname : "");
  1708. if (!glob_master (user))
  1709. {
  1710. dprintf (idx,
  1711. "You need to be a global master to use %schanset *.\n",
  1712. dcc_prefix);
  1713. return;
  1714. }
  1715. newsplit (&par);
  1716. }
  1717. else
  1718. {
  1719. if (strchr (CHANMETA, par[0]))
  1720. {
  1721. chname = newsplit (&par);
  1722. get_user_flagrec (u, &user, chname);
  1723. if (!glob_master (user) && !chan_master (user))
  1724. {
  1725. dprintf (idx, "You don't have access to %s. \n", chname);
  1726. return;
  1727. }
  1728. else if (!(chan = findchan_by_dname (chname))
  1729. && (chname[0] != '+'))
  1730. {
  1731. dprintf (idx, "That channel doesn't exist!\n");
  1732. return;
  1733. }
  1734. if (!chan)
  1735. {
  1736. if (par[0])
  1737. *--par = ' ';
  1738. par = chname;
  1739. }
  1740. }
  1741. if (!par[0] || par[0] == '*')
  1742. {
  1743. dprintf (idx, "Usage: chanset [%schannel] <settings>\n",
  1744. CHANMETA);
  1745. return;
  1746. }
  1747. if (!chan
  1748. && !(chan =
  1749. findchan_by_dname (chname = dcc[idx].u.chat->con_chan)))
  1750. {
  1751. dprintf (idx, "Invalid console channel.\n");
  1752. return;
  1753. }
  1754. }
  1755. if (all)
  1756. chan = chanset;
  1757. bak = par;
  1758. buf = nmalloc (strlen (par) + 1);
  1759. while (chan)
  1760. {
  1761. chname = chan->dname;
  1762. strcpy (buf, bak);
  1763. par = buf;
  1764. list[0] = newsplit (&par);
  1765. answers[0] = 0;
  1766. while (list[0][0])
  1767. {
  1768. if (list[0][0] == '+' || list[0][0] == '-'
  1769. || (!strcmp (list[0], "dont-idle-kick")))
  1770. {
  1771. if (tcl_channel_modify (0, chan, 1, list) == TCL_OK)
  1772. {
  1773. strcat (answers, list[0]);
  1774. strcat (answers, " ");
  1775. items++;
  1776. }
  1777. else if (!all || !chan->next)
  1778. dprintf (idx,
  1779. "Error trying to set %s for %s, invalid mode.\n",
  1780. list[0], all ? "all channels" : chname);
  1781. list[0] = newsplit (&par);
  1782. continue;
  1783. }
  1784. if (strncmp (list[0], "need-", 5) || (u->flags & USER_OWNER))
  1785. {
  1786. if (!strncmp (list[0], "need-", 5)
  1787. && !(isowner (dcc[idx].nick)) && must_be_owner)
  1788. {
  1789. dprintf (idx,
  1790. "Due to security concerns, only permanent owners can set these modes.\n");
  1791. nfree (buf);
  1792. return;
  1793. }
  1794. list[1] = par;
  1795. parcpy = nmalloc (strlen (par) + 1);
  1796. strcpy (parcpy, par);
  1797. if (tcl_channel_modify (0, chan, 2, list) == TCL_OK)
  1798. {
  1799. strcat (answers, list[0]);
  1800. strcat (answers, " { ");
  1801. strcat (answers, parcpy);
  1802. strcat (answers, " }");
  1803. }
  1804. else if (!all || !chan->next)
  1805. dprintf (idx,
  1806. "Error trying to set %s for %s, invalid option\n",
  1807. list[0], all ? "all channels" : chname);
  1808. nfree (parcpy);
  1809. }
  1810. break;
  1811. }
  1812. if (!all && answers[0])
  1813. {
  1814. sprintf (buf2, "cset %s %s", chname, bak);
  1815. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1816. dprintf (idx, "Successfully set modes { %s } on %s.\n", answers,
  1817. chname);
  1818. #ifdef HUB
  1819. write_userfile (-1);
  1820. #endif
  1821. }
  1822. if (!all)
  1823. chan = NULL;
  1824. else
  1825. chan = chan->next;
  1826. }
  1827. if (all && answers[0])
  1828. {
  1829. sprintf (buf2, "cset * %s", bak);
  1830. botnet_send_zapf_broad (-1, botnetnick, NULL, buf2);
  1831. dprintf (idx, "Successfully set modes { %s } on all channels.\n",
  1832. answers);
  1833. #ifdef HUB
  1834. write_userfile (-1);
  1835. #endif
  1836. }
  1837. nfree (buf);
  1838. }
  1839. }
  1840. static dcc_cmd_t C_dcc_irc[] =
  1841. { {"+ban", "o|o", (Function) cmd_pls_ban, NULL, NULL},
  1842. #ifdef S_IRCNET
  1843. {"+exempt", "o|o", (Function) cmd_pls_exempt, NULL, NULL}, {"+invite", "o|o",
  1844. (Function)
  1845. cmd_pls_invite,
  1846. NULL, NULL},
  1847. #endif
  1848. {"+chan", "n", (Function) cmd_pls_chan, NULL, NULL}, {"+chrec", "m|m",
  1849. (Function)
  1850. cmd_pls_chrec, NULL,
  1851. NULL}, {"-ban", "o|o",
  1852. (Function)
  1853. cmd_mns_ban,
  1854. NULL, NULL},
  1855. {"-chan", "n", (Function) cmd_mns_chan, NULL, NULL}, {"-chrec", "m|m",
  1856. (Function)
  1857. cmd_mns_chrec, NULL,
  1858. NULL},
  1859. #ifdef S_IRCNET
  1860. {"-exempt", "o|o", (Function) cmd_mns_exempt, NULL, NULL}, {"-invite", "o|o",
  1861. (Function)
  1862. cmd_mns_invite,
  1863. NULL, NULL},
  1864. #endif
  1865. {"bans", "o|o", (Function) cmd_bans, NULL, NULL},
  1866. #ifdef S_IRCNET
  1867. {"exempts", "o|o", (Function) cmd_exempts, NULL, NULL}, {"invites", "o|o",
  1868. (Function)
  1869. cmd_invites, NULL,
  1870. NULL},
  1871. #endif
  1872. {"chaninfo", "m|m", (Function) cmd_chaninfo, NULL, NULL}, {"chanset", "m|m",
  1873. (Function)
  1874. cmd_chanset, NULL,
  1875. NULL}, {"chinfo",
  1876. "m|m",
  1877. (Function)
  1878. cmd_chinfo,
  1879. NULL,
  1880. NULL},
  1881. {"cycle", "n|n", (Function) cmd_cycle, NULL, NULL}, {"down", "n|n",
  1882. (Function) cmd_down,
  1883. NULL, NULL}, {"info",
  1884. "",
  1885. (Function)
  1886. cmd_info,
  1887. NULL,
  1888. NULL},
  1889. {"slowjoin", "n", (Function) cmd_slowjoin, NULL, NULL}, {"stick", "o|o",
  1890. (Function)
  1891. cmd_stick, NULL,
  1892. NULL}, {"unstick",
  1893. "o|o",
  1894. (Function)
  1895. cmd_unstick,
  1896. NULL,
  1897. NULL},
  1898. {NULL, NULL, NULL, NULL, NULL}
  1899. };