diff -urN eggdrop1.6.15/src/chan.h eggdrop1.6.15-topicprot/src/chan.h --- eggdrop1.6.15/src/chan.h Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/chan.h Wed May 7 10:51:30 2003 @@ -185,6 +185,7 @@ int mode_mns_prot; /* modes to reject */ int limit_prot; /* desired limit */ char key_prot[121]; /* desired password */ + char topic_prot[501]; /* desired topic */ char pls[21]; /* positive mode changes */ char mns[21]; /* negative mode changes */ char *key; /* new key to set */ diff -urN eggdrop1.6.15/src/chanprog.c eggdrop1.6.15-topicprot/src/chanprog.c --- eggdrop1.6.15/src/chanprog.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/chanprog.c Wed May 7 10:53:11 2003 @@ -680,3 +680,23 @@ pa = pb; } } + +/* If we have a protected topic and the bot is opped, halfoped, + * or the channel is -t, change the topic. (Sup 11May2001) + */ +void check_topic(struct chanset_t *chan) +{ + memberlist *m = NULL; + + if (chan->topic_prot[0]) { + m = ismember(chan, botname); + if (!m) + return; + if (chan->channel.topic) { + if (!egg_strcasecmp(chan->topic_prot, chan->channel.topic)) + return; + } + if (chan_hasop(m) || !channel_optopic(chan) || chan_hashalfop(m)) + dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, chan->topic_prot); + } +} diff -urN eggdrop1.6.15/src/mod/channels.mod/channels.c eggdrop1.6.15-topicprot/src/mod/channels.mod/channels.c --- eggdrop1.6.15/src/mod/channels.mod/channels.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/channels.mod/channels.c Wed May 7 11:07:16 2003 @@ -364,6 +364,7 @@ FILE *f; char s[121], w[1024], w2[1024], name[163]; char need1[242], need2[242], need3[242], need4[242], need5[242]; + char topic[1002]; struct chanset_t *chan; struct udef_struct *ul; @@ -384,13 +385,14 @@ convert_element(chan->dname, name); get_mode_protect(chan, w); convert_element(w, w2); + convert_element(chan->topic_prot, topic); convert_element(chan->need_op, need1); convert_element(chan->need_invite, need2); convert_element(chan->need_key, need3); convert_element(chan->need_unban, need4); convert_element(chan->need_limit, need5); fprintf(f, - "channel %s %s%schanmode %s idle-kick %d stopnethack-mode %d \ + "channel %s %s%schanmode %s topic %s idle-kick %d stopnethack-mode %d \ revenge-mode %d need-op %s need-invite %s need-key %s \ need-unban %s need-limit %s flood-chan %d:%d flood-ctcp %d:%d \ flood-join %d:%d flood-kick %d:%d flood-deop %d:%d \ @@ -402,7 +404,7 @@ %cdynamicexempts %cuserexempts %cdynamicinvites \ %cuserinvites %cnodesynch ", channel_static(chan) ? "set" : "add", name, channel_static(chan) ? - " " : " { ", w2, chan->idle_kick, chan->stopnethack_mode, + " " : " { ", w2, topic, chan->idle_kick, chan->stopnethack_mode, chan->revenge_mode, need1, need2, need3, need4, need5, chan->flood_pub_thr, chan->flood_pub_time, chan->flood_ctcp_thr, chan->flood_ctcp_time, diff -urN eggdrop1.6.15/src/mod/channels.mod/cmdschan.c eggdrop1.6.15-topicprot/src/mod/channels.mod/cmdschan.c --- eggdrop1.6.15/src/mod/channels.mod/cmdschan.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/channels.mod/cmdschan.c Wed May 7 11:09:01 2003 @@ -1241,6 +1241,7 @@ channel_static(chan) ? "static" : "dynamic", chan->dname); get_mode_protect(chan, work); dprintf(idx, "Protect modes (chanmode): %s\n", work[0] ? work : "None"); + dprintf(idx, "Protect topic: %s\n", chan->topic_prot[0] ? chan->topic_prot : "None"); if (chan->idle_kick) dprintf(idx, "Idle Kick after (idle-kick): %d\n", chan->idle_kick); else diff -urN eggdrop1.6.15/src/mod/channels.mod/help/chaninfo.help eggdrop1.6.15-topicprot/src/mod/channels.mod/help/chaninfo.help --- eggdrop1.6.15/src/mod/channels.mod/help/chaninfo.help Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/channels.mod/help/chaninfo.help Wed May 7 11:09:44 2003 @@ -4,6 +4,7 @@ It shows any of the following: %bchanmode%b These modes are enforced on the channel. Both + and - modes can be enforced. + %btopic%b which topic is enforced on the channel %bidle-kick%b Kick idle users that are not +f or above on the channel after how many minutes (set this to 0 to disable). %{+n} diff -urN eggdrop1.6.15/src/mod/channels.mod/tclchan.c eggdrop1.6.15-topicprot/src/mod/channels.mod/tclchan.c --- eggdrop1.6.15/src/mod/channels.mod/tclchan.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/channels.mod/tclchan.c Wed May 7 11:10:59 2003 @@ -1223,6 +1223,15 @@ return TCL_ERROR; } chan->invite_time = atoi(item[i]); + } else if (!strcmp(item[i], "topic")) { + i++; + if (i >= items) { + if (irp) + Tcl_AppendResult(irp, "channel topic needs argument", NULL); + return TCL_ERROR; + } + strncpyz(chan->topic_prot, item[i], sizeof(chan->topic_prot)); + check_topic(chan); } else if (!strcmp(item[i], "+enforcebans")) chan->status |= CHAN_ENFORCEBANS; else if (!strcmp(item[i], "-enforcebans")) diff -urN eggdrop1.6.15/src/mod/irc.mod/chan.c eggdrop1.6.15-topicprot/src/mod/irc.mod/chan.c --- eggdrop1.6.15/src/mod/irc.mod/chan.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/irc.mod/chan.c Wed May 7 11:13:46 2003 @@ -1473,12 +1473,14 @@ memberlist *m; struct chanset_t *chan; struct userrec *u; + struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; chname = newsplit(&msg); fixcolon(msg); u = get_user_by_host(from); nick = splitnick(&from); chan = findchan(chname); + get_user_flagrec(u, &fr, chname); if (chan) { putlog(LOG_JOIN, chan->dname, "Topic changed on %s by %s!%s: %s", chan->dname, nick, from, msg); @@ -1487,6 +1489,8 @@ m->last = now; set_topic(chan, msg); check_tcl_topc(nick, from, u, chan->dname, msg); + if (egg_strcasecmp(botname, nick) && !glob_master(fr) && !chan_master(fr)) + check_topic(chan); } return 0; } @@ -1505,6 +1509,7 @@ if (chan) { set_topic(chan, NULL); check_tcl_topc("*", "*", NULL, chan->dname, ""); + check_topic(chan); } return 0; } @@ -1524,6 +1529,7 @@ fixcolon(msg); set_topic(chan, msg); check_tcl_topc("*", "*", NULL, chan->dname, msg); + check_topic(chan); } return 0; } diff -urN eggdrop1.6.15/src/mod/irc.mod/cmdsirc.c eggdrop1.6.15-topicprot/src/mod/irc.mod/cmdsirc.c --- eggdrop1.6.15/src/mod/irc.mod/cmdsirc.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/irc.mod/cmdsirc.c Wed May 7 11:15:35 2003 @@ -895,6 +895,7 @@ static void cmd_topic(struct userrec *u, int idx, char *par) { struct chanset_t *chan; + struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0, 0, 0}; if (par[0] && (strchr(CHANMETA, par[0]) != NULL)) { char *chname = newsplit(&par); @@ -920,6 +921,13 @@ dprintf(idx, "I'm not a channel op or halfop on %s and the channel is " "+t.\n", chan->dname); else { + if (chan->topic_prot[0]) { + get_user_flagrec(u, &fr, chan->dname); + if (!glob_master(fr) && !chan_master(fr)) { + dprintf(idx, "The topic of %s is protected.\n", chan->dname); + return; + } + } dprintf(DP_SERVER, "TOPIC %s :%s\n", chan->name, par); dprintf(idx, "Changing topic...\n"); putlog(LOG_CMDS, "*", "#%s# (%s) topic %s", dcc[idx].nick, diff -urN eggdrop1.6.15/src/mod/irc.mod/mode.c eggdrop1.6.15-topicprot/src/mod/irc.mod/mode.c --- eggdrop1.6.15/src/mod/irc.mod/mode.c Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/irc.mod/mode.c Wed May 7 11:18:41 2003 @@ -460,8 +460,10 @@ } } m->flags |= WASOP; - if (check_chan) + if (check_chan) { recheck_channel(chan, 1); + check_topic(chan); + } } static void got_halfop(struct chanset_t *chan, char *nick, char *from, @@ -549,8 +551,10 @@ } } m->flags |= WASHALFOP; - if (check_chan) + if (check_chan) { recheck_channel(chan, 1); + check_topic(chan); + } } static void got_deop(struct chanset_t *chan, char *nick, char *from, @@ -1223,6 +1227,8 @@ (chan->mode_mns_prot & todo))) add_mode(chan, ms2[0] == '+' ? '-' : '+', *chg, ""); } + if ((ms2[0] == '-') && ((*chg == 't') || (*chg == 'h'))) + check_topic(chan); } chg++; } diff -urN eggdrop1.6.15/src/mod/module.h eggdrop1.6.15-topicprot/src/mod/module.h --- eggdrop1.6.15/src/mod/module.h Mon May 5 00:05:32 2003 +++ eggdrop1.6.15-topicprot/src/mod/module.h Wed May 7 11:19:36 2003 @@ -368,7 +368,7 @@ #define rem_tcl_coups ((void (*) (tcl_coups *))global[210]) #define botname ((char *)(global[211])) /* 212 - 215 */ -/* 212: remove_gunk() -- UNUSED (drummer) */ +#define check_topic ((void (*)(struct chanset_t *))global[212]) #define check_tcl_chjn ((void (*) (const char *,const char *,int,char,int,const char *))global[213]) #define sanitycheck_dcc ((int (*)(char *, char *, char *, char *))global[214]) #define isowner ((int (*)(char *))global[215]) diff -urN eggdrop1.6.15/src/modules.c eggdrop1.6.15-topicprot/src/modules.c --- eggdrop1.6.15/src/modules.c Mon May 5 00:05:33 2003 +++ eggdrop1.6.15-topicprot/src/modules.c Wed May 7 11:20:12 2003 @@ -461,7 +461,7 @@ (Function) rem_tcl_coups, (Function) botname, /* 212 - 215 */ - (Function) 0, /* remove_gunk() -- UNUSED! (drummer) */ + (Function) check_topic, (Function) check_tcl_chjn, (Function) sanitycheck_dcc, (Function) isowner, diff -urN eggdrop1.6.15/src/patch.h eggdrop1.6.15-topicprot/src/patch.h --- eggdrop1.6.15/src/patch.h Mon May 5 00:08:01 2003 +++ eggdrop1.6.15-topicprot/src/patch.h Wed May 7 11:21:14 2003 @@ -36,7 +36,7 @@ * * */ -/* PATCH GOES HERE */ +patch("topicprot"); /* * * diff -urN eggdrop1.6.15/src/proto.h eggdrop1.6.15-topicprot/src/proto.h --- eggdrop1.6.15/src/proto.h Mon May 5 00:05:33 2003 +++ eggdrop1.6.15-topicprot/src/proto.h Wed May 7 11:21:48 2003 @@ -116,6 +116,7 @@ void set_chanlist(const char *host, struct userrec *rec); void clear_chanlist(void); void clear_chanlist_member(const char *nick); +void check_topic(struct chanset_t *); /* cmds.c */ int check_dcc_attrs(struct userrec *, int);