ServerInstance->AddCommand(mycommand);
}
- void OnRehash(const std::string ¶meter)
+ void OnRehash(userrec* user, const std::string ¶meter)
{
DELETE(Conf);
Conf = new ConfigReader(ServerInstance);
void Implements(char* List)
{
- List[I_OnDecodeMetaData] = List[I_OnWhois] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnPostCommand] = 1;
+ List[I_OnDecodeMetaData] = List[I_OnWhoisLine] = List[I_OnSyncUserMetaData] = List[I_OnUserQuit] = List[I_OnCleanup] = List[I_OnRehash] = List[I_OnPostCommand] = 1;
}
// :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games.
- virtual void OnWhois(userrec* source, userrec* dest)
+ int OnWhoisLine(userrec* user, userrec* dest, int &numeric, std::string &text)
{
- std::string* swhois;
- dest->GetExt("swhois", swhois);
- if (swhois)
+ /* We use this and not OnWhois because this triggers for remote, too */
+ if (numeric == 312)
{
- ServerInstance->SendWhoisLine(source, dest, 320, "%s %s :%s",source->nick,dest->nick,swhois->c_str());
+ /* Insert our numeric before 312 */
+ std::string* swhois;
+ dest->GetExt("swhois", swhois);
+ if (swhois)
+ {
+ ServerInstance->SendWhoisLine(user, dest, 320, "%s %s :%s",user->nick,dest->nick,swhois->c_str());
+ }
}
+ /* Dont block anything */
+ return 0;
}
// Whenever the linking module wants to send out data, but doesnt know what the data
// it is ours.
virtual void OnSyncUserMetaData(userrec* user, Module* proto, void* opaque, const std::string &extname)
{
- ServerInstance->Log(DEBUG,"Sync user metadata type '%s'", extname.c_str());
// check if the linking module wants to know about OUR metadata
if (extname == "swhois")
{
// sees fit, and send it on its way. We dont need or want to know how.
proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*swhois);
}
- else
- {
- ServerInstance->Log(DEBUG,"User has a null swhois string!");
- }
}
}
// when a user quits, tidy up their metadata
- virtual void OnUserQuit(userrec* user, const std::string &message)
+ virtual void OnUserQuit(userrec* user, const std::string &message, const std::string &oper_message)
{
std::string* swhois;
user->GetExt("swhois", swhois);
// check if its our metadata key, and its associated with a user
if ((target_type == TYPE_USER) && (extname == "swhois"))
{
- ServerInstance->Log(DEBUG,"Extend with swhois");
userrec* dest = (userrec*)target;
// if they dont already have an swhois field, accept the remote server's
std::string* text;
{
std::string* text = new std::string(extdata);
dest->Extend("swhois",text);
- ServerInstance->Log(DEBUG,"extended: %s %s", dest->nick, text->c_str());
}
}
}
std::string *text = new std::string(swhois);
user->Extend("swhois", text);
+ std::deque<std::string>* metadata = new std::deque<std::string>;
+ metadata->push_back(user->nick);
+ metadata->push_back("swhois"); // The metadata id
+ metadata->push_back(*text); // The value to send
+ Event event((char*)metadata,(Module*)this,"send_metadata");
+ event.Send(ServerInstance);
+ delete metadata;
}
-
+
virtual ~ModuleSWhois()
{
DELETE(Conf);