]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/message.cpp
Fix to services sending quits with no reasons
[user/henk/code/inspircd.git] / src / message.cpp
index 63fdae1358181f1955dbe0ca5c8c57f58c0924bd..e71e72a48b032f3ed7a9d0d25d0633ab680d736a 100644 (file)
 #include "wildcard.h"
 #include "message.h"
 
+using namespace std;
+
+extern int MODCOUNT;
+extern vector<Module*> modules;
+extern vector<ircd_module*> factory;
 
 /* return 0 or 1 depending if users u and u2 share one or more common channels
  * (used by QUIT, NICK etc which arent channel specific notices) */
@@ -403,4 +408,78 @@ int has_channel(userrec *u, chanrec *c)
 }
 
 
+void TidyBan(char *ban)
+{
+       if (!ban) {
+               log(DEFAULT,"*** BUG *** TidyBan was given an invalid parameter");
+               return;
+       }
+       
+       char temp[MAXBUF],NICK[MAXBUF],IDENT[MAXBUF],HOST[MAXBUF];
+
+       strcpy(temp,ban);
+
+       char* pos_of_pling = strchr(temp,'!');
+       char* pos_of_at = strchr(temp,'@');
+
+       pos_of_pling[0] = '\0';
+       pos_of_at[0] = '\0';
+       pos_of_pling++;
+       pos_of_at++;
+
+       strncpy(NICK,temp,NICKMAX);
+       strncpy(IDENT,pos_of_pling,IDENTMAX+1);
+       strncpy(HOST,pos_of_at,160);
+
+       sprintf(ban,"%s!%s@%s",NICK,IDENT,HOST);
+}
+
+char lst[MAXBUF];
+
+char* chlist(userrec *user)
+{
+       int i = 0;
+       char cmp[MAXBUF];
+
+        log(DEBUG,"chlist: %s",user->nick);
+       strcpy(lst,"");
+       if (!user)
+       {
+               return lst;
+       }
+       for (int i = 0; i != MAXCHANS; i++)
+       {
+               if (user->chans[i].channel != NULL)
+               {
+                       if (user->chans[i].channel->name)
+                       {
+                               strcpy(cmp,user->chans[i].channel->name);
+                               strcat(cmp," ");
+                               if (!strstr(lst,cmp))
+                               {
+                                       if ((!user->chans[i].channel->c_private) && (!user->chans[i].channel->secret))
+                                       {
+                                               strcat(lst,cmode(user,user->chans[i].channel));
+                                               strcat(lst,user->chans[i].channel->name);
+                                               strcat(lst," ");
+                                       }
+                               }
+                       }
+               }
+       }
+       if (strlen(lst))
+       {
+               lst[strlen(lst)-1] = '\0'; // chop trailing space
+       }
+       return lst;
+}
+
+
+void send_network_quit(const char* nick, const char* reason)
+{
+       char buffer[MAXBUF];
+       snprintf(buffer,MAXBUF,"Q %s :%s",nick,reason);
+       NetSendToAll(buffer);
+}
+