From: sirvulcan Date: Sun, 12 Feb 2006 23:58:58 +0000 (+0000) Subject: nefarious 0.5.0 topic support, requires a line to be removed and a line uncommented... X-Git-Tag: 1.9~591 X-Git-Url: https://jfr.im/git/irc/evilnet/x3.git/commitdiff_plain/7fda2b52a31a4d719437281208fafc12d4aa389e?hp=00bce4cd757448fe394d880c9cf8d7c9c5d1d85e nefarious 0.5.0 topic support, requires a line to be removed and a line uncommented. For now this is up to the admin, once 0.5.0 is released ill make the 0.5.0 topic support default and commit it --- diff --git a/src/chanserv.c b/src/chanserv.c index a21aec5..7b10a69 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -4191,13 +4191,18 @@ static CHANSERV_FUNC(cmd_topic) { struct chanData *cData; char *topic; + int p10 = 0; + +#ifdef WITH_PROTOCOL_P10 + p10 = 1; +#endif cData = channel->channel_info; if(argc < 2) { if(cData->topic) { - SetChannelTopic(channel, chanserv, cData->topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, cData->topic, 1); reply("CSMSG_TOPIC_SET", cData->topic); return 1; } @@ -4233,10 +4238,10 @@ static CHANSERV_FUNC(cmd_topic) reply("CSMSG_TOPICMASK_CONFLICT2", TOPICLEN); return 0; } - SetChannelTopic(channel, chanserv, new_topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, new_topic, 1); } else /* No mask set, just set the topic */ - SetChannelTopic(channel, chanserv, topic, 1); + SetChannelTopic(channel, chanserv, p10 ? user : chanserv, topic, 1); } if(check_user_level(channel, user, lvlTopicSnarf, 1, 0)) @@ -5433,7 +5438,7 @@ static MODCMD_FUNC(chan_opt_defaulttopic) && !match_ircglob(channel->channel_info->topic, channel->channel_info->topic_mask)) reply("CSMSG_TOPIC_MISMATCH", channel->name); } - SetChannelTopic(channel, chanserv, topic ? topic : "", 1); + SetChannelTopic(channel, chanserv, chanserv, topic ? topic : "", 1); } if(channel->channel_info->topic) @@ -6352,7 +6357,7 @@ chanserv_refresh_topics(UNUSED_ARG(void *data)) if((refresh_num - cData->last_refresh) < (unsigned int)(1 << (opt - '1'))) continue; if(cData->topic) - SetChannelTopic(cData->channel, chanserv, cData->topic, 1); + SetChannelTopic(cData->channel, chanserv, chanserv, cData->topic, 1); cData->last_refresh = refresh_num; } timeq_add(now + chanserv_conf.refresh_period, chanserv_refresh_topics, NULL); @@ -6710,7 +6715,7 @@ handle_new_channel(struct chanNode *channel) mod_chanmode_announce(chanserv, cData->channel, &cData->modes); if(self->uplink && !self->uplink->burst && channel->channel_info->topic) - SetChannelTopic(channel, chanserv, channel->channel_info->topic, 1); + SetChannelTopic(channel, chanserv, chanserv, channel->channel_info->topic, 1); } /* Welcome to my worst nightmare. Warning: Read (or modify) @@ -7040,7 +7045,7 @@ handle_topic(struct userNode *user, struct chanNode *channel, const char *old_to if(bad_topic(channel, user, channel->topic)) { /* User doesnt have privs to set topics. Undo it */ send_message(user, chanserv, "CSMSG_TOPIC_LOCKED", channel->name); - SetChannelTopic(channel, chanserv, old_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, old_topic, 1); return 1; } /* If there is a topic mask set, and the new topic doesnt match, @@ -7051,12 +7056,12 @@ handle_topic(struct userNode *user, struct chanNode *channel, const char *old_to conform_topic(cData->topic_mask, channel->topic, new_topic); if(*new_topic) { - SetChannelTopic(channel, chanserv, new_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, new_topic, 1); /* and fall through to topicsnarf code below.. */ } else /* Topic couldnt fit into mask, was too long */ { - SetChannelTopic(channel, chanserv, old_topic, 1); + SetChannelTopic(channel, chanserv, chanserv, old_topic, 1); send_message(user, chanserv, "CSMSG_TOPICMASK_CONFLICT1", channel->name, cData->topic_mask); send_message(user, chanserv, "CSMSG_TOPICMASK_CONFLICT2", TOPICLEN); return 1; diff --git a/src/hash.c b/src/hash.c index 4afce1a..6e1005f 100644 --- a/src/hash.c +++ b/src/hash.c @@ -692,7 +692,7 @@ reg_topic_func(topic_func_t handler) } void -SetChannelTopic(struct chanNode *channel, struct userNode *user, const char *topic, int announce) +SetChannelTopic(struct chanNode *channel, struct userNode *service, struct userNode *user, const char *topic, int announce) { unsigned int n; struct modeNode *mn; @@ -713,7 +713,7 @@ SetChannelTopic(struct chanNode *channel, struct userNode *user, const char *top if (announce) { /* We don't really care if a local user messes with the topic, * so don't call the tf_list functions. */ - irc_topic(user, channel, topic); + irc_topic(service, user, channel, topic); } else { for (n=0; nnumeric, what->name, who->nick, what->timestamp, now, topic); + * UNCOMMENT FOR NEFARIOUS 0.5.0 TOPIC SUPPORT */ + + who = service; /* REMOVE LINE FOR NEFARIOUS 0.5.0 */ + putsock("%s " P10_TOPIC " %s :%s", who->numeric, what->name, topic); } @@ -1340,6 +1346,7 @@ static CMD_FUNC(cmd_topic) { struct chanNode *cn; time_t chan_ts, topic_ts; + struct userNode *user; if (argc < 3) return 0; @@ -1347,15 +1354,23 @@ static CMD_FUNC(cmd_topic) log_module(MAIN_LOG, LOG_ERROR, "Unable to find channel %s whose topic is being set", argv[1]); return 0; } - if (argc >= 5) { - /* Looks like an Asuka style topic burst. */ + + + if (argc == 5) { /* Asuka / Topic Bursting IRCu's */ + user = GetUserH(origin); chan_ts = atoi(argv[2]); topic_ts = atoi(argv[3]); - } else { + } else if (argc >= 6) { /* Nefarious 0.5.0 */ + user = GetUserH(strtok(argv[2], "!")); + chan_ts = atoi(argv[3]); + topic_ts = atoi(argv[4]); + } else { /* Regular IRCu (No Topic Bursting)*/ + user = GetUserH(origin); chan_ts = cn->timestamp; topic_ts = now; } - SetChannelTopic(cn, GetUserH(origin), argv[argc-1], 0); + + SetChannelTopic(cn, user, user, argv[argc-1], 0); cn->topic_time = topic_ts; return 1; } diff --git a/src/proto.h b/src/proto.h index 7ac6a31..e8adde9 100644 --- a/src/proto.h +++ b/src/proto.h @@ -135,7 +135,7 @@ void irc_mode(struct userNode *who, struct chanNode *target, const char *modes); void irc_umode(struct userNode *target, const char *modes); void irc_kick(struct userNode *who, struct userNode *target, struct chanNode *from, const char *msg); void irc_part(struct userNode *who, struct chanNode *what, const char *reason); -void irc_topic(struct userNode *who, struct chanNode *what, const char *topic); +void irc_topic(struct userNode *service, struct userNode *who, struct chanNode *what, const char *topic); void irc_fetchtopic(struct userNode *from, const char *to); /* network maintenance */