]> jfr.im git - irc/evilnet/x3.git/commitdiff
nefarious 0.5.0 topic support, requires a line to be removed and a line uncommented...
authorsirvulcan <redacted>
Sun, 12 Feb 2006 23:58:58 +0000 (23:58 +0000)
committersirvulcan <redacted>
Sun, 12 Feb 2006 23:58:58 +0000 (23:58 +0000)
src/chanserv.c
src/hash.c
src/hash.h
src/proto-p10.c
src/proto.h

index a21aec53b6bcb1ded5787eda00dbf77ebd0bf0f7..7b10a6953c183e388f4f7f2b6766032a67245981 100644 (file)
@@ -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;
index 4afce1a07401019670c41f0391319ceba9185da6..6e1005ff150f80b1851e0c88ffd3d7e98571ce9e 100644 (file)
@@ -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; n<tf_used; n++)
            if (tf_list[n](user, channel, old_topic))
index 7957ee1b1f636b31e28d4208d0262aef2961a5db..e759e0c704ed7b285552c5eb310b071b8c680507 100644 (file)
@@ -270,7 +270,7 @@ int ChannelExemptExists(struct chanNode *channel, const char *exempt);
 
 typedef int (*topic_func_t)(struct userNode *who, struct chanNode *chan, const char *old_topic);
 void reg_topic_func(topic_func_t handler);
-void SetChannelTopic(struct chanNode *channel, struct userNode *user, const char *topic, int announce);
+void SetChannelTopic(struct chanNode *channel, struct userNode *service, struct userNode *user, const char *topic, int announce);
 struct userNode *IsInChannel(struct chanNode *channel, struct userNode *user);
 
 void init_structs(void);
index 0ff72b9acd48ae791156a0e1cde4405d18bce537..6102ec01709e0cda4e72f7872153f59997528f2e 100644 (file)
@@ -787,8 +787,14 @@ irc_part(struct userNode *who, struct chanNode *what, const char *reason)
 }
 
 void
-irc_topic(struct userNode *who, struct chanNode *what, const char *topic)
+irc_topic(struct userNode *service, struct userNode *who, struct chanNode *what, const char *topic)
 {
+/* UNCOMMENT FOR NEFARIOUS 0.5.0 TOPIC SUPPORT
+ *    putsock("%s " P10_TOPIC " %s %s " FMT_TIME_T " " FMT_TIME_T " :%s", service->numeric, 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;
 }
index 7ac6a319d52a0a14a3bb81002bf8cceb1ae036c8..e8adde900e8d1b2a06d5e940402e52d027dd3e71 100644 (file)
@@ -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 */