Skip to content

Commit

Permalink
Add away timestamp to the AWAY message sent server-server
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11664 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
danieldg committed Sep 2, 2009
1 parent 62e2d69 commit b1002b7
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
46 changes: 46 additions & 0 deletions src/modules/m_spanningtree/away.cpp
@@ -0,0 +1,46 @@
/* +------------------------------------+
* | Inspire Internet Relay Chat Daemon |
* +------------------------------------+
*
* InspIRCd: (C) 2002-2009 InspIRCd Development Team
* See: http://wiki.inspircd.org/Credits
*
* This program is free but copyrighted software; see
* the file COPYING for details.
*
* ---------------------------------------------------
*/

#include "inspircd.h"

#include "main.h"
#include "utils.h"
#include "treeserver.h"
#include "treesocket.h"

bool TreeSocket::Away(const std::string &prefix, parameterlist &params)
{
User* u = this->ServerInstance->FindNick(prefix);
if (!u)
return true;
if (params.size())
{
FOREACH_MOD(I_OnSetAway, OnSetAway(u, params[params.size() - 1]));

if (params.size() > 1)
u->awaytime = atoi(params[0].c_str());
else
u->awaytime = ServerInstance->Time();

u->awaymsg = params[params.size() - 1];

params[params.size() - 1] = ":" + params[params.size() - 1];
}
else
{
FOREACH_MOD(I_OnSetAway, OnSetAway(u, ""));
u->awaymsg.clear();
}
Utils->DoOneToAllButSender(prefix,"AWAY",params,u->server);
return true;
}
8 changes: 8 additions & 0 deletions src/modules/m_spanningtree/compat.cpp
Expand Up @@ -69,6 +69,14 @@ void TreeSocket::WriteLine(std::string line)
std::string uid = line.substr(b, c - b);
line = ":" + ServerInstance->Config->GetSID() + " SVSNICK " + uid + line.substr(b);
}
else if (proto_version < 1202 && command == "AWAY")
{
if (b != std::string::npos)
{
std::string::size_type c = line.find(' ', b + 1);
line.erase(b,c-b);
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_spanningtree/main.cpp
Expand Up @@ -881,12 +881,12 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
if (awaymsg.empty())
{
parameterlist params;
params.clear();
Utils->DoOneToMany(user->uuid,"AWAY",params);
}
else
{
parameterlist params;
params.push_back(ConvToStr(user->awaytime));
params.push_back(":" + awaymsg);
Utils->DoOneToMany(user->uuid,"AWAY",params);
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/m_spanningtree/netburst.cpp
Expand Up @@ -254,7 +254,7 @@ void TreeSocket::SendUsers(TreeServer* Current)
}
if (IS_AWAY(u->second))
{
snprintf(data,MAXBUF,":%s AWAY :%s", u->second->uuid.c_str(), u->second->awaymsg.c_str());
snprintf(data,MAXBUF,":%s AWAY %ld :%s", u->second->uuid.c_str(), (long)u->second->awaytime, u->second->awaymsg.c_str());
this->WriteLine(data);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/modules/m_spanningtree/treesocket.h
Expand Up @@ -291,6 +291,9 @@ class TreeSocket : public BufferedSocket
*/
bool OperType(const std::string &prefix, parameterlist &params);

/** Remote AWAY */
bool Away(const std::string &prefix, parameterlist &params);

/** Because Andy insists that services-compatible servers must
* implement SVSNICK and SVSJOIN, that's exactly what we do :p
*/
Expand Down
4 changes: 4 additions & 0 deletions src/modules/m_spanningtree/treesocket2.cpp
Expand Up @@ -361,6 +361,10 @@ bool TreeSocket::ProcessLine(std::string &line)
{
return this->OperType(prefix,params);
}
else if (command == "AWAY")
{
return this->Away(prefix,params);
}
else if (command == "FMODE")
{
return this->ForceMode(prefix,params);
Expand Down

0 comments on commit b1002b7

Please sign in to comment.