plexus2.c

Go to the documentation of this file.
00001 /* PlexusIRCD IRCD functions
00002  *
00003  * (C) 2003-2013 Anope Team
00004  * Contact us at team@anope.org
00005  *
00006  * Please read COPYING and README for further details.
00007  *
00008  * Based on the original code of Epona by Lara.
00009  * Based on the original code of Services by Andy Church.
00010  */
00011 
00012 #include "services.h"
00013 #include "pseudo.h"
00014 #include "plexus2.h"
00015 #include "version.h"
00016 
00017 IRCDVar myIrcd[] = {
00018   {"PleXusIRCd 2.0+",           /* ircd name */
00019    "+oiSR",                     /* nickserv mode */
00020    "+oiSR",                     /* chanserv mode */
00021    "+oiSR",                     /* memoserv mode */
00022    "+oiSR",                     /* hostserv mode */
00023    "+oaiSR",                    /* operserv mode */
00024    "+oiSR",                     /* botserv mode  */
00025    "+oiSR",                     /* helpserv mode */
00026    "+oiSR",                     /* Dev/Null mode */
00027    "+oiSR",                     /* Global mode   */
00028    "+oiSR",                     /* nickserv alias mode */
00029    "+oiSR",                     /* chanserv alias mode */
00030    "+oiSR",                     /* memoserv alias mode */
00031    "+oiSR",                     /* hostserv alias mode */
00032    "+oaiSR",                    /* operserv alias mode */
00033    "+oiSR",                     /* botserv alias mode  */
00034    "+oiSR",                     /* helpserv alias mode */
00035    "+oiSR",                     /* Dev/Null alias mode */
00036    "+oiSR",                     /* Global alias mode   */
00037    "+iSR",                      /* Used by BotServ Bots */
00038    3,                           /* Chan Max Symbols     */
00039    "-acilmnpstMNORZ",           /* Modes to Remove */
00040    "+o",                        /* Channel Umode used by Botserv bots */
00041    1,                           /* SVSNICK */
00042    1,                           /* Vhost  */
00043    0,                           /* Has Owner */
00044    NULL,                        /* Mode to set for an owner */
00045    NULL,                        /* Mode to unset for an owner */
00046    NULL,                        /* Mode to set for chan admin */
00047    NULL,                        /* Mode to unset for chan admin */
00048    "+R",                        /* Mode On Reg          */
00049      NULL,                      /* Mode on ID for Roots */
00050      NULL,                      /* Mode on ID for Admins */
00051      NULL,                      /* Mode on ID for Opers */
00052    "-R",                        /* Mode on UnReg        */
00053    "-R",                        /* Mode on Nick Change  */
00054    1,                           /* Supports SGlines     */
00055    1,                           /* Supports SQlines     */
00056    0,                           /* Supports SZlines     */
00057    1,                           /* Supports Halfop +h   */
00058    3,                           /* Number of server args */
00059    0,                           /* Join 2 Set           */
00060    0,                           /* Join 2 Message       */
00061    1,                           /* Has exceptions +e    */
00062    0,                           /* TS Topic Forward     */
00063    0,                           /* TS Topci Backward    */
00064    0,                           /* Protected Umode      */
00065    0,                           /* Has Admin            */
00066    1,                           /* Chan SQlines         */
00067    0,                           /* Quit on Kill         */
00068    0,                           /* SVSMODE unban        */
00069    0,                           /* Has Protect          */
00070    0,                           /* Reverse              */
00071    0,                           /* Chan Reg             */
00072    0,                           /* Channel Mode         */
00073    0,                           /* vidents              */
00074    0,                           /* svshold              */
00075    1,                           /* time stamp on mode   */
00076    0,                           /* NICKIP               */
00077    0,                           /* O:LINE               */
00078    1,                           /* UMODE                */
00079    1,                           /* VHOST ON NICK        */
00080    0,                           /* Change RealName      */
00081    CMODE_p,                     /* No Knock             */
00082    0,                           /* Admin Only           */
00083    DEFAULT_MLOCK,               /* Default MLOCK        */
00084    UMODE_h,                     /* Vhost Mode           */
00085    0,                           /* +f                   */
00086    0,                           /* +L                   */
00087    0,                           /* +f Mode                          */
00088    0,                           /* +L Mode                              */
00089    0,                           /* On nick change check if they could be identified */
00090    0,                           /* No Knock requires +i */
00091    NULL,                        /* CAPAB Chan Modes             */
00092    0,                           /* We support TOKENS */
00093    1,                           /* TOKENS are CASE inSensitive */
00094    0,                           /* TIME STAMPS are BASE64 */
00095    1,                           /* +I support */
00096    0,                           /* SJOIN ban char */
00097    0,                           /* SJOIN except char */
00098    0,                           /* SJOIN invite char */
00099    0,                           /* Can remove User Channel Modes with SVSMODE */
00100    0,                           /* Sglines are not enforced until user reconnects */
00101    "h",                         /* vhost char */
00102    0,                           /* ts6 */
00103    0,                           /* support helper umode */
00104    0,                           /* p10 */
00105    NULL,                        /* character set */
00106    1,                           /* reports sync state */
00107    0,               /* CIDR channelbans */
00108    0,               /* +j */
00109    0,               /* +j mode */
00110    0,                         /* Use delayed client introduction. */
00111    }
00112   ,
00113   {NULL}
00114 };
00115 
00116 IRCDCAPAB myIrcdcap[] = {
00117   {
00118    0,                           /* NOQUIT       */
00119    0,                           /* TSMODE       */
00120    0,                           /* UNCONNECT    */
00121    0,                           /* NICKIP       */
00122    0,                           /* SJOIN        */
00123    CAPAB_ZIP,                   /* ZIP          */
00124    0,                           /* BURST        */
00125    CAPAB_TS5,                   /* TS5          */
00126    0,                           /* TS3          */
00127    0,                           /* DKEY         */
00128    0,                           /* PT4          */
00129    0,                           /* SCS          */
00130    CAPAB_QS,                    /* QS           */
00131    CAPAB_UID,                   /* UID          */
00132    CAPAB_KNOCK,                 /* KNOCK        */
00133    0,                           /* CLIENT       */
00134    0,                           /* IPV6         */
00135    0,                           /* SSJ5         */
00136    0,                           /* SN2          */
00137    0,                           /* TOKEN        */
00138    0,                           /* VHOST        */
00139    0,                           /* SSJ3         */
00140    0,                           /* NICK2        */
00141    0,                           /* UMODE2       */
00142    0,                           /* VL           */
00143    0,                           /* TLKEXT       */
00144    0,                           /* DODKEY       */
00145    0,                           /* DOZIP        */
00146    0, 0, 0}
00147 };
00148 
00149 
00150 
00151 void
00152 plexus_set_umode (User * user, int ac, char **av)
00153 {
00154   int add = 1;                  /* 1 if adding modes, 0 if deleting */
00155   char *modes = av[0];
00156 
00157   ac--;
00158 
00159   if (debug)
00160     alog ("debug: Changing mode for %s to %s", user->nick, modes);
00161 
00162   while (*modes)
00163     {
00164 
00165       /* This looks better, much better than "add ? (do_add) : (do_remove)".
00166        * At least this is readable without paying much attention :) -GD
00167        */
00168       if (add)
00169         user->mode |= umodes[(int) *modes];
00170       else
00171         user->mode &= ~umodes[(int) *modes];
00172 
00173       switch (*modes++)
00174         {
00175         case '+':
00176           add = 1;
00177           break;
00178         case '-':
00179           add = 0;
00180           break;
00181         case 'h':
00182           update_host (user);
00183           break;
00184         case 'o':
00185           if (add)
00186             {
00187               opcnt++;
00188 
00189               if (WallOper)
00190                 anope_cmd_global (s_OperServ,
00191                                   "\2%s\2 is now an IRC operator.",
00192                                   user->nick);
00193               display_news (user, NEWS_OPER);
00194 
00195             }
00196           else
00197             {
00198               opcnt--;
00199             }
00200           break;
00201         case 'R':
00202           if (add && !nick_identified (user))
00203             {
00204               common_svsmode (user, "-R", NULL);
00205               user->mode &= ~UMODE_R;
00206             }
00207           break;
00208 
00209         }
00210     }
00211 }
00212 
00213 /*  
00214  * Local valid_op, and valid_halfop overrides.
00215  * These are nessecary due to the way hybrid-based ircds handle halfops.
00216  * hybrid-based ircds treat a -o as a -h as well. So if a user is set -o,
00217  * the ircd will also set them -h if they have that mode. This breaks
00218  * is_valid_op, as it always sends a -o. Breaking up the routines corrects this problem. - ThaPrince
00219  */
00220 
00221 int
00222 plexus_check_valid_halfop (User * user, Channel * chan, int servermode)
00223 {
00224   if (!chan || !chan->ci)
00225     return 1;
00226 
00227   /* They will be kicked; no need to deop, no need to update our internal struct too */
00228   if (chan->ci->flags & CI_VERBOTEN)
00229     return 0;
00230 
00231   if (servermode && !check_access (user, chan->ci, CA_AUTOHALFOP))
00232     {
00233       notice_lang (s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ);
00234       anope_cmd_mode (whosends (chan->ci), chan->name, "-h %s", user->nick);
00235       return 0;
00236     }
00237 
00238   if (check_access (user, chan->ci, CA_AUTODEOP))
00239     {
00240       anope_cmd_mode (whosends (chan->ci), chan->name, "-h %s", user->nick);
00241       return 0;
00242     }
00243 
00244   return 1;
00245 }
00246 
00247 int
00248 plexus_check_valid_op (User * user, Channel * chan, int servermode)
00249 {
00250   if (!chan || !chan->ci)
00251     return 1;
00252 
00253   /* They will be kicked; no need to deop, no need to update our internal struct too */
00254   if (chan->ci->flags & CI_VERBOTEN)
00255     return 0;
00256 
00257   if (servermode && !check_access (user, chan->ci, CA_AUTOOP))
00258     {
00259       notice_lang (s_ChanServ, user, CHAN_IS_REGISTERED, s_ChanServ);
00260       if (check_access (user, chan->ci, CA_AUTOHALFOP))
00261         {
00262           anope_cmd_mode (whosends (chan->ci), chan->name,
00263                           "-o+h %s %s", user->nick, user->nick);
00264         }
00265       else
00266         {
00267           anope_cmd_mode (whosends (chan->ci), chan->name, "-o %s",
00268                           user->nick);
00269         }
00270       return 0;
00271     }
00272 
00273   if (check_access (user, chan->ci, CA_AUTODEOP))
00274     {
00275       anope_cmd_mode (whosends (chan->ci), chan->name, "-o %s", user->nick);
00276       return 0;
00277     }
00278 
00279   return 1;
00280 }
00281 
00282 unsigned long umodes[128] = {
00283   0, 0, 0,                      /* Unused */
00284   0, 0, 0,                      /* Unused */
00285   0, 0, 0,                      /* Unused, Unused, Horzontal Tab */
00286   0, 0, 0,                      /* Line Feed, Unused, Unused */
00287   0, 0, 0,                      /* Carriage Return, Unused, Unused */
00288   0, 0, 0,                      /* Unused */
00289   0, 0, 0,                      /* Unused */
00290   0, 0, 0,                      /* Unused */
00291   0, 0, 0,                      /* Unused */
00292   0, 0, 0,                      /* Unused */
00293   0, 0, 0,                      /* Unused, Unused, Space */
00294   0, 0, 0,                      /* ! " #  */
00295   0, 0, 0,                      /* $ % &  */
00296   0, 0, 0,                      /* ! ( )  */
00297   0, 0, 0,                      /* * + ,  */
00298   0, 0, 0,                      /* - . /  */
00299   0, 0,                         /* 0 1 */
00300   0, 0,                         /* 2 3 */
00301   0, 0,                         /* 4 5 */
00302   0, 0,                         /* 6 7 */
00303   0, 0,                         /* 8 9 */
00304   0, 0,                         /* : ; */
00305   0, 0, 0,                      /* < = > */
00306   0, 0,                         /* ? @ */
00307   0, 0, 0,                      /* A B C */
00308   0, 0, 0,                      /* D E F */
00309   0, 0, 0,                      /* G H I */
00310   0, 0, 0,                      /* J K L */
00311   0, 0, 0,                      /* M N O */
00312   0, 0, UMODE_R,                /* P Q R */
00313   UMODE_S, 0, 0,                /* S T U */
00314   0, 0, 0,                      /* V W X */
00315   0,                            /* Y */
00316   0,                            /* Z */
00317   0, 0, 0,                      /* [ \ ] */
00318   0, 0, 0,                      /* ^ _ ` */
00319   UMODE_a, UMODE_b, 0,          /* a b c */
00320   UMODE_d, 0, 0,                /* d e f */
00321   0, UMODE_h, UMODE_i,          /* g h i */
00322   0, 0, UMODE_l,                /* j k l */
00323   UMODE_g, UMODE_n, UMODE_o,    /* m n o */
00324   0, 0, 0,                      /* p q r */
00325   0, 0, UMODE_u,                /* s t u */
00326   0, UMODE_w, UMODE_x,          /* v w x */
00327   0,                            /* y */
00328   0,                            /* z */
00329   0, 0, 0,                      /* { | } */
00330   0, 0                          /* ~ � */
00331 };
00332 
00333 
00334 char myCsmodes[128] = {
00335   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00336   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00337 
00338   0,
00339   0,
00340   0, 0, 0,
00341   'h',
00342   0, 0, 0, 0,
00343   0,
00344 
00345   'v', 0, 0, 0, 0,
00346   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00347 
00348   'o', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00349   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00350 
00351   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00352   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
00353 };
00354 
00355 CMMode myCmmodes[128] = {
00356   {NULL}, {NULL}, {NULL},
00357   {NULL}, {NULL}, {NULL},
00358   {NULL}, {NULL}, {NULL},
00359   {NULL}, {NULL}, {NULL},
00360   {NULL}, {NULL}, {NULL},
00361   {NULL}, {NULL}, {NULL},
00362   {NULL}, {NULL}, {NULL},
00363   {NULL}, {NULL}, {NULL},
00364   {NULL}, {NULL}, {NULL},
00365   {NULL}, {NULL}, {NULL},
00366   {NULL}, {NULL}, {NULL},
00367   {NULL}, {NULL}, {NULL},
00368   {NULL}, {NULL}, {NULL},
00369   {NULL}, {NULL}, {NULL},
00370   {NULL}, {NULL}, {NULL},
00371   {NULL}, {NULL}, {NULL},
00372   {NULL}, {NULL}, {NULL},
00373   {NULL}, {NULL}, {NULL},
00374   {NULL}, {NULL}, {NULL},
00375   {NULL}, {NULL}, {NULL},
00376   {NULL}, {NULL}, {NULL},
00377   {NULL}, {NULL}, {NULL},
00378   {NULL}, {NULL}, {NULL},       /* BCD */
00379   {NULL}, {NULL}, {NULL},       /* EFG */
00380   {NULL},                       /* H */
00381   {add_invite, del_invite},
00382   {NULL},                       /* J */
00383   {NULL}, {NULL}, {NULL},       /* KLM */
00384   {NULL}, {NULL}, {NULL},       /* NOP */
00385   {NULL}, {NULL}, {NULL},       /* QRS */
00386   {NULL}, {NULL}, {NULL},       /* TUV */
00387   {NULL}, {NULL}, {NULL},       /* WXY */
00388   {NULL},                       /* Z */
00389   {NULL}, {NULL},               /* (char 91 - 92) */
00390   {NULL}, {NULL}, {NULL},       /* (char 93 - 95) */
00391   {NULL},                       /* ` (char 96) */
00392   {NULL},                       /* a (char 97) */
00393   {add_ban, del_ban},
00394   {NULL},
00395   {NULL},
00396   {add_exception, del_exception},
00397   {NULL},
00398   {NULL},
00399   {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00400   {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL},
00401   {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}
00402 };
00403 
00404 
00405 CBMode myCbmodes[128] = {
00406   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00407   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00408   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00409   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00410   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00411   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00412   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00413   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00414   {0},
00415   {0},                          /* A */
00416   {0},                          /* B */
00417   {0},                          /* C */
00418   {0},                          /* D */
00419   {0},                          /* E */
00420   {0},                          /* F */
00421   {0},                          /* G */
00422   {0},                          /* H */
00423   {0},                          /* I */
00424   {0},                          /* J */
00425   {0},                          /* K */
00426   {0},                          /* L */
00427   {CMODE_M, 0, NULL, NULL},     /* M */
00428   {CMODE_N, 0, NULL, NULL},     /* N */
00429   {CMODE_O, CBM_NO_USER_MLOCK, NULL, NULL},     /* O */
00430   {0},                          /* P */
00431   {0},                          /* Q */
00432   {CMODE_R, 0, NULL, NULL},     /* R */
00433   {0},                          /* S */
00434   {0},                          /* T */
00435   {0},                          /* U */
00436   {0},                          /* V */
00437   {0},                          /* W */
00438   {0},                          /* X */
00439   {0},                          /* Y */
00440   {CMODE_Z, 0, NULL, NULL},     /* Z */
00441   {0}, {0}, {0}, {0}, {0}, {0},
00442   {CMODE_a, 0, NULL, NULL},
00443   {0},                          /* b */
00444   {CMODE_c, 0, NULL, NULL},     /* c */
00445   {0},                          /* d */
00446   {0},                          /* e */
00447   {0},                          /* f */
00448   {0},                          /* g */
00449   {0},                          /* h */
00450   {CMODE_i, 0, NULL, NULL},
00451   {0},                          /* j */
00452   {CMODE_k, 0, chan_set_key, cs_set_key},
00453   {CMODE_l, CBM_MINUS_NO_ARG, set_limit, cs_set_limit},
00454   {CMODE_m, 0, NULL, NULL},
00455   {CMODE_n, 0, NULL, NULL},
00456   {0},                          /* o */
00457   {CMODE_p, 0, NULL, NULL},
00458   {0},                          /* q */
00459   {0},
00460   {CMODE_s, 0, NULL, NULL},
00461   {CMODE_t, 0, NULL, NULL},
00462   {0},
00463   {0},                          /* v */
00464   {0},                          /* w */
00465   {0},                          /* x */
00466   {0},                          /* y */
00467   {0},                          /* z */
00468   {0}, {0}, {0}, {0}
00469 };
00470 
00471 CBModeInfo myCbmodeinfos[] = {
00472   {'a', CMODE_a, 0, NULL, NULL},
00473   {'i', CMODE_i, 0, NULL, NULL},
00474   {'k', CMODE_k, 0, get_key, cs_get_key},
00475   {'l', CMODE_l, CBM_MINUS_NO_ARG, get_limit, cs_get_limit},
00476   {'m', CMODE_m, 0, NULL, NULL},
00477   {'n', CMODE_n, 0, NULL, NULL},
00478   {'p', CMODE_p, 0, NULL, NULL},
00479   {'s', CMODE_s, 0, NULL, NULL},
00480   {'t', CMODE_t, 0, NULL, NULL},
00481   {'M', CMODE_M, 0, NULL, NULL},
00482   {'N', CMODE_N, 0, NULL, NULL},
00483   {'O', CMODE_O, 0, NULL, NULL},
00484   {'R', CMODE_R, 0, NULL, NULL},
00485   {'Z', CMODE_Z, 0, NULL, NULL},
00486   {0}
00487 };
00488 
00489 
00490 CUMode myCumodes[128] = {
00491   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00492   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00493   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00494   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00495 
00496   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00497   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00498   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00499   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00500 
00501   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00502   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00503   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00504   {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0},
00505 
00506   {0},
00507 
00508   {0},                          /* a */
00509   {0},                          /* b */
00510   {0},                          /* c */
00511   {0},                          /* d */
00512   {0},                          /* e */
00513   {0},                          /* f */
00514   {0},                          /* g */
00515   {CUS_HALFOP, 0, plexus_check_valid_halfop},
00516   {0},                          /* i */
00517   {0},                          /* j */
00518   {0},                          /* k */
00519   {0},                          /* l */
00520   {0},                          /* m */
00521   {0},                          /* n */
00522   {CUS_OP, CUF_PROTECT_BOTSERV, plexus_check_valid_op},
00523   {0},                          /* p */
00524   {0},                          /* q */
00525   {0},                          /* r */
00526   {0},                          /* s */
00527   {0},                          /* t */
00528   {0},                          /* u */
00529   {CUS_VOICE, 0, NULL},
00530   {0},                          /* w */
00531   {0},                          /* x */
00532   {0},                          /* y */
00533   {0},                          /* z */
00534   {0}, {0}, {0}, {0}, {0}
00535 };
00536 
00537 
00538 
00539 void
00540 plexus_cmd_notice (char *source, char *dest, char *buf)
00541 {
00542   if (!buf)
00543     {
00544       return;
00545     }
00546 
00547   if (NSDefFlags & NI_MSG)
00548     {
00549       plexus_cmd_privmsg2 (source, dest, buf);
00550     }
00551   else
00552     {
00553       send_cmd (source, "NOTICE %s :%s", dest, buf);
00554     }
00555 }
00556 
00557 void
00558 plexus_cmd_notice2 (char *source, char *dest, char *msg)
00559 {
00560   send_cmd (source, "NOTICE %s :%s", dest, msg);
00561 }
00562 
00563 void
00564 plexus_cmd_privmsg (char *source, char *dest, char *buf)
00565 {
00566   if (!buf)
00567     {
00568       return;
00569     }
00570 
00571   send_cmd (source, "PRIVMSG %s :%s", dest, buf);
00572 }
00573 
00574 void
00575 plexus_cmd_privmsg2 (char *source, char *dest, char *msg)
00576 {
00577   send_cmd (source, "PRIVMSG %s :%s", dest, msg);
00578 }
00579 
00580 void
00581 plexus_cmd_serv_notice (char *source, char *dest, char *msg)
00582 {
00583   send_cmd (source, "NOTICE $$%s :%s", dest, msg);
00584 }
00585 
00586 void
00587 plexus_cmd_serv_privmsg (char *source, char *dest, char *msg)
00588 {
00589   send_cmd (source, "PRIVMSG $$%s :%s", dest, msg);
00590 }
00591 
00592 
00593 void
00594 plexus_cmd_global (char *source, char *buf)
00595 {
00596   if (!buf)
00597     {
00598       return;
00599     }
00600 
00601   send_cmd (source ? source : ServerName, "OPERWALL :%s", buf);
00602 }
00603 
00604 /* GLOBOPS - to handle old WALLOPS */
00605 void
00606 plexus_cmd_global_legacy (char *source, char *fmt)
00607 {
00608   send_cmd (source ? source : ServerName, "OPERWALL :%s", fmt);
00609 }
00610 
00611 int
00612 anope_event_sjoin (char *source, int ac, char **av)
00613 {
00614   do_sjoin (source, ac, av);
00615   return MOD_CONT;
00616 }
00617 
00618 int
00619 anope_event_nick (char *source, int ac, char **av)
00620 {
00621   if (ac != 2)
00622     {
00623       User *user = do_nick (source, av[0], av[4], av[5], av[7], av[9],
00624                             strtoul (av[2], NULL, 10),
00625                             strtoul (av[8], NULL, 0), 0, av[6], NULL);
00626       if (user)
00627         anope_set_umode (user, 1, &av[3]);
00628     }
00629   else
00630     {
00631       do_nick (source, av[0], NULL, NULL, NULL, NULL,
00632                strtoul (av[1], NULL, 10), 0, 0, NULL, NULL);
00633     }
00634   return MOD_CONT;
00635 }
00636 
00637 int
00638 anope_event_topic (char *source, int ac, char **av)
00639 {
00640   if (ac == 4)
00641     {
00642       do_topic (source, ac, av);
00643     }
00644   else
00645     {
00646       Channel *c = findchan (av[0]);
00647       time_t topic_time = time (NULL);
00648 
00649       if (!c)
00650         {
00651           if (debug)
00652             {
00653               alog ("debug: TOPIC %s for nonexistent channel %s",
00654                     merge_args (ac - 1, av + 1), av[0]);
00655             }
00656           return MOD_CONT;
00657         }
00658 
00659       if (check_topiclock (c, topic_time))
00660         return MOD_CONT;
00661 
00662       if (c->topic)
00663         {
00664           free (c->topic);
00665           c->topic = NULL;
00666         }
00667       if (ac > 1 && *av[1])
00668         c->topic = sstrdup (av[1]);
00669 
00670       strscpy (c->topic_setter, source, sizeof (c->topic_setter));
00671       c->topic_time = topic_time;
00672 
00673       record_topic (av[0]);
00674           
00675           if (ac > 1 && *av[1])
00676               send_event(EVENT_TOPIC_UPDATED, 2, av[0], av[1]);
00677           else
00678               send_event(EVENT_TOPIC_UPDATED, 2, av[0], "");
00679                           
00680     }
00681   return MOD_CONT;
00682 }
00683 
00684 int
00685 anope_event_tburst (char *source, int ac, char **av)
00686 {
00687   if (ac != 5)
00688     return MOD_CONT;
00689 
00690   av[0] = av[1];
00691   av[1] = av[3];
00692   av[3] = av[4];
00693   do_topic (source, 4, av);
00694   return MOD_CONT;
00695 }
00696 
00697 int
00698 anope_event_436 (char *source, int ac, char **av)
00699 {
00700   if (ac < 1)
00701     return MOD_CONT;
00702 
00703   m_nickcoll (av[0]);
00704   return MOD_CONT;
00705 }
00706 
00707 
00708 void
00709 moduleAddIRCDMsgs (void)
00710 {
00711   Message *m;
00712 
00713   updateProtectDetails ("PROTECT", "PROTECTME", "protect", "deprotect",
00714                         "AUTOPROTECT", "+", "-");
00715 
00716   m = createMessage ("401", anope_event_null);
00717   addCoreMessage (IRCD, m);
00718   m = createMessage ("402", anope_event_null);
00719   addCoreMessage (IRCD, m);
00720   m = createMessage ("436", anope_event_436);
00721   addCoreMessage (IRCD, m);
00722   m = createMessage ("AWAY", anope_event_away);
00723   addCoreMessage (IRCD, m);
00724   m = createMessage ("INVITE", anope_event_invite);
00725   addCoreMessage (IRCD, m);
00726   m = createMessage ("JOIN", anope_event_join);
00727   addCoreMessage (IRCD, m);
00728   m = createMessage ("KICK", anope_event_kick);
00729   addCoreMessage (IRCD, m);
00730   m = createMessage ("KILL", anope_event_kill);
00731   addCoreMessage (IRCD, m);
00732   m = createMessage ("MODE", anope_event_mode);
00733   addCoreMessage (IRCD, m);
00734   m = createMessage ("MOTD", anope_event_motd);
00735   addCoreMessage (IRCD, m);
00736   m = createMessage ("NICK", anope_event_nick);
00737   addCoreMessage (IRCD, m);
00738   m = createMessage ("NOTICE", anope_event_notice);
00739   addCoreMessage (IRCD, m);
00740   m = createMessage ("PART", anope_event_part);
00741   addCoreMessage (IRCD, m);
00742   m = createMessage ("PASS", anope_event_pass);
00743   addCoreMessage (IRCD, m);
00744   m = createMessage ("PING", anope_event_ping);
00745   addCoreMessage (IRCD, m);
00746   m = createMessage ("PRIVMSG", anope_event_privmsg);
00747   addCoreMessage (IRCD, m);
00748   m = createMessage ("QUIT", anope_event_quit);
00749   addCoreMessage (IRCD, m);
00750   m = createMessage ("SERVER", anope_event_server);
00751   addCoreMessage (IRCD, m);
00752   m = createMessage ("SQUIT", anope_event_squit);
00753   addCoreMessage (IRCD, m);
00754   m = createMessage ("TOPIC", anope_event_topic);
00755   addCoreMessage (IRCD, m);
00756   m = createMessage ("TBURST", anope_event_tburst);
00757   addCoreMessage (IRCD, m);
00758   m = createMessage ("USER", anope_event_null);
00759   addCoreMessage (IRCD, m);
00760   m = createMessage ("WALLOPS", anope_event_null);
00761   addCoreMessage (IRCD, m);
00762   m = createMessage ("WHOIS", anope_event_whois);
00763   addCoreMessage (IRCD, m);
00764   m = createMessage ("SVSMODE", anope_event_mode);
00765   addCoreMessage (IRCD, m);
00766   m = createMessage ("SVSNICK", anope_event_null);
00767   addCoreMessage (IRCD, m);
00768   m = createMessage ("CAPAB", anope_event_capab);
00769   addCoreMessage (IRCD, m);
00770   m = createMessage ("SJOIN", anope_event_sjoin);
00771   addCoreMessage (IRCD, m);
00772   m = createMessage ("SVINFO", anope_event_svinfo);
00773   addCoreMessage (IRCD, m);
00774   m = createMessage ("EOB", anope_event_eob);
00775   addCoreMessage (IRCD, m);
00776   m = createMessage ("ADMIN", anope_event_admin);
00777   addCoreMessage (IRCD, m);
00778   m = createMessage ("ERROR", anope_event_error);
00779   addCoreMessage (IRCD, m);
00780   m = createMessage ("SETHOST", anope_event_sethost);
00781   addCoreMessage (IRCD, m);
00782 }
00783 
00784 void
00785 plexus_cmd_sqline (char *mask, char *reason)
00786 {
00787   send_cmd (s_OperServ, "RESV * %s :%s", mask, reason);
00788 }
00789 
00790 void
00791 plexus_cmd_unsgline (char *mask)
00792 {
00793   send_cmd (s_OperServ, "UNXLINE * %s", mask);
00794 }
00795 
00796 void
00797 plexus_cmd_unszline (char *mask)
00798 {
00799   /* Does not support */
00800 }
00801 
00802 void
00803 plexus_cmd_szline (char *mask, char *reason, char *whom)
00804 {
00805   /* Does not support */
00806 }
00807 
00808 void
00809 plexus_cmd_svsnoop (char *server, int set)
00810 {
00811   /* does not support */
00812 }
00813 
00814 void
00815 plexus_cmd_svsadmin (char *server, int set)
00816 {
00817   plexus_cmd_svsnoop (server, set);
00818 }
00819 
00820 void
00821 plexus_cmd_sgline (char *mask, char *reason)
00822 {
00823   send_cmd (s_OperServ, "XLINE * %s :%s", mask, reason);
00824 }
00825 
00826 void
00827 plexus_cmd_remove_akill (char *user, char *host)
00828 {
00829   send_cmd (s_OperServ, "UNKLINE * %s %s", user, host);
00830 }
00831 
00832 void
00833 plexus_cmd_topic (char *whosets, char *chan, char *whosetit,
00834                   char *topic, time_t when)
00835 {
00836   send_cmd (whosets, "SVSTOPIC %s %s %lu :%s", chan, whosetit,
00837             (unsigned long int) when, topic);
00838 }
00839 
00840 void
00841 plexus_cmd_vhost_off (User * u)
00842 {
00843   send_cmd (ServerName, "SVSMODE %s -h", u->nick);
00844 }
00845 
00846 void
00847 plexus_cmd_vhost_on (char *nick, char *vIdent, char *vhost)
00848 {
00849   User *u;
00850 
00851   if (!nick)
00852   {
00853     return;
00854   }
00855 
00856   u = finduser (nick);
00857 
00858   if (u)
00859   {
00860     send_cmd (ServerName, "SVSHOST %s %s", nick, vhost);
00861     u->mode |= UMODE_h;
00862   }
00863 }
00864 
00865 void
00866 plexus_cmd_unsqline (char *user)
00867 {
00868   send_cmd (s_OperServ, "UNRESV * %s", user);
00869 }
00870 
00871 void
00872 plexus_cmd_join (char *user, char *channel, time_t chantime)
00873 {
00874   send_cmd (ServerName, "SJOIN %ld %s + :%s", (long int) chantime, channel,
00875             user);
00876 }
00877 
00878 /*
00879 oper:           the nick of the oper performing the kline
00880 target.server:  the server(s) this kline is destined for
00881 duration:       the duration if a tkline, 0 if permanent.
00882 user:           the 'user' portion of the kline
00883 host:           the 'host' portion of the kline
00884 reason:         the reason for the kline.
00885 */
00886 
00887 void
00888 plexus_cmd_akill (char *user, char *host, char *who, time_t when,
00889                   time_t expires, char *reason)
00890 {
00891   send_cmd (s_OperServ, "KLINE * %ld %s %s :%s",
00892             (long int) (expires - (long) time (NULL)), user, host, reason);
00893 }
00894 
00895 void
00896 plexus_cmd_svskill (char *source, char *user, char *buf)
00897 {
00898   if (!buf)
00899     {
00900       return;
00901     }
00902 
00903   if (!source || !user)
00904     {
00905       return;
00906     }
00907 
00908   send_cmd (source, "KILL %s :%s", user, buf);
00909 }
00910 
00911 void
00912 plexus_cmd_svsmode (User * u, int ac, char **av)
00913 {
00914   send_cmd (ServerName, "SVSMODE %s %s", u->nick, av[0]);
00915 
00916   if ((ac == 2) && isdigit (*av[1]))
00917     send_cmd (ServerName, "SVSID %s %s", u->nick, av[1]);
00918 }
00919 
00920 /*
00921  * SVINFO
00922  *      parv[0] = sender prefix
00923  *      parv[1] = TS_CURRENT for the server
00924  *      parv[2] = TS_MIN for the server
00925  *      parv[3] = server is standalone or connected to non-TS only
00926  *      parv[4] = server's idea of UTC time
00927  */
00928 void
00929 plexus_cmd_svinfo ()
00930 {
00931   send_cmd (NULL, "SVINFO 5 5 0 :%ld", (long int) time (NULL));
00932 }
00933 
00934 /* CAPAB */
00935 /*
00936   QS     - Can handle quit storm removal
00937   EX     - Can do channel +e exemptions 
00938   CHW    - Can do channel wall @#
00939   LL     - Can do lazy links 
00940   IE     - Can do invite exceptions 
00941   EOB    - Can do EOB message
00942   KLN    - Can do KLINE message 
00943   GLN    - Can do GLINE message 
00944   HOPS   - can do half ops (+h)
00945   HUB    - This server is a HUB 
00946   AOPS   - Can do anon ops (+a) 
00947   UID    - Can do UIDs
00948   ZIP    - Can do ZIPlinks
00949   ENC    - Can do ENCrypted links 
00950   KNOCK  -  supports KNOCK 
00951   TBURST - supports TBURST
00952   PARA   - supports invite broadcasting for +p
00953   ENCAP  - ?
00954 */
00955 void
00956 plexus_cmd_capab ()
00957 {
00958   send_cmd (NULL,
00959             "CAPAB :QS EX CHW IE EOB KLN GLN HOPS HUB KNOCK TBURST PARA");
00960 }
00961 
00962 /* PASS */
00963 void
00964 plexus_cmd_pass (char *pass)
00965 {
00966   send_cmd (NULL, "PASS %s :TS", pass);
00967 }
00968 
00969 /* SERVER name hop descript */
00970 void
00971 plexus_cmd_server (char *servname, int hop, char *descript)
00972 {
00973   send_cmd (NULL, "SERVER %s %d :%s", servname, hop, descript);
00974 }
00975 
00976 void
00977 plexus_cmd_connect (int servernum)
00978 {
00979   me_server = new_server (NULL, ServerName, ServerDesc, SERVER_ISME, NULL);
00980 
00981   if (servernum == 1)
00982     plexus_cmd_pass (RemotePassword);
00983   else if (servernum == 2)
00984     plexus_cmd_pass (RemotePassword2);
00985   else if (servernum == 3)
00986     plexus_cmd_pass (RemotePassword3);
00987 
00988   plexus_cmd_capab ();
00989   plexus_cmd_server (ServerName, 1, ServerDesc);
00990   plexus_cmd_svinfo ();
00991 }
00992 
00993 void
00994 plexus_cmd_bob()
00995 {
00996   /* not used */
00997 }
00998 
00999 void
01000 plexus_cmd_svsinfo ()
01001 {
01002   /* not used */
01003 }
01004 
01005 
01006 
01007 void
01008 plexus_cmd_bot_nick (char *nick, char *user, char *host, char *real,
01009                      char *modes)
01010 {
01011   EnforceQlinedNick (nick, NULL);
01012   send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
01013             (long int) time (NULL), modes, user, host, "*", ServerName, real);
01014   plexus_cmd_sqline (nick, "Reserved for services");
01015 
01016 }
01017 
01018 void
01019 plexus_cmd_part (char *nick, char *chan, char *buf)
01020 {
01021   if (buf)
01022     {
01023       send_cmd (nick, "PART %s :%s", chan, buf);
01024     }
01025   else
01026     {
01027       send_cmd (nick, "PART %s", chan);
01028     }
01029 }
01030 
01031 int
01032 anope_event_sethost (char *source, int ac, char **av)
01033 {
01034   User *u;
01035 
01036   if (ac != 2)
01037     return MOD_CONT;
01038 
01039   u = finduser (av[0]);
01040   if (!u)
01041     {
01042       if (debug)
01043         {
01044           alog ("debug: SETHOST for nonexistent user %s", source);
01045         }
01046       return MOD_CONT;
01047     }
01048 
01049   change_user_host (u, av[1]);
01050   return MOD_CONT;
01051 }
01052 
01053 int
01054 anope_event_ping (char *source, int ac, char **av)
01055 {
01056   if (ac < 1)
01057     return MOD_CONT;
01058   plexus_cmd_pong (ac > 1 ? av[1] : ServerName, av[0]);
01059   return MOD_CONT;
01060 }
01061 
01062 int
01063 anope_event_away (char *source, int ac, char **av)
01064 {
01065   if (!source)
01066     {
01067       return MOD_CONT;
01068     }
01069   m_away (source, (ac ? av[0] : NULL));
01070   return MOD_CONT;
01071 }
01072 
01073 int
01074 anope_event_kill (char *source, int ac, char **av)
01075 {
01076   if (ac != 2)
01077     return MOD_CONT;
01078 
01079   m_kill (av[0], av[1]);
01080   return MOD_CONT;
01081 }
01082 
01083 int
01084 anope_event_kick (char *source, int ac, char **av)
01085 {
01086   if (ac != 3)
01087     return MOD_CONT;
01088   do_kick (source, ac, av);
01089   return MOD_CONT;
01090 }
01091 
01092 int
01093 anope_event_eob (char *source, int ac, char **av)
01094 {
01095   Server *s;
01096   s = findserver (servlist, source);
01097   /* If we found a server with the given source, that one just
01098    * finished bursting. If there was no source, then our uplink
01099    * server finished bursting. -GD
01100    */
01101   if (!s && serv_uplink)
01102     s = serv_uplink;
01103   finish_sync (s, 1);
01104 
01105   return MOD_CONT;
01106 }
01107 
01108 void
01109 plexus_cmd_eob ()
01110 {
01111   send_cmd (ServerName, "EOB");
01112 }
01113 
01114 
01115 int
01116 anope_event_join (char *source, int ac, char **av)
01117 {
01118   if (ac != 1)
01119     return MOD_CONT;
01120   do_join (source, ac, av);
01121   return MOD_CONT;
01122 }
01123 
01124 int
01125 anope_event_motd (char *source, int ac, char **av)
01126 {
01127   if (!source)
01128     {
01129       return MOD_CONT;
01130     }
01131 
01132   m_motd (source);
01133   return MOD_CONT;
01134 }
01135 
01136 int
01137 anope_event_privmsg (char *source, int ac, char **av)
01138 {
01139   if (ac != 2)
01140     return MOD_CONT;
01141   m_privmsg (source, av[0], av[1]);
01142   return MOD_CONT;
01143 }
01144 
01145 int
01146 anope_event_part (char *source, int ac, char **av)
01147 {
01148   if (ac < 1 || ac > 2)
01149     return MOD_CONT;
01150   do_part (source, ac, av);
01151   return MOD_CONT;
01152 }
01153 
01154 int
01155 anope_event_whois (char *source, int ac, char **av)
01156 {
01157   if (source && ac >= 1)
01158     {
01159       m_whois (source, av[0]);
01160     }
01161   return MOD_CONT;
01162 }
01163 
01164 /* EVENT: SERVER */
01165 int
01166 anope_event_server (char *source, int ac, char **av)
01167 {
01168   if (!stricmp (av[1], "1"))
01169     {
01170       uplink = sstrdup (av[0]);
01171     }
01172   do_server (source, av[0], av[1], av[2], NULL);
01173   return MOD_CONT;
01174 }
01175 
01176 int
01177 anope_event_squit (char *source, int ac, char **av)
01178 {
01179   if (ac != 2)
01180     return MOD_CONT;
01181   do_squit (source, ac, av);
01182   return MOD_CONT;
01183 }
01184 
01185 int
01186 anope_event_quit (char *source, int ac, char **av)
01187 {
01188   if (ac != 1)
01189     return MOD_CONT;
01190   do_quit (source, ac, av);
01191   return MOD_CONT;
01192 }
01193 
01194 void
01195 plexus_cmd_372 (char *source, char *msg)
01196 {
01197   send_cmd (ServerName, "372 %s :- %s", source, msg);
01198 }
01199 
01200 void
01201 plexus_cmd_372_error (char *source)
01202 {
01203   send_cmd (ServerName, "422 %s :- MOTD file not found!  Please "
01204             "contact your IRC administrator.", source);
01205 }
01206 
01207 void
01208 plexus_cmd_375 (char *source)
01209 {
01210   send_cmd (ServerName, "375 %s :- %s Message of the Day",
01211             source, ServerName);
01212 }
01213 
01214 void
01215 plexus_cmd_376 (char *source)
01216 {
01217   send_cmd (ServerName, "376 %s :End of /MOTD command.", source);
01218 }
01219 
01220 /* 391 */
01221 void
01222 plexus_cmd_391 (char *source, char *timestr)
01223 {
01224   if (!timestr)
01225     {
01226       return;
01227     }
01228   send_cmd (ServerName, "391 :%s %s :%s", source, ServerName, timestr);
01229 }
01230 
01231 /* 250 */
01232 void
01233 plexus_cmd_250 (char *buf)
01234 {
01235   if (!buf)
01236     {
01237       return;
01238     }
01239 
01240   send_cmd (ServerName, "250 %s", buf);
01241 }
01242 
01243 /* 307 */
01244 void
01245 plexus_cmd_307 (char *buf)
01246 {
01247   if (!buf)
01248     {
01249       return;
01250     }
01251 
01252   send_cmd (ServerName, "307 %s", buf);
01253 }
01254 
01255 /* 311 */
01256 void
01257 plexus_cmd_311 (char *buf)
01258 {
01259   if (!buf)
01260     {
01261       return;
01262     }
01263 
01264   send_cmd (ServerName, "311 %s", buf);
01265 }
01266 
01267 /* 312 */
01268 void
01269 plexus_cmd_312 (char *buf)
01270 {
01271   if (!buf)
01272     {
01273       return;
01274     }
01275 
01276   send_cmd (ServerName, "312 %s", buf);
01277 }
01278 
01279 /* 317 */
01280 void
01281 plexus_cmd_317 (char *buf)
01282 {
01283   if (!buf)
01284     {
01285       return;
01286     }
01287 
01288   send_cmd (ServerName, "317 %s", buf);
01289 }
01290 
01291 /* 219 */
01292 void
01293 plexus_cmd_219 (char *source, char *letter)
01294 {
01295   if (!source)
01296     {
01297       return;
01298     }
01299 
01300   if (letter)
01301     {
01302       send_cmd (ServerName, "219 %s %c :End of /STATS report.", source, *letter);
01303     }
01304   else
01305     {
01306       send_cmd (ServerName, "219 %s l :End of /STATS report.", source);
01307     }
01308 }
01309 
01310 /* 401 */
01311 void
01312 plexus_cmd_401 (char *source, char *who)
01313 {
01314   if (!source || !who)
01315     {
01316       return;
01317     }
01318   send_cmd (ServerName, "401 %s %s :No such service.", source, who);
01319 }
01320 
01321 /* 318 */
01322 void
01323 plexus_cmd_318 (char *source, char *who)
01324 {
01325   if (!source || !who)
01326     {
01327       return;
01328     }
01329 
01330   send_cmd (ServerName, "318 %s %s :End of /WHOIS list.", source, who);
01331 }
01332 
01333 /* 242 */
01334 void
01335 plexus_cmd_242 (char *buf)
01336 {
01337   if (!buf)
01338     {
01339       return;
01340     }
01341 
01342   send_cmd (ServerName, "242 %s", buf);
01343 }
01344 
01345 /* 243 */
01346 void
01347 plexus_cmd_243 (char *buf)
01348 {
01349   if (!buf)
01350     {
01351       return;
01352     }
01353 
01354   send_cmd (ServerName, "243 %s", buf);
01355 }
01356 
01357 /* 211 */
01358 void
01359 plexus_cmd_211 (char *buf)
01360 {
01361   if (!buf)
01362     {
01363       return;
01364     }
01365 
01366   send_cmd (ServerName, "211 %s", buf);
01367 }
01368 
01369 void
01370 plexus_cmd_mode (char *source, char *dest, char *buf)
01371 {
01372   if (!buf)
01373     {
01374       return;
01375     }
01376 
01377   send_cmd (source, "MODE %s %s", dest, buf);
01378 }
01379 
01380 void
01381 plexus_cmd_nick (char *nick, char *name, char *mode)
01382 {
01383   EnforceQlinedNick (nick, NULL);
01384   send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
01385             (long int) time (NULL), mode, ServiceUser, ServiceHost,
01386             "*", ServerName, (name));
01387   send_cmd (nick, "RESV * %s :%s", nick, "Reserved for services");
01388 }
01389 
01390 void
01391 plexus_cmd_kick (char *source, char *chan, char *user, char *buf)
01392 {
01393   if (buf)
01394     {
01395       send_cmd (source, "KICK %s %s :%s", chan, user, buf);
01396     }
01397   else
01398     {
01399       send_cmd (source, "KICK %s %s", chan, user);
01400     }
01401 }
01402 
01403 void
01404 plexus_cmd_notice_ops (char *source, char *dest, char *buf)
01405 {
01406   if (!buf)
01407     {
01408       return;
01409     }
01410 
01411   send_cmd (ServerName, "NOTICE @%s :%s", dest, buf);
01412 }
01413 
01414 void
01415 plexus_cmd_bot_chan_mode (char *nick, char *chan)
01416 {
01417   anope_cmd_mode (nick, chan, "%s %s", ircd->botchanumode, nick);
01418 }
01419 
01420 /* QUIT */
01421 void
01422 plexus_cmd_quit (char *source, char *buf)
01423 {
01424   if (buf)
01425     {
01426       send_cmd (source, "QUIT :%s", buf);
01427     }
01428   else
01429     {
01430       send_cmd (source, "QUIT");
01431     }
01432 }
01433 
01434 /* PONG */
01435 void
01436 plexus_cmd_pong (char *servname, char *who)
01437 {
01438   send_cmd (servname, "PONG %s", who);
01439 }
01440 
01441 /* INVITE */
01442 void
01443 plexus_cmd_invite (char *source, char *chan, char *nick)
01444 {
01445   if (!source || !chan || !nick)
01446     {
01447       return;
01448     }
01449 
01450   send_cmd (source, "INVITE %s %s", nick, chan);
01451 }
01452 
01453 /* SQUIT */
01454 void
01455 plexus_cmd_squit (char *servname, char *message)
01456 {
01457   if (!servname || !message)
01458     {
01459       return;
01460     }
01461 
01462   send_cmd (ServerName, "SQUIT %s :%s", servname, message);
01463 }
01464 
01465 int
01466 anope_event_mode (char *source, int ac, char **av)
01467 {
01468   if (ac < 2)
01469     return MOD_CONT;
01470 
01471   if (*av[0] == '#' || *av[0] == '&')
01472     {
01473       do_cmode (source, ac, av);
01474     }
01475   else
01476     {
01477       Server *s;
01478       s = findserver (servlist, source);
01479 
01480       if (s && *av[0])
01481         {
01482           do_umode (av[0], ac, av);
01483         }
01484       else
01485         {
01486           do_umode (source, ac, av);
01487         }
01488     }
01489   return MOD_CONT;
01490 }
01491 
01492 void
01493 plexus_cmd_351 (char *source)
01494 {
01495   send_cmd (ServerName, "351 %s Anope-%s %s :%s - %s (%s) -- %s",
01496             source, version_number, ServerName, ircd->name, version_flags,
01497             EncModule, version_build);
01498 }
01499 
01500 /* Event: PROTOCTL */
01501 int
01502 anope_event_capab (char *source, int ac, char **av)
01503 {
01504     int argvsize = 8;
01505     int argc;
01506     char **argv;
01507     char *str;
01508 
01509     if (ac < 1)
01510         return MOD_CONT;
01511 
01512     /* We get the params as one arg, we should split it for capab_parse */
01513     argv = scalloc(argvsize, sizeof(char *));
01514     argc = 0;
01515     while ((str = myStrGetToken(av[0], ' ', argc))) {
01516         if (argc == argvsize) {
01517             argvsize += 8;
01518             argv = srealloc(argv, argvsize * sizeof(char *));
01519         }
01520         argv[argc] = str;
01521         argc++;
01522     }
01523 
01524     capab_parse(argc, argv);
01525 
01526     /* Free our built ac/av */
01527     for (argvsize = 0; argvsize < argc; argvsize++) {
01528         free(argv[argvsize]);
01529     }
01530     free(argv);
01531 
01532   return MOD_CONT;
01533 }
01534 
01535 /* SVSHOLD - set */
01536 void
01537 plexus_cmd_svshold (char *nick)
01538 {
01539   /* Not supported by this IRCD */
01540 }
01541 
01542 /* SVSHOLD - release */
01543 void
01544 plexus_cmd_release_svshold (char *nick)
01545 {
01546   /* Not Supported by this IRCD */
01547 }
01548 
01549 /* SVSNICK */
01550 void
01551 plexus_cmd_svsnick (char *nick, char *newnick, time_t when)
01552 {
01553   if (!nick || !newnick)
01554     {
01555       return;
01556     }
01557   send_cmd (ServerName, "SVSNICK %s %s", nick, newnick);
01558 }
01559 
01560 void
01561 plexus_cmd_guest_nick (char *nick, char *user, char *host, char *real,
01562                        char *modes)
01563 {
01564   send_cmd (ServerName, "NICK %s 1 %ld %s %s %s %s %s 0 :%s", nick,
01565             (long int) time (NULL), modes, user, host, "*", ServerName, real);
01566 }
01567 
01568 void
01569 plexus_cmd_svso (char *source, char *nick, char *flag)
01570 {
01571   /* Not Supported by this IRCD */
01572 }
01573 
01574 void
01575 plexus_cmd_unban (char *name, char *nick)
01576 {
01577   /* Not Supported by this IRCD */
01578 }
01579 
01580 /* SVSMODE channel modes */
01581 
01582 void
01583 plexus_cmd_svsmode_chan (char *name, char *mode, char *nick)
01584 {
01585   /* Not Supported by this IRCD */
01586 }
01587 
01588 /* SVSMODE +d */
01589 /* sent if svid is something weird */
01590 void
01591 plexus_cmd_svid_umode (char *nick, time_t ts)
01592 {
01593   send_cmd (ServerName, "SVSID %s 1", nick);
01594 }
01595 
01596 /* SVSMODE +d */
01597 /* nc_change was = 1, and there is no na->status */
01598 void
01599 plexus_cmd_nc_change (User * u)
01600 {
01601   common_svsmode (u, "-R", "1");
01602 }
01603 
01604 /* SVSMODE +d */
01605 void
01606 plexus_cmd_svid_umode2 (User * u, char *ts)
01607 {
01608   if (u->svid != u->timestamp)
01609     {
01610       common_svsmode (u, "+R", ts);
01611     }
01612   else
01613     {
01614       common_svsmode (u, "+R", NULL);
01615     }
01616 }
01617 
01618 void
01619 plexus_cmd_svid_umode3 (User * u, char *ts)
01620 {
01621   /* not used */
01622 }
01623 
01624 /* NICK <newnick>  */
01625 void
01626 plexus_cmd_chg_nick (char *oldnick, char *newnick)
01627 {
01628   if (!oldnick || !newnick)
01629     {
01630       return;
01631     }
01632 
01633   send_cmd (oldnick, "NICK %s", newnick);
01634 }
01635 
01636 /*
01637  * SVINFO
01638  *      parv[0] = sender prefix
01639  *      parv[1] = TS_CURRENT for the server
01640  *      parv[2] = TS_MIN for the server
01641  *      parv[3] = server is standalone or connected to non-TS only
01642  *      parv[4] = server's idea of UTC time
01643  */
01644 int
01645 anope_event_svinfo (char *source, int ac, char **av)
01646 {
01647   /* currently not used but removes the message : unknown message from server */
01648   return MOD_CONT;
01649 }
01650 
01651 int
01652 anope_event_pass (char *source, int ac, char **av)
01653 {
01654   /* currently not used but removes the message : unknown message from server */
01655   return MOD_CONT;
01656 }
01657 
01658 void
01659 plexus_cmd_svsjoin (char *source, char *nick, char *chan, char *param)
01660 {
01661   /* Not Supported by this IRCD */
01662 }
01663 
01664 void
01665 plexus_cmd_svspart (char *source, char *nick, char *chan)
01666 {
01667   /* Not Supported by this IRCD */
01668 }
01669 
01670 void
01671 plexus_cmd_swhois (char *source, char *who, char *mask)
01672 {
01673   /* not supported */
01674 }
01675 
01676 int
01677 anope_event_notice (char *source, int ac, char **av)
01678 {
01679   return MOD_CONT;
01680 }
01681 
01682 int
01683 anope_event_admin (char *source, int ac, char **av)
01684 {
01685   return MOD_CONT;
01686 }
01687 
01688 int
01689 anope_event_invite (char *source, int ac, char **av)
01690 {
01691   return MOD_CONT;
01692 }
01693 
01694 int
01695 plexus_flood_mode_check (char *value)
01696 {
01697   return 0;
01698 }
01699 
01700 int
01701 anope_event_error (char *source, int ac, char **av)
01702 {
01703   if (ac >= 1)
01704     {
01705       if (debug)
01706         {
01707           alog ("debug: %s", av[0]);
01708         }
01709     }
01710   return MOD_CONT;
01711 }
01712 
01713 void
01714 plexus_cmd_jupe (char *jserver, char *who, char *reason)
01715 {
01716   char rbuf[256];
01717 
01718   snprintf (rbuf, sizeof (rbuf), "Juped by %s%s%s", who,
01719             reason ? ": " : "", reason ? reason : "");
01720 
01721   if (findserver(servlist, jserver))
01722     plexus_cmd_squit (jserver, rbuf);
01723   plexus_cmd_server (jserver, 2, rbuf);
01724   new_server (me_server, jserver, rbuf, SERVER_JUPED, NULL);
01725 }
01726 
01727 /* 
01728   1 = valid nick
01729   0 = nick is in valid
01730 */
01731 int
01732 plexus_valid_nick (char *nick)
01733 {
01734   /* no hard coded invalid nicks */
01735   return 1;
01736 }
01737 
01738 /* 
01739   1 = valid chan
01740   0 = chan is in valid
01741 */
01742 int
01743 plexus_valid_chan (char *chan)
01744 {
01745   /* no hard coded invalid chan */
01746   return 1;
01747 }
01748 
01749 
01750 void
01751 plexus_cmd_ctcp (char *source, char *dest, char *buf)
01752 {
01753   char *s;
01754 
01755   if (!buf)
01756     {
01757       return;
01758     }
01759   else
01760     {
01761       s = normalizeBuffer (buf);
01762     }
01763 
01764   send_cmd (source, "NOTICE %s :\1%s \1", dest, s);
01765   free (s);
01766 }
01767 
01768 
01773 void
01774 moduleAddAnopeCmds ()
01775 {
01776   pmodule_cmd_svsnoop (plexus_cmd_svsnoop);
01777   pmodule_cmd_remove_akill (plexus_cmd_remove_akill);
01778   pmodule_cmd_topic (plexus_cmd_topic);
01779   pmodule_cmd_vhost_off (plexus_cmd_vhost_off);
01780   pmodule_cmd_akill (plexus_cmd_akill);
01781   pmodule_cmd_svskill (plexus_cmd_svskill);
01782   pmodule_cmd_svsmode (plexus_cmd_svsmode);
01783   pmodule_cmd_372 (plexus_cmd_372);
01784   pmodule_cmd_372_error (plexus_cmd_372_error);
01785   pmodule_cmd_375 (plexus_cmd_375);
01786   pmodule_cmd_376 (plexus_cmd_376);
01787   pmodule_cmd_nick (plexus_cmd_nick);
01788   pmodule_cmd_guest_nick (plexus_cmd_guest_nick);
01789   pmodule_cmd_mode (plexus_cmd_mode);
01790   pmodule_cmd_bot_nick (plexus_cmd_bot_nick);
01791   pmodule_cmd_kick (plexus_cmd_kick);
01792   pmodule_cmd_notice_ops (plexus_cmd_notice_ops);
01793   pmodule_cmd_notice (plexus_cmd_notice);
01794   pmodule_cmd_notice2 (plexus_cmd_notice2);
01795   pmodule_cmd_privmsg (plexus_cmd_privmsg);
01796   pmodule_cmd_privmsg2 (plexus_cmd_privmsg2);
01797   pmodule_cmd_serv_notice (plexus_cmd_serv_notice);
01798   pmodule_cmd_serv_privmsg (plexus_cmd_serv_privmsg);
01799   pmodule_cmd_bot_chan_mode (plexus_cmd_bot_chan_mode);
01800   pmodule_cmd_351 (plexus_cmd_351);
01801   pmodule_cmd_quit (plexus_cmd_quit);
01802   pmodule_cmd_pong (plexus_cmd_pong);
01803   pmodule_cmd_join (plexus_cmd_join);
01804   pmodule_cmd_unsqline (plexus_cmd_unsqline);
01805   pmodule_cmd_invite (plexus_cmd_invite);
01806   pmodule_cmd_part (plexus_cmd_part);
01807   pmodule_cmd_391 (plexus_cmd_391);
01808   pmodule_cmd_250 (plexus_cmd_250);
01809   pmodule_cmd_307 (plexus_cmd_307);
01810   pmodule_cmd_311 (plexus_cmd_311);
01811   pmodule_cmd_312 (plexus_cmd_312);
01812   pmodule_cmd_317 (plexus_cmd_317);
01813   pmodule_cmd_219 (plexus_cmd_219);
01814   pmodule_cmd_401 (plexus_cmd_401);
01815   pmodule_cmd_318 (plexus_cmd_318);
01816   pmodule_cmd_242 (plexus_cmd_242);
01817   pmodule_cmd_243 (plexus_cmd_243);
01818   pmodule_cmd_211 (plexus_cmd_211);
01819   pmodule_cmd_global (plexus_cmd_global);
01820   pmodule_cmd_global_legacy (plexus_cmd_global_legacy);
01821   pmodule_cmd_sqline (plexus_cmd_sqline);
01822   pmodule_cmd_squit (plexus_cmd_squit);
01823   pmodule_cmd_svso (plexus_cmd_svso);
01824   pmodule_cmd_chg_nick (plexus_cmd_chg_nick);
01825   pmodule_cmd_svsnick (plexus_cmd_svsnick);
01826   pmodule_cmd_vhost_on (plexus_cmd_vhost_on);
01827   pmodule_cmd_connect (plexus_cmd_connect);
01828   pmodule_cmd_bob(plexus_cmd_bob);
01829   pmodule_cmd_svshold (plexus_cmd_svshold);
01830   pmodule_cmd_release_svshold (plexus_cmd_release_svshold);
01831   pmodule_cmd_unsgline (plexus_cmd_unsgline);
01832   pmodule_cmd_unszline (plexus_cmd_unszline);
01833   pmodule_cmd_szline (plexus_cmd_szline);
01834   pmodule_cmd_sgline (plexus_cmd_sgline);
01835   pmodule_cmd_unban (plexus_cmd_unban);
01836   pmodule_cmd_svsmode_chan (plexus_cmd_svsmode_chan);
01837   pmodule_cmd_svid_umode (plexus_cmd_svid_umode);
01838   pmodule_cmd_nc_change (plexus_cmd_nc_change);
01839   pmodule_cmd_svid_umode2 (plexus_cmd_svid_umode2);
01840   pmodule_cmd_svid_umode3 (plexus_cmd_svid_umode3);
01841   pmodule_cmd_svsjoin (plexus_cmd_svsjoin);
01842   pmodule_cmd_svspart (plexus_cmd_svspart);
01843   pmodule_cmd_swhois (plexus_cmd_swhois);
01844   pmodule_cmd_eob (plexus_cmd_eob);
01845   pmodule_flood_mode_check (plexus_flood_mode_check);
01846   pmodule_cmd_jupe (plexus_cmd_jupe);
01847   pmodule_valid_nick (plexus_valid_nick);
01848   pmodule_valid_chan (plexus_valid_chan);
01849   pmodule_cmd_ctcp (plexus_cmd_ctcp);
01850   pmodule_set_umode (plexus_set_umode);
01851 }
01852 
01856 int
01857 AnopeInit (int argc, char **argv)
01858 {
01859 
01860   moduleAddAuthor ("Anope");
01861   moduleAddVersion (VERSION_STRING);
01862   moduleSetType (PROTOCOL);
01863 
01864   pmodule_ircd_version ("PleXusIRCd 2.0+");
01865   pmodule_ircd_cap (myIrcdcap);
01866   pmodule_ircd_var (myIrcd);
01867   pmodule_ircd_cbmodeinfos (myCbmodeinfos);
01868   pmodule_ircd_cumodes (myCumodes);
01869   pmodule_ircd_flood_mode_char_set ("");
01870   pmodule_ircd_flood_mode_char_remove ("");
01871   pmodule_ircd_cbmodes (myCbmodes);
01872   pmodule_ircd_cmmodes (myCmmodes);
01873   pmodule_ircd_csmodes (myCsmodes);
01874   pmodule_ircd_useTSMode (0);
01875 
01877   pmodule_invis_umode (UMODE_i);
01878   pmodule_oper_umode (UMODE_o);
01879   pmodule_invite_cmode (CMODE_i);
01880   pmodule_secret_cmode (CMODE_s);
01881   pmodule_private_cmode (CMODE_p);
01882   pmodule_key_mode (CMODE_k);
01883   pmodule_limit_mode (CMODE_l);
01884   pmodule_permchan_mode(0);
01885 
01886   moduleAddAnopeCmds ();
01887   moduleAddIRCDMsgs ();
01888 
01889   return MOD_CONT;
01890 }
01891 
01892 /* EOF */