瀏覽代碼

ircd/meetbot: Write nick of person adding the topic.

Luther Blissett 3 年之前
父節點
當前提交
e79ef3ab21
共有 2 個文件被更改,包括 15 次插入8 次删除
  1. 14 7
      bin/ircd/script/meetbot.py
  2. 1 1
      bin/ircd/src/mvc.rs

+ 14 - 7
bin/ircd/script/meetbot.py

@@ -44,7 +44,9 @@ async def channel_listen(host, port, nick, chan):
         if not msg:
             continue
 
-        command = msg.split(" ")[1]
+        split_msg = msg.split(" ")
+        command = split_msg[1]
+        nick = split_msg[0][1:].rsplit("!", 1)[0]
         logging.debug("%s: Recv: %s", chan, msg.rstrip())
 
         if command == "PRIVMSG":
@@ -102,19 +104,24 @@ async def channel_listen(host, port, nick, chan):
                     logging.debug("%s: Topic msg len not 5, skipping", chan)
                     continue
 
-                topic = topic[4].rstrip()
+                topic = topic[4].rstrip() + f" (by {nick})"
 
                 if topic == "":
                     logging.debug("%s: Topic message empty, skipping", chan)
                     continue
 
                 topics = CHANS[chan]["topics"]
-                topics.append(topic)
-                CHANS[chan]["topics"] = topics
-                logging.debug("%s: Appended topic to channel topics", chan)
+                if topic not in topics:
+                    topics.append(topic)
+                    CHANS[chan]["topics"] = topics
+                    logging.debug("%s: Appended topic to channel topics", chan)
+                    reply = f"PRIVMSG {chan} :Added topic: {topic}"
+                    logging.info("%s: Send: %s", chan, reply)
+                else:
+                    logging.debug("%s: Topic already in list of topics", chan)
+                    reply = f"PRIVMSG {chan} :Topic already in list"
+                    logging.info("%s: Send: %s", chan, reply)
 
-                reply = f"PRIVMSG {chan} :Added topic: {topic}"
-                logging.info("%s: Send: %s", chan, reply)
                 writer.write((reply + "\r\n").encode("utf-8"))
                 await writer.drain()
                 continue

+ 1 - 1
bin/ircd/src/mvc.rs

@@ -210,7 +210,7 @@ impl Model {
 
         // set the new root
         if let Some(ancestor) = highest_ancestor {
-            // TODO change this number 
+            // TODO change this number
             // set to 10 for testing only
             // the ancestor must have at least height > 300
             let ancestor_height = self.find_height(&self.current_root, ancestor).unwrap();