summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h6
-rw-r--r--src/cmd_away.cpp2
-rw-r--r--src/modules.cpp2
-rw-r--r--src/modules/m_spanningtree.cpp20
4 files changed, 28 insertions, 2 deletions
diff --git a/include/modules.h b/include/modules.h
index 2ba139e7e..1cdbbdeda 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -289,7 +289,7 @@ enum Implementation { I_OnUserConnect, I_OnUserQuit, I_OnUserDisconnect, I_OnUse
I_OnCheckKey, I_OnCheckLimit, I_OnCheckBan, I_OnStats, I_OnChangeLocalUserHost, I_OnChangeLocalUserGecos, I_OnLocalTopicChange,
I_OnPostLocalTopicChange, I_OnEvent, I_OnRequest, I_OnOperCompre, I_OnGlobalOper, I_OnGlobalConnect, I_OnAddBan, I_OnDelBan,
I_OnRawSocketAccept, I_OnRawSocketClose, I_OnRawSocketWrite, I_OnRawSocketRead, I_OnChangeLocalUserGECOS, I_OnUserRegister,
- I_OnOperCompare, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData };
+ I_OnOperCompare, I_OnChannelDelete, I_OnPostOper, I_OnSyncOtherMetaData, I_OnSetAway, I_OnCancelAway };
/** Base class for all InspIRCd modules
* This class is the base class for InspIRCd modules. All modules must inherit from this class,
@@ -1198,6 +1198,10 @@ class Module : public classbase
* @return nonzero if the event was handled, in which case readresult must be valid on exit
*/
virtual int OnRawSocketRead(int fd, char* buffer, unsigned int count, int &readresult);
+
+ virtual void OnSetAway(userrec* user);
+
+ virtual void OnCancelAway(userrec* user);
};
diff --git a/src/cmd_away.cpp b/src/cmd_away.cpp
index b68dcdeda..4623dc7f7 100644
--- a/src/cmd_away.cpp
+++ b/src/cmd_away.cpp
@@ -46,11 +46,13 @@ void cmd_away::Handle (char **parameters, int pcnt, userrec *user)
{
strlcpy(user->awaymsg,parameters[0],MAXAWAY);
WriteServ(user->fd,"306 %s :You have been marked as being away",user->nick);
+ FOREACH_MOD(I_OnSetAway,OnSetAway(user));
}
else
{
*user->awaymsg = 0;
WriteServ(user->fd,"305 %s :You are no longer marked as being away",user->nick);
+ FOREACH_MOD(I_OnCancelAway,OnCancelAway(user));
}
}
diff --git a/src/modules.cpp b/src/modules.cpp
index 4749bcd3f..38b84c2bd 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -302,6 +302,8 @@ void Module::OnCleanup(int target_type, void* item) { };
void Module::Implements(char* Implements) { for (int j = 0; j < 255; j++) Implements[j] = 0; };
void Module::OnChannelDelete(chanrec* chan) { };
Priority Module::Prioritize() { return PRIORITY_DONTCARE; }
+void Module::OnSetAway(userrec* user) { };
+void Module::OnCancelAway(userrec* user) { };
/* server is a wrapper class that provides methods to all of the C-style
* exports in the core
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index a064aa7d0..c6aa83ee2 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -1248,6 +1248,10 @@ class TreeSocket : public InspSocket
{
this->WriteLine(":"+std::string(u->second->nick)+" OPERTYPE "+std::string(u->second->oper));
}
+ if (*u->second->awaymsg)
+ {
+ this->WriteLine(":"+std::string(u->second->nick)+" AWAY :"+std::string(u->second->awaymsg));
+ }
FOREACH_MOD(I_OnSyncUser,OnSyncUser(u->second,(Module*)TreeProtocolModule,(void*)this));
list.clear();
u->second->GetExtList(list);
@@ -3323,6 +3327,20 @@ class ModuleSpanningTree : public Module
}
}
+ virtual void OnSetAway(userrec* user)
+ {
+ std::deque<std::string> params;
+ params.push_back(":"+std::string(u->awaymsg));
+ DoOneToMany(user->nick,"AWAY",params);
+ }
+
+ virtual void OnCancelAway(userrec* user)
+ {
+ std::deque<std::string> params;
+ params.push_back(":");
+ DoOneToMany(user->nick,"AWAY",params);
+ }
+
virtual void ProtoSendMode(void* opaque, int target_type, void* target, std::string modeline)
{
TreeSocket* s = (TreeSocket*)opaque;
@@ -3392,7 +3410,7 @@ class ModuleSpanningTree : public Module
List[I_OnUserQuit] = List[I_OnUserPostNick] = List[I_OnUserKick] = List[I_OnRemoteKill] = List[I_OnRehash] = 1;
List[I_OnOper] = List[I_OnAddGLine] = List[I_OnAddZLine] = List[I_OnAddQLine] = List[I_OnAddELine] = 1;
List[I_OnDelGLine] = List[I_OnDelZLine] = List[I_OnDelQLine] = List[I_OnDelELine] = List[I_ProtoSendMode] = List[I_OnMode] = 1;
- List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = 1;
+ List[I_OnStats] = List[I_ProtoSendMetaData] = List[I_OnEvent] = List[I_OnSetAway] = List[I_OnCancelAway] = 1;
}
/* It is IMPORTANT that m_spanningtree is the last module in the chain