op, deop, ban, unban, kick, kickban implemented
authorMarkus Bröker <mbroeker@largo.dyndns.tv>
Sat, 13 Dec 2008 15:41:46 +0100
changeset 19 66114d944208
parent 18 4435146391ae
child 20 b94039112f28
op, deop, ban, unban, kick, kickban implemented committer: Markus Bröker <mbroeker@largo.homelinux.org>
debian/changelog
src/irc.c
src/parse.c
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-mcbot (0.95-1) unstable; urgency=low
+mcbot (0.95-3) unstable; urgency=low
 
   * Initial Release
   * the location of mcbot.cgi is stored in the db
@@ -16,5 +16,6 @@
   * many small improvements, reduced codebase
   * IRC access without password added
   * Help System was able to start a botwar. Fixed
+  * op, deop, kick, ban, unban, kickban implemented
 
- -- Markus Broeker <mbroeker@largo.homelinux.org>  Mon, 11 Aug 2008 20:45:54 +0200
+ -- Markus Broeker <mbroeker@largo.homelinux.org>  Mon, 11 Aug 2008 23:00:01 +0200
--- a/src/irc.c
+++ b/src/irc.c
@@ -32,6 +32,7 @@
 #define PRIVMSG  9
 #define    QUIT 10
 #define    NICK 11
+#define    KICK 12
 
 #define VERSION_STRING "MCBOT on GNU/LINUX"
 
@@ -39,7 +40,7 @@
     "NOTICE", "MODE", "JOIN", "PART",
     "TOPIC", "PING", "ENOMEM", "ERROR",
     "VERSION", "PRIVMSG", "QUIT", "NICK",
-    NULL
+    "KICK", NULL
 };
 
 FILE *irc_connect (char *server, unsigned int port)
@@ -275,6 +276,9 @@
                 case NICK:
                     message->channel = message->user;
                     return command;
+                case KICK:
+                    message->channel = message->user;
+                    return command;
                 }
             }
             i++;
--- a/src/parse.c
+++ b/src/parse.c
@@ -43,6 +43,11 @@
 #define    TIME 17
 #define    TELL 18
 #define      OP 19
+#define    DEOP 20
+#define    KICK 21
+#define     BAN 22
+#define   UNBAN 23
+#define KICKBAN 24
 
 const
 char *COMMAND_LIST[] = {
@@ -74,8 +79,11 @@
     "!list", "!search", "!info",
     "!ping", "!on", "!off",
     "!debug", "!vaccuum", "!logout",
-    "!who", "!whois", "!time", "!tell",
-    "!op", NULL
+    "!who", "!whois", "!time",
+    "!tell", "!op", "!deop",
+    "!kick", "!ban", "!unban",
+    "!kickban",
+    NULL
 };
 
 char *parse (MSG * message)
@@ -284,6 +292,42 @@
                         snprintf (msg, 512, "MODE %s +o %s\r\n", message->channel, token);
                 }
                 return msg;
+
+            case DEOP:
+                if ((token = strtok (NULL, "\r\n")) != NULL) {
+                    if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
+                        snprintf (msg, 512, "MODE %s -o %s\r\n", message->channel, token);
+                }
+                return msg;
+
+            case KICK:
+                if ((token = strtok (NULL, "\r\n")) != NULL) {
+                    if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
+                        snprintf (msg, 512, "KICK %s %s\r\n", message->channel, token);
+                }
+                return msg;
+
+            case BAN:
+                if ((token = strtok (NULL, "\r\n")) != NULL) {
+                    if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
+                        snprintf (msg, 512, "MODE %s +b %s\r\n", message->channel, token);
+                }
+                return msg;
+
+            case UNBAN:
+                if ((token = strtok (NULL, "\r\n")) != NULL) {
+                    if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
+                        snprintf (msg, 512, "MODE %s -b %s\r\n", message->channel, token);
+                }
+                return msg;
+
+            case KICKBAN:
+                if ((token = strtok (NULL, "\r\n")) != NULL) {
+                    if (strstr (message->email, db_lookup (DATABASE_FILE, "mcbot.email")))
+                        snprintf (msg, 512, "MODE %s +b %s\r\nKICK %s %s\r\n", message->channel, token,
+                                  message->channel, token);
+                }
+                return msg;
             }
         }
         i++;