]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Added 'i' and 't' type link datagrams
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 11 Apr 2004 13:08:31 +0000 (13:08 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 11 Apr 2004 13:08:31 +0000 (13:08 +0000)
Fixed /mode #channel +b glitch

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@521 e03df62e-2008-0410-955e-edbf42e46eb7

include/ctables.h
include/inspircd.h
include/modules.h
src/InspIRCd.layout
src/inspircd.cpp
src/modules.cpp

index 5ca5e13b395dda8e37b899f9f5391bcc556c5727..ab39bf5f32878fb82889126130b155de5770b172 100644 (file)
@@ -27,17 +27,17 @@ typedef void (handlerfunc) (char**, int, userrec*);
 class command_t : public classbase
 {
  public:
-    /** Command name
-     */
+       /** Command name
+       */
        char command[MAXBUF];
        /** Handler function as in typedef
-     */
+       */
        handlerfunc *handler_function; 
        /** User flags needed to execute the command or 0
         */
        char flags_needed;
-    /** Minimum number of parameters command takes
-     */
+       /** Minimum number of parameters command takes
+       */
        int min_params;
        /** used by /stats m
         */
index 8409c391d350d1f7823282a3ed75b60294870d57..6da27ce3f12754eebeac26b8230dfedba10a157c 100644 (file)
@@ -112,4 +112,6 @@ chanrec* del_channel(userrec *user, const char* cname, const char* reason, bool
 void force_nickchange(userrec* user,const char* newnick);
 void kill_link(userrec *user,const char* r);
 int usercount(chanrec *c);
+void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user);
+void send_network_quit(const char* nick, const char* reason);
 
index 691e6eda109b6930615261bd6a115d1899399198..91688b62279e0bce9f1e95e09049a1c58e68a4f5 100644 (file)
@@ -458,6 +458,19 @@ class Server : public classbase
         * Returns true if the literal successfully matches the pattern, false if otherwise.
         */
        virtual bool MatchText(std::string sliteral, std::string spattern);
+       
+       /** Calls the handler for a command, either implemented by the core or by another module.
+        * You can use this function to trigger other commands in the ircd, such as PRIVMSG, JOIN,
+        * KICK etc, or even as a method of callback. By defining command names that are untypeable
+        * for users on irc (e.g. those which contain a \r or \n) you may use them as callback identifiers.
+        * The first parameter to this method is the name of the command handler you wish to call, e.g.
+        * PRIVMSG. This will be a command handler previously registered by the core or wih AddCommand().
+        * The second parameter is an array of parameters, and the third parameter is a count of parameters
+        * in the array. If you do not pass enough parameters to meet the minimum needed by the handler, the
+        * functiom will silently ignore it. The final parameter is the user executing the command handler,
+        * used for privilage checks, etc.
+        */
+       virtual void CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user);
 };
 
 /** Allows reading of values from configuration files
index 001dbf33f6e3eea75c02b6e0cbb495ad27032fcb..20f417d4d74ca650959554d939c87ebe58e73bd0 100644 (file)
@@ -1,5 +1,5 @@
 [Editors]
-Focused=1
+Focused=-1
 Order=1,2,-1,4,6,3,7,25,5
 
 [Editor_0]
@@ -12,10 +12,10 @@ LeftChar=1
 
 [Editor_1]
 Open=1
-Top=1
-CursorCol=53
-CursorRow=1768
-TopLine=1725
+Top=0
+CursorCol=25
+CursorRow=5168
+TopLine=5141
 LeftChar=1
 
 [Editor_2]
@@ -37,9 +37,9 @@ LeftChar=1
 [Editor_4]
 Open=1
 Top=0
-CursorCol=60
-CursorRow=164
-TopLine=133
+CursorCol=57
+CursorRow=180
+TopLine=145
 LeftChar=1
 
 [Editor_5]
@@ -83,11 +83,11 @@ TopLine=1
 LeftChar=1
 
 [Editor_10]
-Open=0
+Open=1
 Top=0
 CursorCol=31
 CursorRow=75
-TopLine=37
+TopLine=94
 LeftChar=1
 
 [Editor_11]
@@ -115,10 +115,10 @@ TopLine=18
 LeftChar=1
 
 [Editor_14]
-Open=0
-Top=0
+Open=1
+Top=1
 CursorCol=1
-CursorRow=23
+CursorRow=45
 TopLine=1
 LeftChar=1
 
@@ -141,9 +141,9 @@ LeftChar=1
 [Editor_17]
 Open=1
 Top=0
-CursorCol=86
-CursorRow=111
-TopLine=60
+CursorCol=25
+CursorRow=115
+TopLine=62
 LeftChar=1
 
 [Editor_18]
@@ -165,9 +165,9 @@ LeftChar=1
 [Editor_20]
 Open=1
 Top=0
-CursorCol=20
-CursorRow=517
-TopLine=472
+CursorCol=36
+CursorRow=471
+TopLine=425
 LeftChar=1
 
 [Editor_21]
@@ -246,8 +246,8 @@ LeftChar=4
 [Editor_31]
 Open=1
 Top=0
-CursorCol=22
-CursorRow=32
+CursorCol=2
+CursorRow=40
 TopLine=8
 LeftChar=1
 [Editor_32]
index 7ef71ff3aad608611e567f66aa86c1aec809446c..a6cd9813986d2a9dc1f8609b54f0e2319cb1be7c 100644 (file)
@@ -2988,6 +2988,7 @@ void handle_mode(char **parameters, int pcnt, userrec *user)
                                        WriteServ(user->fd,"367 %s %s %s %s %d",user->nick, Ptr->name, i->data, i->set_by, i->set_time);
                                }
                                WriteServ(user->fd,"368 %s %s :End of channel ban list",user->nick, Ptr->name);
+                               return;
                        }
                }
 
@@ -4024,6 +4025,21 @@ void handle_invite(char **parameters, int pcnt, userrec *user)
        u->InviteTo(c->name);
        WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
        WriteServ(user->fd,"341 %s %s %s",user->nick,u->nick,c->name);
+       
+       // i token must go to ALL servers!!!
+       char buffer[MAXBUF];
+       snprintf(buffer,MAXBUF,"i %s %s %s",u->nick,user->nick,c->name);
+       for (int j = 0; j < 255; j++)
+       {
+               if (servers[j] != NULL)
+               {
+                       if (strcmp(servers[j]->name,ServerName))
+                       {
+                               me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+                               log(DEBUG,"Sent i token");
+                       }
+               }
+       }
 }
 
 void handle_topic(char **parameters, int pcnt, userrec *user)
@@ -4078,6 +4094,21 @@ void handle_topic(char **parameters, int pcnt, userrec *user)
                                strcpy(Ptr->setby,user->nick);
                                Ptr->topicset = time(NULL);
                                WriteChannel(Ptr,user,"TOPIC %s :%s",Ptr->name, Ptr->topic);
+
+                               // t token must go to ALL servers!!!
+                               char buffer[MAXBUF];
+                               snprintf(buffer,MAXBUF,"t %s %s :%s",user->nick,Ptr->name,topic);
+                               for (int j = 0; j < 255; j++)
+                               {
+                                       if (servers[j] != NULL)
+                                       {
+                                               if (strcmp(servers[j]->name,ServerName))
+                                               {
+                                                       me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+                                                       log(DEBUG,"Sent t token");
+                                               }
+                                       }
+                               }
                        }
                        else
                        {
@@ -4644,6 +4675,20 @@ void handle_whois(char **parameters, int pcnt, userrec *user)
        }
 }
 
+void send_network_quit(const char* nick, const char* reason)
+{
+               char buffer[MAXBUF];
+               snprintf(buffer,MAXBUF,"Q %s :%s",nick,reason);
+               for (int j = 0; j < 255; j++)
+               {
+                       if (servers[j] != NULL)
+                       {
+                               me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+                               log(DEBUG,"Sent Q token");
+                       }
+               }
+}
+
 void handle_quit(char **parameters, int pcnt, userrec *user)
 {
        user_hash::iterator iter = clientlist.find(user->nick);
@@ -4675,12 +4720,9 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
                        {
                                if (servers[j] != NULL)
                                {
-                                       if (CommonOnThisServer(user,servers[j]->name))
-                                       {
-                                               me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
-                                               log(DEBUG,"Sent Q token");
-                                       }
-                                       }
+                                       me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+                                       log(DEBUG,"Sent Q token");
+                               }
                        }
                }
                else
@@ -4695,12 +4737,9 @@ void handle_quit(char **parameters, int pcnt, userrec *user)
                        {
                                if (servers[j] != NULL)
                                {
-                                       if (CommonOnThisServer(user,servers[j]->name))
-                                       {
-                                               me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
-                                               log(DEBUG,"Sent Q token");
-                                       }
-                                       }
+                                       me[defaultRoute]->SendPacket(buffer,servers[j]->internal_addr,servers[j]->internal_port,MyKey);
+                                       log(DEBUG,"Sent Q token");
+                               }
                        }
                }
                FOREACH_MOD OnUserQuit(user);
@@ -5146,6 +5185,28 @@ void handle_modules(char **parameters, int pcnt, userrec *user)
        }
 }
 
+// calls a handler function for a command
+
+void call_handler(const char* commandname,char **parameters, int pcnt, userrec *user)
+{
+               for (int i = 0; i < cmdlist.size(); i++)
+               {
+                       if (!strcasecmp(cmdlist[i].command,commandname))
+                       {
+                               if (cmdlist[i].handler_function)
+                               {
+                                       if (pcnt>=cmdlist[i].min_params)
+                                       {
+                                               if (strchr(user->modes,cmdlist[i].flags_needed))
+                                               {
+                                                       cmdlist[i].handler_function(parameters,pcnt,user);
+                                               }
+                                       }
+                               }
+                       }
+               }
+}
+
 void handle_stats(char **parameters, int pcnt, userrec *user)
 {
        if (pcnt != 1)
@@ -6001,6 +6062,37 @@ void handle_P(char token,char* params,serverrec* source,serverrec* reply, char*
        
 }
 
+void handle_i(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port)
+{
+       char* nick = strtok(params," ");
+       char* from = strtok(params," ");
+       char* channel = strtok(NULL," ");
+       userrec* u = Find(nick);
+       userrec* user = Find(from);
+       chanrec* c = FindChan(channel);
+       if ((c) && (u) && (user))
+       {
+               u->InviteTo(c->name);
+               WriteFrom(u->fd,user,"INVITE %s :%s",u->nick,c->name);
+       }
+}
+
+void handle_t(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port)
+{
+       char* setby = strtok(params," ");
+       char* channel = strtok(NULL," :");
+       char* topic = strtok(NULL,"\r\n");
+       topic++;
+       userrec* u = Find(setby);
+       chanrec* c = FindChan(channel);
+       if ((c) && (u))
+       {
+               WriteChannelLocal(c,u,"TOPIC %s :%s",c->name,topic);
+               strncpy(c->topic,topic,MAXTOPIC);
+               strncpy(c->setby,u->nick,NICKMAX);
+       }       
+}
+       
 
 void handle_T(char token,char* params,serverrec* source,serverrec* reply, char* udp_host,int udp_port)
 {
@@ -6296,7 +6388,18 @@ void process_restricted_commands(char token,char* params,serverrec* source,serve
                case 'N':
                        handle_N(token,params,source,reply,udp_host,udp_port);
                break;
+               // t <NICK> <CHANNEL> :<TOPIC>
+               // change a channel topic
+               case 't':
+                       handle_t(token,params,source,reply,udp_host,udp_port);
+               break;
+               // i <NICK> <CHANNEL>
+               // invite a user to a channel
+               case 'i':
+                       handle_i(token,params,source,reply,udp_host,udp_port);
+               break;
                // k <SOURCE> <DEST> <CHANNEL> :<REASON>
+               // kick a user from a channel
                case 'k':
                        handle_k(token,params,source,reply,udp_host,udp_port);
                break;
index d2c3f21f9fe6720fc4099af205f69bf484d10ee5..548f6fdcb9841a7e234e493796a95b073ae44ce8 100644 (file)
@@ -171,9 +171,14 @@ void Server::ChangeUserNick(userrec* user, std::string nickname)
 
 void Server::QuitUser(userrec* user, std::string reason)
 {
+       send_network_quit(user->nick,reason.c_str());
        kill_link(user,reason.c_str());
 }
 
+void Server::CallCommandHandler(std::string commandname, char** parameters, int pcnt, userrec* user)
+{
+       call_handler(commandname.c_str(),parameters,pcnt,user);
+}
 
 void Server::Log(int level, std::string s)
 {