diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-04 17:16:22 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2005-12-04 17:16:22 +0000 |
commit | 4b7c157f63daae9c59170c8947c1caea48384cf3 (patch) | |
tree | fe978781296218a361c84600ea846a3be6fc2c2a | |
parent | 4ff0001c260adb74d5259de0f3b43334bdc7683b (diff) |
Added notice-to-servermask
Added ability to output 'is an oper but i dont know what type' in WHOIS
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2152 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/helperfuncs.h | 2 | ||||
-rw-r--r-- | include/inspircd.h | 2 | ||||
-rw-r--r-- | src/commands.cpp | 42 | ||||
-rw-r--r-- | src/helperfuncs.cpp | 40 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 2 |
5 files changed, 80 insertions, 8 deletions
diff --git a/include/helperfuncs.h b/include/helperfuncs.h index 53a3d233b..796b2b386 100644 --- a/include/helperfuncs.h +++ b/include/helperfuncs.h @@ -45,6 +45,8 @@ bool ChanAnyOnThisServer(chanrec *c,char* servername); bool CommonOnThisServer(userrec* u,const char* servername); void WriteMode(const char* modes, int flags, const char* text, ...); void NoticeAll(userrec *source, bool local_only, char* text, ...); +void ServerNoticeAll(char* text, ...); +void ServerPrivmsgAll(char* text, ...); void WriteWallOps(userrec *source, bool local_only, char* text, ...); void strlower(char *n); userrec* Find(std::string nick); diff --git a/include/inspircd.h b/include/inspircd.h index ec5f7b26c..1c95eb9e5 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -108,6 +108,8 @@ bool LoadModule(const char* filename); bool UnloadModule(const char* filename); char* ModuleError(); void NoticeAll(userrec *source, bool local_only, char* text, ...); +void ServerNoticeAll(char* text, ...); +void ServerPrivmsgAll(char* text, ...); void NoticeAllOpers(userrec *source, bool local_only, char* text, ...); // optimization tricks to save us walking the user hash diff --git a/src/commands.cpp b/src/commands.cpp index c8aae6dfa..6c5998979 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -583,7 +583,18 @@ void handle_privmsg(char **parameters, int pcnt, userrec *user) if (loop_call(handle_privmsg,parameters,pcnt,user,0,pcnt-2,0)) return; - if (parameters[0][0] == '#') + if (parameters[0][0] == '$') + { + // notice to server mask + char* servermask = parameters[0]; + servermask++; + if (match(ServerName,servermask)) + { + ServerPrivmsgAll(parameters[1]); + } + return; + } + else if (parameters[0][0] == '#') { chan = FindChan(parameters[0]); if (chan) @@ -670,7 +681,18 @@ void handle_notice(char **parameters, int pcnt, userrec *user) if (loop_call(handle_notice,parameters,pcnt,user,0,pcnt-2,0)) return; - if (parameters[0][0] == '#') + if (parameters[0][0] == '$') + { + // notice to server mask + char* servermask = parameters[0]; + servermask++; + if (match(ServerName,servermask)) + { + ServerNoticeAll(parameters[1]); + } + return; + } + else if (parameters[0][0] == '#') { chan = FindChan(parameters[0]); if (chan) @@ -814,19 +836,25 @@ void handle_whois(char **parameters, int pcnt, userrec *user) WriteServ(user->fd,"378 %s %s :is connecting from *@%s %s",user->nick, dest->nick, dest->host, dest->ip); } char* cl = chlist(dest,user); - if (strcmp(cl,"")) + if (*cl) { WriteServ(user->fd,"319 %s %s :%s",user->nick, dest->nick, cl); } WriteServ(user->fd,"312 %s %s %s :%s",user->nick, dest->nick, dest->server, GetServerDescription(dest->server).c_str()); - if (strcmp(dest->awaymsg,"")) + if (*dest->awaymsg) { WriteServ(user->fd,"301 %s %s :%s",user->nick, dest->nick, dest->awaymsg); } - if ((strchr(dest->modes,'o')) && (strcmp(dest->oper,""))) + if (strchr(dest->modes,'o')) { - WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick, - (strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network); + if (*dest->oper) + { + WriteServ(user->fd,"313 %s %s :is %s %s on %s",user->nick, dest->nick, (strchr("aeiou",dest->oper[0]) ? "an" : "a"),dest->oper, Network); + } + else + { + WriteServ(user->fd,"313 %s %s :is opered but has an unknown type",user->nick, dest->nick); + } } FOREACH_MOD OnWhois(user,dest); if (!strcasecmp(user->server,dest->server)) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index ea7b1f9dc..205121edd 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -516,6 +516,46 @@ void WriteOpers(char* text, ...) } } +void ServerNoticeAll(char* text, ...) +{ + if (!text) + return; + + char textbuffer[MAXBUF]; + va_list argsPtr; + va_start (argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + + for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + { + if ((i->second) && (i->second->fd != FD_MAGIC_NUMBER)) + { + WriteServ(i->second->fd,"NOTICE $%s :%s",ServerName,textbuffer); + } + } +} + +void ServerPrivmsgAll(char* text, ...) +{ + if (!text) + return; + + char textbuffer[MAXBUF]; + va_list argsPtr; + va_start (argsPtr, text); + vsnprintf(textbuffer, MAXBUF, text, argsPtr); + va_end(argsPtr); + + for (user_hash::const_iterator i = clientlist.begin(); i != clientlist.end(); i++) + { + if ((i->second) && (i->second->fd != FD_MAGIC_NUMBER)) + { + WriteServ(i->second->fd,"PRIVMSG $%s :%s",ServerName,textbuffer); + } + } +} + void NoticeAllOpers(userrec *source, bool local_only, char* text, ...) { if ((!text) || (!source)) diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 115264e84..d3f1c8229 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -1266,7 +1266,7 @@ bool DoOneToAllButSenderRaw(std::string data,std::string omit,std::string prefix TreeServer* omitroute = BestRouteTo(omit); if ((command == "NOTICE") || (command == "PRIVMSG")) { - if (params.size() >= 2) + if ((params.size() >= 2) && (*(params[0].c_str()) != '$')) { if (*(params[0].c_str()) != '#') { |