summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h20
-rw-r--r--src/core/cs_info.c6
-rw-r--r--src/core/ns_info.c2
-rw-r--r--src/modules/os_info.c53
4 files changed, 41 insertions, 40 deletions
diff --git a/include/modules.h b/include/modules.h
index afc6806d1..6e7de5188 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -868,6 +868,13 @@ class CoreExport Module
*/
virtual void OnAkickDel(ChannelInfo *ci, AutoKick *ak) { }
+ /** Called when a user requests info for a channel
+ * @param u The user requesting info
+ * @param ci The channel the user is requesting info for
+ * @param ShowHidden true if we should show the user everything
+ */
+ virtual void OnChanInfo(User *u, ChannelInfo *ci, bool ShowHidden) { }
+
/** Called when a nick is dropped
* @param nick The nick
*/
@@ -946,13 +953,20 @@ class CoreExport Module
*/
virtual void OnNickAddAccess(NickCore *nc, const std::string &entry) { }
- /** called from NickCore::EraseAccess()
+ /** Called from NickCore::EraseAccess()
* @param nc pointer to the NickCore
* @param entry The access mask
*/
virtual void OnNickEraseAccess(NickCore *nc, const std::string &entry) { }
- /** called when a vhost is deleted
+ /** Called when a user requests info for a nick
+ * @param u The user requesting info
+ * @param na The nick the user is requesting info from
+ * @param ShowHidden true if we should show the user everything
+ */
+ virtual void OnNickInfo(User *u, NickAlias *na, bool ShowHidden) { }
+
+ /** Called when a vhost is deleted
* @param na The nickalias of the vhost
*/
virtual void OnDeleteVhost(NickAlias *na) { }
@@ -1077,11 +1091,13 @@ enum Implementation
I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended,
I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
I_OnDelNickRequest, I_OnMakeNickRequest, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
+ I_OnNickInfo,
/* ChanServ */
I_OnChanServHelp, I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange,
I_OnAccessDel, I_OnAccessClear, I_OnLevelChange, I_OnChanRegistered, I_OnChanUnsuspend, I_OnDelChan, I_OnChannelCreate,
I_OnChannelDelete, I_OnAkickAdd, I_OnAkickDel,
+ I_OnChanInfo,
/* BotServ */
I_OnBotServHelp, I_OnBotJoin, I_OnBotKick, I_OnBotCreate, I_OnBotChange, I_OnBotDelete, I_OnBotAssign, I_OnBotUnAssign,
diff --git a/src/core/cs_info.c b/src/core/cs_info.c
index 9131d1a3a..b3e7a1077 100644
--- a/src/core/cs_info.c
+++ b/src/core/cs_info.c
@@ -44,7 +44,7 @@ class CommandCSInfo : public Command
char buf[BUFSIZE];
struct tm *tm;
bool has_auspex = u->IsIdentified() && u->Account()->HasPriv("chanserv/auspex");
- int show_all = 0;
+ bool show_all = false;
time_t expt;
ci = cs_findchan(chan);
@@ -64,7 +64,7 @@ class CommandCSInfo : public Command
/* Should we show all fields? Only for sadmins and identified users */
if (!param.empty() && param == "ALL" && (check_access(u, ci, CA_INFO) || has_auspex))
- show_all = 1;
+ show_all = true;
notice_lang(Config.s_ChanServ, u, CHAN_INFO_HEADER, chan);
notice_lang(Config.s_ChanServ, u, CHAN_INFO_NO_FOUNDER, ci->founder->display);
@@ -138,6 +138,8 @@ class CommandCSInfo : public Command
notice_lang(Config.s_ChanServ, u, CHAN_X_SUSPENDED, ci->forbidby, (ci->forbidreason ? ci->forbidreason : getstring(u, NO_REASON)));
}
+ FOREACH_MOD(I_OnChanInfo, OnChanInfo(u, ci, show_all));
+
if (!show_all && (check_access(u, ci, CA_INFO) || has_auspex))
notice_lang(Config.s_ChanServ, u, NICK_INFO_FOR_MORE, Config.s_ChanServ, ci->name.c_str());
return MOD_CONT;
diff --git a/src/core/ns_info.c b/src/core/ns_info.c
index 020745008..976e3d458 100644
--- a/src/core/ns_info.c
+++ b/src/core/ns_info.c
@@ -178,6 +178,8 @@ class CommandNSInfo : public Command
}
}
+ FOREACH_MOD(I_OnNickInfo, OnNickInfo(u, na, show_hidden));
+
if (!show_hidden && u->Account() && (na->nc == u->Account() || has_auspex))
notice_lang(Config.s_NickServ, u, NICK_INFO_FOR_MORE, Config.s_NickServ, na->nick);
}
diff --git a/src/modules/os_info.c b/src/modules/os_info.c
index 87d8ea298..b486e32f6 100644
--- a/src/modules/os_info.c
+++ b/src/modules/os_info.c
@@ -409,8 +409,8 @@ class OSInfo : public Module
this->InsertLanguage(LANG_RU, LANG_NUM_STRINGS, langtable_ru);
this->InsertLanguage(LANG_IT, LANG_NUM_STRINGS, langtable_it);
- Implementation i[] = { I_OnNickServHelp, I_OnChanServHelp, I_OnPostCommand, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata };
- ModuleManager::Attach(i, this, 5);
+ Implementation i[] = { I_OnNickServHelp, I_OnChanServHelp, I_OnNickInfo, I_OnChanInfo, I_OnDatabaseReadMetadata, I_OnDatabaseWriteMetadata };
+ ModuleManager::Attach(i, this, 6);
}
~OSInfo()
@@ -439,42 +439,23 @@ class OSInfo : public Module
}
}
- void OnPostCommand(User *u, const std::string &service, const ci::string &command, const std::vector<ci::string> &params)
+ void OnNickInfo(User *u, NickAlias *na, bool)
{
- if (command == "INFO")
+ if (is_oper(u))
{
- if (service == Config.s_NickServ)
- {
- const char *nick = params[0].c_str();
- NickAlias *na = NULL;
-
- if (is_oper(u)) /* Only show our goodies to opers */
- {
- if ((na = findnick(nick))) /* ok we've found the user */
- {
- /* If we have any info on this user */
- char *c;
- if (na->nc->GetExtArray("os_info", c))
- u->SendMessage(Config.s_NickServ, " OperInfo: %s", c);
- }
- }
- }
- else if (service == Config.s_ChanServ)
- {
- const char *chan = params[0].c_str();
- ChannelInfo *ci = NULL;
-
- if (is_oper(u)) /* Only show our goodies to opers */
- {
- if ((ci = cs_findchan(chan)))
- {
- /* If we have any info on this channel */
- char *c;
- if (ci->GetExtArray("os_info", c))
- u->SendMessage(Config.s_ChanServ, " OperInfo: %s", c);
- }
- }
- }
+ char *c;
+ if (na->nc->GetExtArray("os_info", c))
+ u->SendMessage(Config.s_NickServ, " OperInfo: %s", c);
+ }
+ }
+
+ void OnChanInfo(User *u, ChannelInfo *ci, bool)
+ {
+ if (is_oper(u))
+ {
+ char *c;
+ if (ci->GetExtArray("os_info", c))
+ u->SendMessage(Config.s_ChanServ, " OperInfo: %s", c);
}
}