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
00026
00027
00028
00029
00030
00031 #include "stdinc.h"
00032 #include "handlers.h"
00033 #include "client.h"
00034 #include "common.h"
00035 #include "ircd.h"
00036 #include "send.h"
00037 #include "msg.h"
00038 #include "modules.h"
00039 #include "hash.h"
00040 #include "s_serv.h"
00041 #include "s_conf.h"
00042
00043 static void ms_tb(struct Client *, struct Client *, int, char *[]);
00044 static void ms_tburst(struct Client *, struct Client *, int, char *[]);
00045 static void set_topic(struct Client *, struct Channel *, time_t,
00046 const char *, const char *);
00047
00048 struct Message tburst_msgtab = {
00049 "TBURST", 0, 0, 5, 0, MFLG_SLOW, 0,
00050 { m_ignore, m_ignore, ms_tburst, m_ignore, m_ignore, m_ignore }
00051 };
00052
00053 struct Message tb_msgtab = {
00054 "TB", 0, 0, 4, 0, MFLG_SLOW, 0,
00055 { m_ignore, m_ignore, ms_tb, m_ignore, m_ignore, m_ignore }
00056 };
00057
00058 #ifndef STATIC_MODULES
00059
00060 void
00061 _modinit(void)
00062 {
00063 mod_add_cmd(&tb_msgtab);
00064 add_capability("TB", CAP_TB, 1);
00065
00066 mod_add_cmd(&tburst_msgtab);
00067 add_capability("TBURST", CAP_TBURST, 1);
00068 }
00069
00070 void
00071 _moddeinit(void)
00072 {
00073 mod_del_cmd(&tb_msgtab);
00074 delete_capability("TB");
00075
00076 mod_del_cmd(&tburst_msgtab);
00077 delete_capability("TBURST");
00078 }
00079
00080 const char *_version = "$Revision: 122 $";
00081
00082 #endif
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 static void
00094 ms_tburst(struct Client *client_p, struct Client *source_p,
00095 int parc, char *parv[])
00096 {
00097 struct Channel *chptr = NULL;
00098 int accept_remote = 0;
00099 time_t remote_channel_ts = atol(parv[1]);
00100 time_t remote_topic_ts = atol(parv[3]);
00101 const char *topic = "";
00102 const char *setby = "";
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112 if ((chptr = hash_find_channel(parv[2])) == NULL)
00113 return;
00114
00115 if (parc == 6)
00116 {
00117 topic = parv[5];
00118 setby = parv[4];
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 if (remote_channel_ts < chptr->channelts)
00133 accept_remote = 1;
00134 else if (remote_channel_ts == chptr->channelts)
00135 if (remote_topic_ts > chptr->topic_time)
00136 accept_remote = 1;
00137
00138 if (accept_remote)
00139 {
00140 int topic_differs = strcmp(chptr->topic ? chptr->topic : "", topic);
00141
00142 set_channel_topic(chptr, topic, setby, remote_topic_ts);
00143
00144 if (topic_differs)
00145 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s",
00146 ConfigServerHide.hide_servers ? me.name : source_p->name,
00147 chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
00148 }
00149
00150
00151
00152
00153
00154 sendto_server(source_p, NULL, chptr, CAP_TBURST, NOCAPS, NOFLAGS,
00155 ":%s TBURST %s %s %s %s :%s",
00156 source_p->name, parv[1], parv[2], parv[3], setby, topic);
00157 if (parc > 5 && *topic != '\0')
00158 sendto_server(source_p, NULL, chptr, CAP_TB, CAP_TBURST, NOFLAGS,
00159 ":%s TB %s %s %s :%s",
00160 source_p->name, parv[1], parv[2], setby, topic);
00161 }
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171 #define tb_channel parv[1]
00172 #define tb_topicts_str parv[2]
00173
00174 static void
00175 ms_tb(struct Client *client_p, struct Client *source_p, int parc, char *parv[])
00176 {
00177 struct Channel *chptr;
00178 time_t tb_topicts = atol(tb_topicts_str);
00179 char *tb_whoset = NULL;
00180 char *tb_topic = NULL;
00181
00182 if ((chptr = hash_find_channel(tb_channel)) == NULL)
00183 return;
00184
00185 if (parc == 5)
00186 {
00187 tb_whoset = parv[3];
00188 tb_topic = parv[4];
00189 }
00190 else
00191 {
00192 tb_whoset = source_p->name;
00193 tb_topic = parv[3];
00194 }
00195
00196 set_topic(source_p, chptr, tb_topicts, tb_whoset, tb_topic);
00197 }
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211 static void
00212 set_topic(struct Client *source_p, struct Channel *chptr, time_t topicts,
00213 const char *topicwho, const char *topic)
00214 {
00215 int new_topic = strcmp(chptr->topic ? chptr->topic : "", topic);
00216
00217 set_channel_topic(chptr, topic, topicwho, topicts);
00218
00219
00220 if (new_topic)
00221 sendto_channel_local(ALL_MEMBERS, NO, chptr, ":%s TOPIC %s :%s",
00222 ConfigServerHide.hide_servers ? me.name : source_p->name,
00223 chptr->chname, chptr->topic == NULL ? "" : chptr->topic);
00224
00225 sendto_server(source_p, NULL, chptr, CAP_TBURST, NOCAPS, NOFLAGS,
00226 ":%s TBURST %lu %s %lu %s :%s",
00227 me.name, (unsigned long)chptr->channelts, chptr->chname,
00228 (unsigned long)chptr->topic_time,
00229 chptr->topic_info == NULL ? "" : chptr->topic_info,
00230 chptr->topic == NULL ? "" : chptr->topic);
00231 sendto_server(source_p, NULL, chptr, CAP_TB, CAP_TBURST, NOFLAGS,
00232 ":%s TB %s %lu %s :%s",
00233 me.name, chptr->chname,
00234 (unsigned long)chptr->topic_time,
00235 chptr->topic_info == NULL ? "" : chptr->topic_info,
00236 chptr->topic == NULL ? "" : chptr->topic);
00237 }