/** * NickCatchTimer * * Used to regain a user's nickname * * @param Now current time * @param IRCConnection irc connection */ bool NickCatchTimer(time_t Now, void *IRCConnection) { CIRCConnection *IRC = (CIRCConnection *)IRCConnection; CUser *Owner = IRC->GetOwner(); const char *AwayNick; if (Owner != NULL) { AwayNick = IRC->GetOwner()->GetAwayNick(); } else { AwayNick = NULL; } if (Owner && Owner->GetClientConnectionMultiplexer() != NULL) { IRC->m_NickCatchTimer = NULL; return false; } if (IRC->GetCurrentNick() != NULL && AwayNick != NULL && strcmp(IRC->GetCurrentNick(), AwayNick) != 0) { IRC->WriteLine("NICK %s", AwayNick); } IRC->m_NickCatchTimer = NULL; return false; }
/** * PlayToUser * * Sends the log to the specified user. * * @param Client the user who should receive the log * @param Type specifies how the log should be sent, can be one of: * Log_Notices - use IRC notices * Log_Messages - use IRC messages * Log_Motd - use IRC motd replies */ void CLog::PlayToUser(CClientConnection *Client, LogType Type) const { FILE *LogFile; CIRCConnection *IRC = Client->GetOwner()->GetIRCConnection(); const char *Nick = NULL; const char *Server = NULL; if (m_File != NULL) { fclose(m_File); } if (m_Filename != NULL && (LogFile = fopen(m_Filename, "r")) != NULL) { char Line[500]; while (!feof(LogFile)) { char *LinePtr = fgets(Line, sizeof(Line), LogFile); if (LinePtr == NULL) { continue; } char *TempLinePtr = Line; while (*TempLinePtr) { if (*TempLinePtr == '\r' || *TempLinePtr == '\n') { *TempLinePtr = '\0'; break; } TempLinePtr++; } if (Type == Log_Notice) { Client->RealNotice(Line); } else if (Type == Log_Message) { Client->Privmsg(Line); } else if (Type == Log_Motd) { if (IRC != NULL) { Nick = IRC->GetCurrentNick(); Server = IRC->GetServer(); } else { Nick = Client->GetNick(); Server = "bouncer.shroudbnc.info"; } if (Client != NULL) { Client->WriteLine(":%s 372 %s :%s", Server, Nick, Line); } } } fclose(LogFile); m_File = NULL; } if (Type == Log_Motd && Client != NULL && Nick != NULL && Server != NULL) { Client->WriteLine(":%s 376 %s :End of /MOTD command.", Server, Nick); } }