Topic command added
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Tue, 02 Feb 2010 12:50:52 +0100
changeset 40 5b7e8dba46a0
parent 39 0ae006af497e
child 41 7260f61566b5
Topic command added The bot can change the topic on the fly right now committer: Markus Bröker <mbroeker@largo.homelinux.org>
src/parse.c
--- a/src/parse.c
+++ b/src/parse.c
@@ -26,7 +26,8 @@
 
 enum command_map {
     HELP, JOIN, LEAVE, ADD, REPLACE, DELETE, LIST, SEARCH, INFO, PING, ON, OFF, DEBUG,
-    VACCUUM, LOGOUT, WHO, WHOIS, TIME, TELL, OP, DEOP, KICK, BAN, UNBAN, KICKBAN, HELLO
+    VACCUUM, LOGOUT, WHO, WHOIS, TIME, TELL, OP, DEOP, KICK, BAN, UNBAN, KICKBAN, HELLO,
+    TOPIC,
 };
 
 const
@@ -46,6 +47,7 @@
     "debug     prints some debug infos\r\n",
     "vaccuum   reorganizes the database\r\n",
     "logout    Protected logout function\r\n",
+    "topic     Sets a new topic\r\n",
     NULL,
 };
 
@@ -62,7 +64,7 @@
     "!who", "!whois", "!time",
     "!tell", "!op", "!deop",
     "!kick", "!ban", "!unban",
-    "!kickban", "!hello",
+    "!kickban", "!hello", "!topic",
     NULL
 };
 
@@ -311,6 +313,13 @@
                 snprintf (msg, sizeof (msg), "PRIVMSG %s :%s, %s?\r\n", message->channel, gettext ("What's up"),
                           message->user);
                 return msg;
+
+            case TOPIC:
+                if ((token = strtok (NULL, "\r\n")) == NULL)
+                    return NULL;
+
+                snprintf (msg, sizeof (msg), "TOPIC %s :%s\r\n", message->channel, token);
+                return msg;
             }
         }
         map++;