00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdinc.h"
00026 #include "client.h"
00027 #include "tools.h"
00028 #include "motd.h"
00029 #include "ircd.h"
00030 #include "send.h"
00031 #include "numeric.h"
00032 #include "handlers.h"
00033 #include "hook.h"
00034 #include "msg.h"
00035 #include "s_serv.h"
00036 #include "parse.h"
00037 #include "modules.h"
00038 #include "s_conf.h"
00039
00040 static void mr_motd(struct Client *, struct Client *, int, char *[]);
00041 static void m_motd(struct Client*, struct Client*, int, char *[]);
00042 static void mo_motd(struct Client*, struct Client*, int, char *[]);
00043
00044
00045
00046
00047
00048
00049
00050
00051 struct Message motd_msgtab = {
00052 "MOTD", 0, 0, 0, 1, MFLG_SLOW, 0,
00053 {mr_motd, m_motd, mo_motd, m_ignore, mo_motd, m_ignore}
00054 };
00055
00056 #ifndef STATIC_MODULES
00057 const char *_version = "$Revision: 589 $";
00058 static struct Callback *motd_cb;
00059
00060 static void *
00061 do_motd(va_list args)
00062 {
00063 struct Client *source_p = va_arg(args, struct Client *);
00064
00065 send_message_file(source_p, &ConfigFileEntry.motd);
00066 return NULL;
00067 }
00068
00069 void
00070 _modinit(void)
00071 {
00072 motd_cb = register_callback("doing_motd", do_motd);
00073 mod_add_cmd(&motd_msgtab);
00074 }
00075
00076 void
00077 _moddeinit(void)
00078 {
00079 mod_del_cmd(&motd_msgtab);
00080 uninstall_hook(motd_cb, do_motd);
00081 }
00082 #endif
00083
00084
00085
00086
00087
00088 static void
00089 mr_motd(struct Client *client_p, struct Client *source_p,
00090 int parc, char *parv[])
00091 {
00092 ClearCap(client_p, CAP_TS6);
00093
00094 send_message_file(source_p, &ConfigFileEntry.motd);
00095 exit_client(source_p, source_p, "Client Exit after MOTD");
00096 }
00097
00098
00099
00100
00101
00102
00103 static void
00104 m_motd(struct Client *client_p, struct Client *source_p,
00105 int parc, char *parv[])
00106 {
00107 static time_t last_used = 0;
00108
00109 if ((last_used + ConfigFileEntry.pace_wait) > CurrentTime)
00110 {
00111
00112 sendto_one(source_p, form_str(RPL_LOAD2HI),
00113 me.name, source_p->name);
00114 return;
00115 }
00116
00117 last_used = CurrentTime;
00118
00119
00120 if (!ConfigFileEntry.disable_remote && !ConfigServerHide.hide_servers)
00121 if (hunt_server(client_p, source_p, ":%s MOTD :%s", 1, parc, parv)
00122 != HUNTED_ISME)
00123 return;
00124
00125 #ifdef STATIC_MODULES
00126 send_message_file(source_p, &ConfigFileEntry.motd);
00127 #else
00128 execute_callback(motd_cb, source_p, parc, parv);
00129 #endif
00130 }
00131
00132
00133
00134
00135
00136
00137 static void
00138 mo_motd(struct Client *client_p, struct Client *source_p,
00139 int parc, char *parv[])
00140 {
00141 if (!IsClient(source_p))
00142 return;
00143
00144 if (hunt_server(client_p, source_p, ":%s MOTD :%s",1,parc,parv)!=HUNTED_ISME)
00145 return;
00146
00147 #ifdef STATIC_MODULES
00148 send_message_file(source_p, &ConfigFileEntry.motd);
00149 #else
00150 execute_callback(motd_cb, source_p, parc, parv);
00151 #endif
00152 }